Code Duplication    Length = 20-21 lines in 3 locations

tests/Doctrine/Tests/ORM/Cache/DefaultCacheFactoryTest.php 3 locations

@@ 129-149 (lines=21) @@
126
        $this->assertInstanceOf(NonStrictReadWriteCachedEntityPersister::class, $cachedPersister);
127
    }
128
129
    public function testBuildCachedCollectionPersisterReadOnly()
130
    {
131
        $em        = $this->em;
132
        $metadata  = $em->getClassMetadata(State::class);
133
        $mapping   = $metadata->associationMappings['cities'];
134
        $persister = new OneToManyPersister($em);
135
        $region    = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
136
137
        $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_ONLY;
138
139
        $this->factory->expects($this->once())
140
            ->method('getRegion')
141
            ->with($this->equalTo($mapping['cache']))
142
            ->will($this->returnValue($region));
143
144
145
        $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);
146
147
        $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister);
148
        $this->assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister);
149
    }
150
151
    public function testBuildCachedCollectionPersisterReadWrite()
152
    {
@@ 151-170 (lines=20) @@
148
        $this->assertInstanceOf(ReadOnlyCachedCollectionPersister::class, $cachedPersister);
149
    }
150
151
    public function testBuildCachedCollectionPersisterReadWrite()
152
    {
153
        $em        = $this->em;
154
        $metadata  = $em->getClassMetadata(State::class);
155
        $mapping   = $metadata->associationMappings['cities'];
156
        $persister = new OneToManyPersister($em);
157
        $region    = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
158
159
        $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_READ_WRITE;
160
161
        $this->factory->expects($this->once())
162
            ->method('getRegion')
163
            ->with($this->equalTo($mapping['cache']))
164
            ->will($this->returnValue($region));
165
166
        $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);
167
168
        $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister);
169
        $this->assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister);
170
    }
171
172
    public function testBuildCachedCollectionPersisterNonStrictReadWrite()
173
    {
@@ 172-191 (lines=20) @@
169
        $this->assertInstanceOf(ReadWriteCachedCollectionPersister::class, $cachedPersister);
170
    }
171
172
    public function testBuildCachedCollectionPersisterNonStrictReadWrite()
173
    {
174
        $em        = $this->em;
175
        $metadata  = $em->getClassMetadata(State::class);
176
        $mapping   = $metadata->associationMappings['cities'];
177
        $persister = new OneToManyPersister($em);
178
        $region    = new ConcurrentRegionMock(new DefaultRegion('regionName', $this->getSharedSecondLevelCacheDriverImpl()));
179
180
        $mapping['cache']['usage'] = ClassMetadata::CACHE_USAGE_NONSTRICT_READ_WRITE;
181
182
        $this->factory->expects($this->once())
183
            ->method('getRegion')
184
            ->with($this->equalTo($mapping['cache']))
185
            ->will($this->returnValue($region));
186
187
        $cachedPersister = $this->factory->buildCachedCollectionPersister($em, $persister, $mapping);
188
189
        $this->assertInstanceOf(CachedCollectionPersister::class, $cachedPersister);
190
        $this->assertInstanceOf(NonStrictReadWriteCachedCollectionPersister::class, $cachedPersister);
191
    }
192
193
    public function testInheritedEntityCacheRegion()
194
    {