From 8bb64f0fe13f6675f0d07ca11ce5c3676f02a9ce Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sun, 5 May 2019 10:51:28 +0200 Subject: [PATCH] Add extra test when the fixtures are in the same file but different order (#994) --- tests/Loader/SimpleFilesLoaderTest.php | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/Loader/SimpleFilesLoaderTest.php b/tests/Loader/SimpleFilesLoaderTest.php index 6c0fd682f..38175f9c4 100644 --- a/tests/Loader/SimpleFilesLoaderTest.php +++ b/tests/Loader/SimpleFilesLoaderTest.php @@ -148,4 +148,59 @@ public function testLoadFilesWithDifferentOrder() self::assertArrayHasKey('userdetail_user1', $objects); self::assertArrayHasKey('userdetail_single_user1', $objects); } + + public function testLoadFixturesWithDifferentOrder() + { + $file1 = 'dummy1.yml'; + $file2 = 'dummy2.yml'; + + $file1Data = [ + User::class => [ + 'user1' => [ + 'name' => '', + ], + ], + UserDetail::class => [ + 'userdetail_{@user*}' => [ + 'email' => '', + ], + 'userdetail_single_{@user1}' => [ + 'email' => '', + ], + ], + ]; + $file2Data = [ + UserDetail::class => [ + 'userdetail_{@user*}' => [ + 'email' => '', + ], + 'userdetail_single_{@user1}' => [ + 'email' => '', + ], + ], + User::class => [ + 'user1' => [ + 'name' => '', + ], + ], + ]; + + $parserProphecy = $this->prophesize(ParserInterface::class); + $parserProphecy->parse($file1)->willReturn($file1Data); + $parserProphecy->parse($file2)->willReturn($file2Data); + /** @var ParserInterface $parser */ + $parser = $parserProphecy->reveal(); + + $loader = new SimpleFilesLoader($parser, new IsolatedLoader()); + + $objects = $loader->loadFiles([$file1], [], [])->getObjects(); + self::assertArrayHasKey('user1', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); + + $objects = $loader->loadFiles([$file2], [], [])->getObjects(); + self::assertArrayHasKey('user1', $objects); + self::assertArrayHasKey('userdetail_user1', $objects); + self::assertArrayHasKey('userdetail_single_user1', $objects); + } }