Skip to content

Commit

Permalink
Merge pull request #278 from Soullivaneuh/default-instance
Browse files Browse the repository at this point in the history
Manage default instance without any properties
  • Loading branch information
tshelburne committed Oct 1, 2015
2 parents 7bb8743 + 528c29b commit e4b48d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nelmio/Alice/Fixtures/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected function buildFixtures(array $rawData)
foreach ($rawData as $class => $specs) {
$this->log('Loading '.$class);
foreach ($specs as $name => $spec) {
$fixtures[] = $this->builder->build($class, $name, $spec);
$fixtures[] = $this->builder->build($class, $name, null !== $spec ? $spec : []);
}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/Nelmio/Alice/Fixtures/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,24 @@ public function testBackslashes()
'\\\\@foo',
], $res['user0']->friends);
}

public function testDefaultInstance()
{
$res = $this->loadData([
self::USER => [
'user (template)' => [
'email' => '[email protected]',
'fullname' => 'testfullname'
],
'user2 (extends user)' => null,
],
]);
$user = $res['user2'];

$this->assertInstanceOf(self::USER, $user);
$this->assertSame('[email protected]', $user->email);
$this->assertSame('testfullname', $user->fullname);
}
}

class FakerProvider
Expand Down

0 comments on commit e4b48d0

Please sign in to comment.