Code Duplication    Length = 46-49 lines in 4 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/LocationHandlerTest.php 1 location

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

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

@@ 822-868 (lines=47) @@
819
    /**
820
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias
821
     */
822
    public function testLoadUrlAliasIsMiss()
823
    {
824
        $this->loggerMock->expects($this->once())->method('logCall');
825
826
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
827
        $this->cacheMock
828
            ->expects($this->once())
829
            ->method('getItem')
830
            ->with('urlAlias', 55)
831
            ->will($this->returnValue($cacheItemMock));
832
833
        $cacheItemMock
834
            ->expects($this->once())
835
            ->method('get')
836
            ->will($this->returnValue(null));
837
838
        $cacheItemMock
839
            ->expects($this->once())
840
            ->method('isMiss')
841
            ->will($this->returnValue(true));
842
843
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler');
844
        $this->persistenceHandlerMock
845
            ->expects($this->once())
846
            ->method('urlAliasHandler')
847
            ->will($this->returnValue($innerHandler));
848
849
        $innerHandler
850
            ->expects($this->once())
851
            ->method('loadUrlAlias')
852
            ->with(55)
853
            ->will($this->returnValue(new UrlAlias(array('id' => 55))));
854
855
        $cacheItemMock
856
            ->expects($this->once())
857
            ->method('set')
858
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias'))
859
            ->will($this->returnValue($cacheItemMock));
860
861
        $cacheItemMock
862
            ->expects($this->once())
863
            ->method('save')
864
            ->with();
865
866
        $handler = $this->persistenceCacheHandler->urlAliasHandler();
867
        $handler->loadUrlAlias(55);
868
    }
869
870
    /**
871
     * @covers eZ\Publish\Core\Persistence\Cache\UrlAliasHandler::loadUrlAlias

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