2017-02-10 17:12:51 +01:00
|
|
|
<?php
|
|
|
|
namespace Doctrine\Tests\Functional\Ticket;
|
|
|
|
|
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
|
|
|
|
|
|
|
final class GH6217Test extends OrmFunctionalTestCase
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$this->enableSecondLevelCache();
|
|
|
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->_schemaTool->createSchema(
|
|
|
|
[
|
|
|
|
$this->_em->getClassMetadata(GH6217User::class),
|
|
|
|
$this->_em->getClassMetadata(GH6217Category::class),
|
|
|
|
$this->_em->getClassMetadata(GH6217UserProfile::class),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group 6217
|
|
|
|
*/
|
|
|
|
public function testRetrievingCacheShouldNotThrowUndefinedIndexException()
|
|
|
|
{
|
2017-08-22 21:11:03 +02:00
|
|
|
$user = new GH6217User();
|
|
|
|
$category = new GH6217Category();
|
2017-08-22 21:21:53 +02:00
|
|
|
$userProfile = new GH6217UserProfile($user, $category);
|
2017-02-10 17:12:51 +01:00
|
|
|
|
|
|
|
$this->_em->persist($category);
|
|
|
|
$this->_em->persist($user);
|
|
|
|
$this->_em->persist($userProfile);
|
|
|
|
$this->_em->flush();
|
|
|
|
$this->_em->clear();
|
|
|
|
|
|
|
|
$repository = $this->_em->getRepository(GH6217UserProfile::class);
|
2017-08-22 21:11:03 +02:00
|
|
|
$filters = ['user' => $user->id, 'category' => $category->id];
|
2017-02-10 17:12:51 +01:00
|
|
|
|
|
|
|
$this->assertCount(1, $repository->findBy($filters));
|
|
|
|
$queryCount = $this->getCurrentQueryCount();
|
|
|
|
|
|
|
|
$this->_em->clear();
|
|
|
|
|
|
|
|
$this->assertCount(1, $repository->findBy($filters));
|
|
|
|
$this->assertEquals($queryCount, $this->getCurrentQueryCount());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-22 21:12:45 +02:00
|
|
|
/** @Entity @Cache(usage="NONSTRICT_READ_WRITE") */
|
2017-02-10 17:12:51 +01:00
|
|
|
class GH6217User
|
|
|
|
{
|
2017-08-22 21:17:14 +02:00
|
|
|
/** @Id @Column(type="string") @GeneratedValue(strategy="NONE") */
|
2017-02-10 17:12:51 +01:00
|
|
|
public $id;
|
|
|
|
|
2017-08-22 21:11:03 +02:00
|
|
|
public function __construct()
|
2017-02-10 17:12:51 +01:00
|
|
|
{
|
2017-08-22 21:11:03 +02:00
|
|
|
$this->id = uniqid(self::class, true);
|
2017-02-10 17:12:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-22 21:12:45 +02:00
|
|
|
/** @Entity @Cache(usage="NONSTRICT_READ_WRITE") */
|
2017-02-10 17:12:51 +01:00
|
|
|
class GH6217Category
|
|
|
|
{
|
2017-08-22 21:17:14 +02:00
|
|
|
/** @Id @Column(type="string") @GeneratedValue(strategy="NONE") */
|
2017-02-10 17:12:51 +01:00
|
|
|
public $id;
|
|
|
|
|
2017-08-22 21:11:03 +02:00
|
|
|
public function __construct()
|
2017-02-10 17:12:51 +01:00
|
|
|
{
|
2017-08-22 21:11:03 +02:00
|
|
|
$this->id = uniqid(self::class, true);
|
2017-02-10 17:12:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-22 21:12:45 +02:00
|
|
|
/** @Entity @Cache(usage="NONSTRICT_READ_WRITE") */
|
2017-02-10 17:12:51 +01:00
|
|
|
class GH6217UserProfile
|
|
|
|
{
|
2017-08-22 21:12:45 +02:00
|
|
|
/** @Id @Cache("NONSTRICT_READ_WRITE") @ManyToOne(targetEntity=GH6217User::class) */
|
2017-02-10 17:12:51 +01:00
|
|
|
public $user;
|
|
|
|
|
2017-08-22 21:14:38 +02:00
|
|
|
/** @Id @Cache("NONSTRICT_READ_WRITE") @ManyToOne(targetEntity=GH6217Category::class, fetch="EAGER") */
|
2017-02-10 17:12:51 +01:00
|
|
|
public $category;
|
|
|
|
|
2017-08-22 21:21:53 +02:00
|
|
|
public function __construct(GH6217User $user, GH6217Category $category)
|
2017-02-10 17:12:51 +01:00
|
|
|
{
|
|
|
|
$this->user = $user;
|
|
|
|
$this->category = $category;
|
|
|
|
}
|
|
|
|
}
|