diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php index 10e1309e3..b2e62f9a6 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3346Test.php @@ -15,25 +15,12 @@ class DDC3346Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->useModelSet('ddc3346'); parent::setUp(); + + $this->loadAuthorFixture(); } public function testFindOneWithEagerFetchWillNotHydrateLimitedCollection() { - $user = new DDC3346Author(); - $user->username = "bwoogy"; - - $article1 = new DDC3346Article(); - $article1->setAuthor($user); - - $article2 = new DDC3346Article(); - $article2->setAuthor($user); - - $this->_em->persist($user); - $this->_em->persist($article1); - $this->_em->persist($article2); - $this->_em->flush(); - $this->_em->clear(); - /** @var DDC3346Author $author */ $author = $this->_em->getRepository(DDC3346Author::CLASSNAME)->findOneBy( array('username' => "bwoogy") @@ -44,21 +31,6 @@ class DDC3346Test extends \Doctrine\Tests\OrmFunctionalTestCase public function testFindLimitedWithEagerFetchWillNotHydrateLimitedCollection() { - $user = new DDC3346Author(); - $user->username = "bwoogy"; - - $article1 = new DDC3346Article(); - $article1->setAuthor($user); - - $article2 = new DDC3346Article(); - $article2->setAuthor($user); - - $this->_em->persist($user); - $this->_em->persist($article1); - $this->_em->persist($article2); - $this->_em->flush(); - $this->_em->clear(); - /** @var DDC3346Author[] $authors */ $authors = $this->_em->getRepository(DDC3346Author::CLASSNAME)->findBy( array('username' => "bwoogy"), @@ -71,6 +43,20 @@ class DDC3346Test extends \Doctrine\Tests\OrmFunctionalTestCase } public function testFindWithEagerFetchAndOffsetWillNotHydrateLimitedCollection() + { + /** @var DDC3346Author[] $authors */ + $authors = $this->_em->getRepository(DDC3346Author::CLASSNAME)->findBy( + array('username' => "bwoogy"), + null, + null, + 1 + ); + + $this->assertCount(1, $authors); + $this->assertCount(2, $authors[0]->articles); + } + + private function loadAuthorFixture() { $user = new DDC3346Author(); $user->username = "bwoogy"; @@ -86,16 +72,5 @@ class DDC3346Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->persist($article2); $this->_em->flush(); $this->_em->clear(); - - /** @var DDC3346Author[] $authors */ - $authors = $this->_em->getRepository(DDC3346Author::CLASSNAME)->findBy( - array('username' => "bwoogy"), - null, - null, - 1 - ); - - $this->assertCount(1, $authors); - $this->assertCount(2, $authors[0]->articles); } }