* @author Toni Uebernickel */ class YamlDataLoaderTest extends TestCase { public function testYamlLoadOneToMany() { $fixtures = <<getTempFile($fixtures); $loader = new YamlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader'); $loader->load(array($filename), 'default'); $books = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookPeer::doSelect(new \Criteria(), $this->con); $this->assertCount(1, $books); $book = $books[0]; $this->assertInstanceOf('Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthor', $book->getBookAuthor()); } public function testYamlLoadManyToMany() { $schema = <<
XML; $fixtures = <<getTempFile($fixtures); $builder = new \PropelQuickBuilder(); $builder->setSchema($schema); $con = $builder->build(); $loader = new YamlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader'); $loader->load(array($filename), 'default'); $books = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlManyToManyBookPeer::doSelect(new \Criteria(), $con); $this->assertCount(1, $books); $this->assertInstanceOf('Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlManyToManyBook', $books[0]); $authors = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlManyToManyAuthorPeer::doSelect(new \Criteria(), $con); $this->assertCount(1, $authors); $this->assertInstanceOf('Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlManyToManyAuthor', $authors[0]); $bookAuthors = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlManyToManyBookAuthorPeer::doSelect(new \Criteria(), $con); $this->assertCount(1, $bookAuthors); $this->assertInstanceOf('Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\YamlManyToManyBookAuthor', $bookAuthors[0]); } public function testLoadSelfReferencing() { $fixtures = <<getTempFile($fixtures); $loader = new YamlDataLoader(__DIR__.'/../../Fixtures/DataFixtures/Loader'); $loader->load(array($filename), 'default'); $books = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookPeer::doSelect(new \Criteria(), $this->con); $this->assertCount(0, $books); $authors = \Propel\PropelBundle\Tests\Fixtures\DataFixtures\Loader\BookAuthorPeer::doSelect(new \Criteria(), $this->con); $this->assertCount(1, $authors); $author = $authors[0]; $this->assertEquals('A famous one', $author->getName()); } }