Skip to content

Commit

Permalink
Added return type and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
ilario-pierbattista committed Oct 12, 2018
1 parent 7177163 commit 479a96f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 36 deletions.
15 changes: 12 additions & 3 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,18 @@ $this->get('mongo.connection.{connectionName}'); // [test_db, other_db, test_db_
To manipulate the database, please read the official [documentation](http://mongodb.github.io/mongo-php-library/classes/database/)

### Fixtures
This bundle supports doctrine style fixtures, to create one you will need to create a php class in your bundle '/DataFixtures/Mongo' directory for Example 'src/AppBundle/DataFixtures/Mongo/LoadTaskDataFixture.php'

Note: This class must implement at least the MongoFixtureInterface, if you need container support you can extend AbstractContainerAwareFixture to use the getContainer method.
This bundle supports doctrine style fixtures.
To create one you will need to add a php class in your bundle's `/DataFixtures/Mongo` directory.
For Example `src/AppBundle/DataFixtures/Mongo/LoadTaskDataFixture.php`.

Note: This class must implement at least the `MongoFixtureInterface`, if you need container support you can
extend `AbstractContainerAwareFixture` to use the `getContainer` method.

#### Ordering
Since [0.6.6](https://github.com/facile-it/mongodb-bundle/releases/tag/0.6.6) it's possibile to specify the order by
which the fixtures are loaded.
Make sure it implements `OrderedFixtureInterface`.
Fixtures with lower values of `getOrder` will be loaded first.

### Commands

Expand Down
8 changes: 1 addition & 7 deletions src/Fixtures/OrderedFixtureInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,5 @@
*/
interface OrderedFixtureInterface
{
/**
* Get the order of this fixture
*
* @return integer
*/
public function getOrder();

public function getOrder(): int;
}
14 changes: 1 addition & 13 deletions tests/fixtures/DataFixtures/TestOrderedMongoFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class TestOrderedMongoFixtures extends AbstractContainerAwareFixture implements MongoFixtureInterface, OrderedFixtureInterface
{
/**
* @return array
*/
public function loadData()
{
$doc = [
Expand All @@ -28,24 +25,15 @@ public function loadData()
$collection->insertOne($doc);
}

/**
* Gets priority to sort fixtures order
*/
public function getOrder()
public function getOrder(): int
{
return 1;
}

/**
* @return array
*/
public function loadIndexes()
{
}

/**
* @return string
*/
public function collection(): string
{
return 'testFixturesOrderedCollection';
Expand Down
14 changes: 1 addition & 13 deletions tests/fixtures/DataFixtures/TestOrderedMongoFixtures1.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

class TestOrderedMongoFixtures1 extends AbstractContainerAwareFixture implements MongoFixtureInterface, OrderedFixtureInterface
{
/**
* @return array
*/
public function loadData()
{
$doc = [
Expand All @@ -28,24 +25,15 @@ public function loadData()
$collection->insertOne($doc);
}

/**
* Gets priority to sort fixtures order
*/
public function getOrder()
public function getOrder(): int
{
return 200;
}

/**
* @return array
*/
public function loadIndexes()
{
}

/**
* @return string
*/
public function collection(): string
{
return 'testFixturesOrderedCollection';
Expand Down

0 comments on commit 479a96f

Please sign in to comment.