#1277 DDC-3346 DDC-3531 - refactoring test code for simplicity/readability
This commit is contained in:
parent
16f447d1ac
commit
36bc448880
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user