Repository: doctrine/data-fixtures (language: php)

Issue:
Demonstrate undefined index notice when using fixture dependent on ordered fixture.
This demonstrates that undefined index notice gets somehow suppressed during standalone tests. That notice stops execution when running doctrine:fixtures:load which is a problem. Sorry about the whitespace formatting, relevant change is at the end of Loader.php diff.



Discussion / hints:

Fix patch:
diff --git a/src/Loader.php b/src/Loader.php
index 9a5d42da..e5088f74 100644
--- a/src/Loader.php
+++ b/src/Loader.php
@@ -403,7 +403,7 @@ private function getUnsequencedClasses(array $sequences, ?iterable $classes = nu
         }
 
         foreach ($classes as $class) {
-            if ($sequences[$class] !== -1) {
+            if (! isset($sequences[$class]) || $sequences[$class] !== -1) {
                 continue;
             }
 


Test patch:
diff --git a/tests/Common/DataFixtures/DependentFixtureTest.php b/tests/Common/DataFixtures/DependentFixtureTest.php
index 044ade99..b4ae00bd 100644
--- a/tests/Common/DataFixtures/DependentFixtureTest.php
+++ b/tests/Common/DataFixtures/DependentFixtureTest.php
@@ -10,11 +10,14 @@
 use Doctrine\Common\DataFixtures\Loader;
 use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
 use Doctrine\Persistence\ObjectManager;
+use Exception;
 use InvalidArgumentException;
 use RuntimeException;
 
 use function array_search;
 use function array_shift;
+use function restore_error_handler;
+use function set_error_handler;
 
 /**
  * Test Fixture ordering by dependencies.
@@ -154,6 +157,29 @@ public function testInCaseGetFixturesReturnsDifferentResultsEachTime(): void
         $this->assertInstanceOf(BaseParentFixture1::class, array_shift($orderedFixtures));
         $this->assertInstanceOf(DependentFixture1::class, array_shift($orderedFixtures));
     }
+
+    public function testOrderFixturesDependingOnOrderedFixture(): void
+    {
+        set_error_handler(static function (int $errno, string $errstr): never {
+            throw new Exception($errstr, $errno);
+        });
+
+        try {
+            $loader = new Loader();
+            $loader->addFixture(new DependingOnOrderedFixture());
+            $loader->addFixture(new OrderedByNumberFixture1());
+            $loader->addFixture(new OrderedByNumberFixture2());
+
+            $orderedFixtures = $loader->getFixtures();
+
+            $this->assertCount(3, $orderedFixtures);
+            $this->assertInstanceOf(OrderedByNumberFixture1::class, array_shift($orderedFixtures));
+            $this->assertInstanceOf(OrderedByNumberFixture2::class, array_shift($orderedFixtures));
+            $this->assertInstanceOf(DependingOnOrderedFixture::class, array_shift($orderedFixtures));
+        } finally {
+            restore_error_handler();
+        }
+    }
 }
 
 class DependentFixture1 implements FixtureInterface, DependentFixtureInterface
@@ -368,6 +394,21 @@ public function getDependencies(): array
     }
 }
 
+class DependingOnOrderedFixture implements FixtureInterface, DependentFixtureInterface
+{
+    public function load(ObjectManager $manager): void
+    {
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function getDependencies(): array
+    {
+        return [OrderedByNumberFixture2::class];
+    }
+}
+
 class FixtureImplementingBothOrderingInterfaces implements FixtureInterface, OrderedFixtureInterface, DependentFixtureInterface
 {
     public function load(ObjectManager $manager): void