Skip to content

Commit

Permalink
Add extra test when the fixtures are in the same file but different o…
Browse files Browse the repository at this point in the history
…rder (#994)
  • Loading branch information
goetas authored and theofidry committed May 5, 2019
1 parent 3d8167a commit 8bb64f0
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/Loader/SimpleFilesLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '<username()>',
],
],
UserDetail::class => [
'userdetail_{@user*}' => [
'email' => '<email()>',
],
'userdetail_single_{@user1}' => [
'email' => '<email()>',
],
],
];
$file2Data = [
UserDetail::class => [
'userdetail_{@user*}' => [
'email' => '<email()>',
],
'userdetail_single_{@user1}' => [
'email' => '<email()>',
],
],
User::class => [
'user1' => [
'name' => '<username()>',
],
],
];

$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);
}
}

0 comments on commit 8bb64f0

Please sign in to comment.