Code Duplication    Length = 47-47 lines in 2 locations

eZ/Publish/Core/Persistence/Cache/Tests/SectionHandlerTest.php 2 locations

@@ 136-182 (lines=47) @@
133
    /**
134
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::create
135
     */
136
    public function testCreate()
137
    {
138
        $this->loggerMock->expects($this->once())->method('logCall');
139
140
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler');
141
        $this->persistenceHandlerMock
142
            ->expects($this->once())
143
            ->method('sectionHandler')
144
            ->will($this->returnValue($innerHandlerMock));
145
146
        $innerHandlerMock
147
            ->expects($this->once())
148
            ->method('create')
149
            ->with('Intranet', 'intranet')
150
            ->will(
151
                $this->returnValue(
152
                    new SPISection(
153
                        array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet')
154
                    )
155
                )
156
            );
157
158
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
159
        $this->cacheMock
160
            ->expects($this->once())
161
            ->method('getItem')
162
            ->with('section', 33)
163
            ->will($this->returnValue($cacheItemMock));
164
165
        $cacheItemMock
166
            ->expects($this->once())
167
            ->method('set')
168
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Section'))
169
            ->will($this->returnValue($cacheItemMock));
170
171
        $cacheItemMock
172
            ->expects($this->once())
173
            ->method('save')
174
            ->with();
175
176
        $cacheItemMock
177
            ->expects($this->never())
178
            ->method('get');
179
180
        $handler = $this->persistenceCacheHandler->sectionHandler();
181
        $handler->create('Intranet', 'intranet');
182
    }
183
184
    /**
185
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::delete
@@ 372-418 (lines=47) @@
369
    /**
370
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::update
371
     */
372
    public function testUpdate()
373
    {
374
        $this->loggerMock->expects($this->once())->method('logCall');
375
376
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler');
377
        $this->persistenceHandlerMock
378
            ->expects($this->once())
379
            ->method('sectionHandler')
380
            ->will($this->returnValue($innerHandler));
381
382
        $innerHandler
383
            ->expects($this->once())
384
            ->method('update')
385
            ->with(33, 'Old Intranet', 'old_intranet')
386
            ->will(
387
                $this->returnValue(
388
                    new SPISection(
389
                        array('id' => 33, 'name' => 'Old Intranet', 'identifier' => 'old_intranet')
390
                    )
391
                )
392
            );
393
394
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
395
        $this->cacheMock
396
            ->expects($this->once())
397
            ->method('getItem')
398
            ->with('section', 33)
399
            ->will($this->returnValue($cacheItemMock));
400
401
        $cacheItemMock
402
            ->expects($this->once())
403
            ->method('set')
404
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Section'))
405
            ->will($this->returnValue($cacheItemMock));
406
407
        $cacheItemMock
408
            ->expects($this->once())
409
            ->method('save')
410
            ->with();
411
412
        $cacheItemMock
413
            ->expects($this->never())
414
            ->method('get');
415
416
        $handler = $this->persistenceCacheHandler->sectionHandler();
417
        $handler->update(33, 'Old Intranet', 'old_intranet');
418
    }
419
}
420