Code Duplication    Length = 11-15 lines in 4 locations

tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheManyToOneTest.php 1 location

@@ 20-30 (lines=11) @@
17
 */
18
class SecondLevelCacheManyToOneTest extends SecondLevelCacheAbstractTest
19
{
20
    public function testPutOnPersist()
21
    {
22
        $this->loadFixturesCountries();
23
        $this->loadFixturesStates();
24
        $this->em->clear();
25
26
        self::assertTrue($this->cache->containsEntity(Country::class, $this->states[0]->getCountry()->getId()));
27
        self::assertTrue($this->cache->containsEntity(Country::class, $this->states[1]->getCountry()->getId()));
28
        self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
29
        self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
30
    }
31
32
    public function testPutAndLoadManyToOneRelation()
33
    {

tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheOneToManyTest.php 1 location

@@ 20-32 (lines=13) @@
17
 */
18
class SecondLevelCacheOneToManyTest extends SecondLevelCacheAbstractTest
19
{
20
    public function testShouldPutCollectionInverseSideOnPersist()
21
    {
22
        $this->loadFixturesCountries();
23
        $this->loadFixturesStates();
24
        $this->loadFixturesCities();
25
26
        $this->em->clear();
27
28
        self::assertTrue($this->cache->containsEntity(State::class, $this->states[0]->getId()));
29
        self::assertTrue($this->cache->containsEntity(State::class, $this->states[1]->getId()));
30
        self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[0]->getId()));
31
        self::assertTrue($this->cache->containsCollection(State::class, 'cities', $this->states[1]->getId()));
32
    }
33
34
    public function testPutAndLoadOneToManyRelation()
35
    {

tests/Doctrine/Tests/ORM/Functional/SecondLevelCacheQueryCacheTest.php 2 locations

@@ 1058-1072 (lines=15) @@
1055
        self::assertSame($state2, $state2->getCities()->get(0)->getState());
1056
    }
1057
1058
    public function testHintClearEntityRegionUpdateStatement()
1059
    {
1060
        $this->evictRegions();
1061
        $this->loadFixturesCountries();
1062
1063
        self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
1064
        self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
1065
1066
        $this->em->createQuery('DELETE Doctrine\Tests\Models\Cache\Country u WHERE u.id = 4')
1067
            ->setHint(Query::HINT_CACHE_EVICT, true)
1068
            ->execute();
1069
1070
        self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
1071
        self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
1072
    }
1073
1074
    public function testHintClearEntityRegionDeleteStatement()
1075
    {
@@ 1074-1088 (lines=15) @@
1071
        self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
1072
    }
1073
1074
    public function testHintClearEntityRegionDeleteStatement()
1075
    {
1076
        $this->evictRegions();
1077
        $this->loadFixturesCountries();
1078
1079
        self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
1080
        self::assertTrue($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
1081
1082
        $this->em->createQuery("UPDATE Doctrine\Tests\Models\Cache\Country u SET u.name = 'foo' WHERE u.id = 1")
1083
            ->setHint(Query::HINT_CACHE_EVICT, true)
1084
            ->execute();
1085
1086
        self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[0]->getId()));
1087
        self::assertFalse($this->cache->containsEntity(Country::class, $this->countries[1]->getId()));
1088
    }
1089
1090
    /**
1091
     * @expectedException \Doctrine\ORM\Cache\CacheException