Code Duplication    Length = 46-49 lines in 3 locations

eZ/Publish/Core/Persistence/Cache/Tests/ContentTypeHandlerTest.php 1 location

@@ 145-190 (lines=46) @@
142
    /**
143
     * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadGroup
144
     */
145
    public function testLoadGroupIsMiss()
146
    {
147
        $this->loggerMock->expects($this->once())->method('logCall');
148
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
149
        $this->cacheMock
150
            ->expects($this->once())
151
            ->method('getItem')
152
            ->with('contentTypeGroup', 55)
153
            ->will($this->returnValue($cacheItemMock));
154
155
        $cacheItemMock
156
            ->expects($this->once())
157
            ->method('get')
158
            ->will($this->returnValue(null));
159
160
        $cacheItemMock
161
            ->expects($this->once())
162
            ->method('isMiss')
163
            ->will($this->returnValue(true));
164
165
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler');
166
        $this->persistenceHandlerMock
167
            ->expects($this->once())
168
            ->method('contentTypeHandler')
169
            ->will($this->returnValue($innerHandler));
170
171
        $innerHandler
172
            ->expects($this->once())
173
            ->method('loadGroup')
174
            ->with(55)
175
            ->will($this->returnValue(new SPITypeGroup()));
176
177
        $cacheItemMock
178
            ->expects($this->once())
179
            ->method('set')
180
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Group'))
181
            ->will($this->returnValue($cacheItemMock));
182
183
        $cacheItemMock
184
            ->expects($this->once())
185
            ->method('save')
186
            ->with();
187
188
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
189
        $handler->loadGroup(55);
190
    }
191
192
    /**
193
     * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadGroup

eZ/Publish/Core/Persistence/Cache/Tests/UserHandlerTest.php 1 location

@@ 199-247 (lines=49) @@
196
    /**
197
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole
198
     */
199
    public function testLoadRoleIsMiss()
200
    {
201
        $this->loggerMock->expects($this->once())->method('logCall');
202
203
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
204
        $this->cacheMock
205
            ->expects($this->once())
206
            ->method('getItem')
207
            ->with('user', 'role', 33)
208
            ->will($this->returnValue($cacheItemMock));
209
210
        $cacheItemMock
211
            ->expects($this->once())
212
            ->method('get')
213
            ->will($this->returnValue(null));
214
215
        $cacheItemMock
216
            ->expects($this->once())
217
            ->method('isMiss')
218
            ->will($this->returnValue(true));
219
220
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler');
221
        $this->persistenceHandlerMock
222
            ->expects($this->once())
223
            ->method('userHandler')
224
            ->will($this->returnValue($innerHandlerMock));
225
226
        $innerHandlerMock
227
            ->expects($this->once())
228
            ->method('loadRole')
229
            ->with(33)
230
            ->will(
231
                $this->returnValue(new Role())
232
            );
233
234
        $cacheItemMock
235
            ->expects($this->once())
236
            ->method('set')
237
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Role'))
238
            ->will($this->returnValue($cacheItemMock));
239
240
        $cacheItemMock
241
            ->expects($this->once())
242
            ->method('save')
243
            ->with();
244
245
        $handler = $this->persistenceCacheHandler->userHandler();
246
        $handler->loadRole(33);
247
    }
248
249
    /**
250
     * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole

eZ/Publish/Core/Persistence/Cache/Tests/UrlAliasHandlerTest.php 1 location

@@ 967-1013 (lines=47) @@
964
    /**
965
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias
966
     */
967
    public function testLoadUrlAliasIsMiss()
968
    {
969
        $this->loggerMock->expects($this->once())->method('logCall');
970
971
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
972
        $this->cacheMock
973
            ->expects($this->once())
974
            ->method('getItem')
975
            ->with('urlAlias', 55)
976
            ->will($this->returnValue($cacheItemMock));
977
978
        $cacheItemMock
979
            ->expects($this->once())
980
            ->method('get')
981
            ->will($this->returnValue(null));
982
983
        $cacheItemMock
984
            ->expects($this->once())
985
            ->method('isMiss')
986
            ->will($this->returnValue(true));
987
988
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
989
        $this->persistenceHandlerMock
990
            ->expects($this->once())
991
            ->method('urlAliasHandler')
992
            ->will($this->returnValue($innerHandler));
993
994
        $innerHandler
995
            ->expects($this->once())
996
            ->method('loadUrlAlias')
997
            ->with(55)
998
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
999
1000
        $cacheItemMock
1001
            ->expects($this->once())
1002
            ->method('set')
1003
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias'))
1004
            ->will($this->returnValue($cacheItemMock));
1005
1006
        $cacheItemMock
1007
            ->expects($this->once())
1008
            ->method('save')
1009
            ->with();
1010
1011
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
1012
        $handler->loadUrlAlias(55);
1013
    }
1014
1015
    /**
1016
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias