Conditions | 2 |
Paths | 2 |
Total Lines | 33 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public function testChildEntityRetrievedFromCache(): void |
||
15 | { |
||
16 | $this->loadFixturesCountries(); |
||
17 | $this->loadFixturesStates(); |
||
18 | $this->loadFixturesCities(); |
||
19 | $this->loadFixturesAttractions(); |
||
20 | |||
21 | // Entities are already cached due to fixtures - hence flush before testing |
||
22 | $region = $this->cache->getEntityCacheRegion(Attraction::class); |
||
23 | |||
24 | if ($region instanceof DefaultMultiGetRegion) { |
||
25 | $region->getCache()->flushAll(); |
||
26 | } |
||
27 | |||
28 | /** @var Bar $bar */ |
||
29 | $bar = $this->attractions[0]; |
||
30 | |||
31 | $repository = $this->_em->getRepository(Bar::class); |
||
32 | |||
33 | $this->assertFalse($this->cache->containsEntity(Bar::class, $bar->getId())); |
||
34 | |||
35 | $repository->findOneBy([ |
||
36 | 'name' => $bar->getName(), |
||
37 | ]); |
||
38 | |||
39 | $this->assertTrue($this->cache->containsEntity(Bar::class, $bar->getId())); |
||
40 | |||
41 | $repository->findOneBy([ |
||
42 | 'name' => $bar->getName(), |
||
43 | ]); |
||
44 | |||
45 | // One hit for entity cache, one hit for query cache |
||
46 | $this->assertEquals(2, $this->secondLevelCacheLogger->getHitCount()); |
||
47 | } |
||
49 |