Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #82 from fazy/dependent-fix

Dependent fix
  • Loading branch information...
commit a95d7839a7794c7c9b22d64e859ee70658d977fe 2 parents 181b71e + 9584ecc
@guilhermeblanco guilhermeblanco authored
View
6 lib/Doctrine/Common/DataFixtures/Loader.php
@@ -41,7 +41,7 @@ class Loader
*
* @var array
*/
- private $orderedFixtures;
+ private $orderedFixtures = array();
/**
* Determines if we must order fixtures by number
@@ -151,6 +151,8 @@ public function addFixture(FixtureInterface $fixture)
*/
public function getFixtures()
{
+ $this->orderedFixtures = array();
+
if ($this->orderFixturesByNumber) {
$this->orderFixturesByNumber();
}
@@ -297,7 +299,7 @@ private function orderFixturesByDependencies()
}
}
- $this->orderedFixtures = is_array($this->orderedFixtures) ? array_merge($this->orderedFixtures, $orderedFixtures) : $orderedFixtures;
+ $this->orderedFixtures = array_merge($this->orderedFixtures, $orderedFixtures);
}
private function validateDependencies($dependenciesClasses)
View
15 tests/Doctrine/Tests/Common/DataFixtures/DependentFixtureTest.php
@@ -154,6 +154,21 @@ public function test_inCaseAFixtureHasAnUnexistenDependencyOrIfItWasntLoaded_thr
$orderedFixtures = $loader->getFixtures();
}
+
+ public function test_inCaseGetFixturesReturnsDifferentResultsEachTime()
+ {
+ $loader = new Loader();
+ $loader->addFixture(new DependentFixture1);
+ $loader->addFixture(new BaseParentFixture1);
+
+ // Intentionally calling getFixtures() twice
+ $loader->getFixtures();
+ $orderedFixtures = $loader->getFixtures();
+
+ $this->assertCount(2, $orderedFixtures);
+ $this->assertInstanceOf(__NAMESPACE__ . '\BaseParentFixture1', array_shift($orderedFixtures));
+ $this->assertInstanceOf(__NAMESPACE__ . '\DependentFixture1', array_shift($orderedFixtures));
+ }
}
class DependentFixture1 implements FixtureInterface, DependentFixtureInterface
Please sign in to comment.
Something went wrong with that request. Please try again.