예제 #1
0
 public function testLoadFixture()
 {
     $expects = array('user' => array('properties' => array('class' => 'DavidBadura\\Fixtures\\TestObjects\\User', 'constructor' => array(0 => 'name', 1 => 'email')), 'data' => array('david' => array('name' => 'David Badura', 'email' => '*****@*****.**', 'group' => array(0 => '@group:owner', 1 => '@group:developer'), 'role' => array(0 => '@role:admin')), 'other' => array('name' => 'Somebody', 'email' => '*****@*****.**', 'group' => array(0 => '@group:developer'), 'role' => array(0 => '@role:user')))));
     $collection = FixtureCollection::create($expects);
     $data = $this->loader->load(__DIR__ . '/../TestResources/fixtures/user.yml');
     $this->assertEquals($collection, $data);
 }
예제 #2
0
 public function testLoadFixtures()
 {
     $user = array('user' => array('properties' => array('class' => 'DavidBadura\\Fixtures\\TestObjects\\User', 'constructor' => array(0 => 'name', 1 => 'email')), 'data' => array('david' => array('name' => 'David Badura', 'email' => '*****@*****.**', 'group' => array(0 => '@group:owner', 1 => '@group:developer'), 'role' => array(0 => '@role:admin')), 'other' => array('name' => 'Somebody', 'email' => '*****@*****.**', 'group' => array(0 => '@group:developer'), 'role' => array(0 => '@role:user')))));
     $group = array('group' => array('properties' => array('class' => 'DavidBadura\\Fixtures\\TestObjects\\Group'), 'data' => array('developer' => array('name' => 'Developer', 'leader' => '@@user:david'))));
     $role = array('role' => array('properties' => array('class' => 'DavidBadura\\Fixtures\\TestObjects\\Role'), 'data' => array('admin' => array('name' => 'Admin'), 'user' => array('name' => 'User'))));
     $this->assertEquals(FixtureCollection::create($user), $this->loader->load(__DIR__ . '/../TestResources/chainFixtures/user.yml'));
     $this->assertEquals(FixtureCollection::create($group), $this->loader->load(__DIR__ . '/../TestResources/chainFixtures/groups.json'));
     $this->assertEquals(FixtureCollection::create($role), $this->loader->load(__DIR__ . '/../TestResources/chainFixtures/roles.php'));
 }
예제 #3
0
 public function testLoadFixtures()
 {
     $path = __DIR__ . '/../TestResources/chainFixtures';
     $this->mock1->expects($this->once())->method('load')->with($this->equalTo($path))->will($this->returnCallback(function ($var) {
         return new FixtureCollection();
     }));
     $this->mock2->expects($this->once())->method('load')->with($this->equalTo($path))->will($this->returnCallback(function ($var) {
         return new FixtureCollection();
     }));
     $this->loader->load(__DIR__ . '/../TestResources/chainFixtures');
 }
예제 #4
0
 public function testLoadFixturesByPath()
 {
     $files = array();
     $this->mockLoader->expects($this->any())->method('load')->with($this->anything())->will($this->returnCallback(function ($var) use(&$files) {
         $files[] = $var;
         return new FixtureCollection();
     }));
     $path = realpath(__DIR__ . '/../TestResources/chainFixtures');
     $this->loader->load($path);
     $this->assertContains($path . '/roles.php', $files);
     $this->assertContains($path . '/user.yml', $files);
     $this->assertContains($path . '/groups.json', $files);
 }
예제 #5
0
 public function testLoadFixture()
 {
     $this->assertEmpty($this->loader->getTrace());
     $path = realpath(__DIR__ . '/../TestResources/chainFixtures');
     $this->loader->load(array($path . '/roles.php', $path . '/user.yml', $path . '/groups.json'));
     $this->assertContains($path . '/roles.php', $this->loader->getTrace());
     $this->assertContains($path . '/user.yml', $this->loader->getTrace());
     $this->assertContains($path . '/groups.json', $this->loader->getTrace());
     $this->loader->reset();
     $this->assertEmpty($this->loader->getTrace());
     $this->loader->load($path . '/user.yml');
     $this->loader->load($path . '/roles.php');
     $this->loader->load($path . '/groups.json');
     $this->assertContains($path . '/roles.php', $this->loader->getTrace());
     $this->assertContains($path . '/user.yml', $this->loader->getTrace());
     $this->assertContains($path . '/groups.json', $this->loader->getTrace());
 }