1
0
mirror of synced 2025-02-13 10:49:25 +03:00

#6284 renaming variables, classes and properties to fit tested behavior

This commit is contained in:
Marco Pivetta 2017-08-22 21:38:44 +02:00
parent 3f09e20955
commit a2f4053a81
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629

View File

@ -3,9 +3,12 @@ namespace Doctrine\Tests\Functional\Ticket;
use Doctrine\Tests\OrmFunctionalTestCase; use Doctrine\Tests\OrmFunctionalTestCase;
/**
* @group #6217
*/
final class GH6217Test extends OrmFunctionalTestCase final class GH6217Test extends OrmFunctionalTestCase
{ {
public function setUp() public function setUp() : void
{ {
$this->enableSecondLevelCache(); $this->enableSecondLevelCache();
@ -18,37 +21,32 @@ final class GH6217Test extends OrmFunctionalTestCase
]); ]);
} }
/** public function testLoadingOfSecondLevelCacheOnEagerAssociations() : void
* @group 6217
*/
public function testLoadingOfSecondLevelCacheOnEagerAssociations()
{ {
$user = new GH6217LazyEntity(); $lazy = new GH6217LazyEntity();
$category = new GH6217EagerEntity(); $eager = new GH6217EagerEntity();
$userProfile = new GH6217FetchedEntity($user, $category); $fetched = new GH6217FetchedEntity($lazy, $eager);
$this->_em->persist($category); $this->_em->persist($eager);
$this->_em->persist($user); $this->_em->persist($lazy);
$this->_em->persist($userProfile); $this->_em->persist($fetched);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$repository = $this->_em->getRepository(GH6217FetchedEntity::class); $repository = $this->_em->getRepository(GH6217FetchedEntity::class);
$filters = ['category' => $category->id]; $filters = ['eager' => $eager->id];
$this->assertCount(1, $repository->findBy($filters)); $this->assertCount(1, $repository->findBy($filters));
$queryCount = $this->getCurrentQueryCount(); $queryCount = $this->getCurrentQueryCount();
$this->_em->clear();
/* @var $found GH6217FetchedEntity[] */ /* @var $found GH6217FetchedEntity[] */
$found = $repository->findBy($filters); $found = $repository->findBy($filters);
$this->assertCount(1, $found); $this->assertCount(1, $found);
$this->assertInstanceOf(GH6217FetchedEntity::class, $found[0]); $this->assertInstanceOf(GH6217FetchedEntity::class, $found[0]);
$this->assertSame($user->id, $found[0]->user->id); $this->assertSame($lazy->id, $found[0]->lazy->id);
$this->assertSame($category->id, $found[0]->category->id); $this->assertSame($eager->id, $found[0]->eager->id);
$this->assertEquals($queryCount, $this->getCurrentQueryCount()); $this->assertEquals($queryCount, $this->getCurrentQueryCount(), 'No queries were executed in `findBy`');
} }
} }
@ -80,14 +78,14 @@ class GH6217EagerEntity
class GH6217FetchedEntity class GH6217FetchedEntity
{ {
/** @Id @Cache("NONSTRICT_READ_WRITE") @ManyToOne(targetEntity=GH6217LazyEntity::class) */ /** @Id @Cache("NONSTRICT_READ_WRITE") @ManyToOne(targetEntity=GH6217LazyEntity::class) */
public $user; public $lazy;
/** @Id @Cache("NONSTRICT_READ_WRITE") @ManyToOne(targetEntity=GH6217EagerEntity::class, fetch="EAGER") */ /** @Id @Cache("NONSTRICT_READ_WRITE") @ManyToOne(targetEntity=GH6217EagerEntity::class, fetch="EAGER") */
public $category; public $eager;
public function __construct(GH6217LazyEntity $user, GH6217EagerEntity $category) public function __construct(GH6217LazyEntity $lazy, GH6217EagerEntity $eager)
{ {
$this->user = $user; $this->lazy = $lazy;
$this->category = $category; $this->eager = $eager;
} }
} }