1
0
mirror of synced 2025-03-21 07:23:55 +03:00

#1277 DDC-3346 DDC-3531 - refactoring test code for simplicity/readability

This commit is contained in:
Marco Pivetta 2015-01-23 16:19:15 +01:00
parent 16f447d1ac
commit 36bc448880

View File

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