Code Duplication    Length = 46-49 lines in 4 locations

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

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

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

@@ 23-68 (lines=46) @@
20
    /**
21
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::load
22
     */
23
    public function testLoadCacheIsMiss()
24
    {
25
        $this->loggerMock->expects($this->once())->method('logCall');
26
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
27
        $this->cacheMock
28
            ->expects($this->once())
29
            ->method('getItem')
30
            ->with('location', 33)
31
            ->will($this->returnValue($cacheItemMock));
32
33
        $cacheItemMock
34
            ->expects($this->once())
35
            ->method('get')
36
            ->will($this->returnValue(null));
37
38
        $cacheItemMock
39
            ->expects($this->once())
40
            ->method('isMiss')
41
            ->will($this->returnValue(true));
42
43
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler');
44
        $this->persistenceHandlerMock
45
            ->expects($this->once())
46
            ->method('locationHandler')
47
            ->will($this->returnValue($innerHandlerMock));
48
49
        $innerHandlerMock
50
            ->expects($this->once())
51
            ->method('load')
52
            ->with(33)
53
            ->will($this->returnValue(new Location(array('id' => 33))));
54
55
        $cacheItemMock
56
            ->expects($this->once())
57
            ->method('set')
58
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Location'))
59
            ->will($this->returnValue($cacheItemMock));
60
61
        $cacheItemMock
62
            ->expects($this->once())
63
            ->method('save')
64
            ->with();
65
66
        $handler = $this->persistenceCacheHandler->locationHandler();
67
        $handler->load(33);
68
    }
69
70
    /**
71
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::load

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

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

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

@@ 898-944 (lines=47) @@
895
    /**
896
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias
897
     */
898
    public function testLoadUrlAliasIsMiss()
899
    {
900
        $this->loggerMock->expects($this->once())->method('logCall');
901
902
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
903
        $this->cacheMock
904
            ->expects($this->once())
905
            ->method('getItem')
906
            ->with('urlAlias', 55)
907
            ->will($this->returnValue($cacheItemMock));
908
909
        $cacheItemMock
910
            ->expects($this->once())
911
            ->method('get')
912
            ->will($this->returnValue(null));
913
914
        $cacheItemMock
915
            ->expects($this->once())
916
            ->method('isMiss')
917
            ->will($this->returnValue(true));
918
919
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
920
        $this->persistenceHandlerMock
921
            ->expects($this->once())
922
            ->method('urlAliasHandler')
923
            ->will($this->returnValue($innerHandler));
924
925
        $innerHandler
926
            ->expects($this->once())
927
            ->method('loadUrlAlias')
928
            ->with(55)
929
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
930
931
        $cacheItemMock
932
            ->expects($this->once())
933
            ->method('set')
934
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias'))
935
            ->will($this->returnValue($cacheItemMock));
936
937
        $cacheItemMock
938
            ->expects($this->once())
939
            ->method('save')
940
            ->with();
941
942
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
943
        $handler->loadUrlAlias(55);
944
    }
945
946
    /**
947
     * @covers \eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias