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