Code Duplication    Length = 41-41 lines in 2 locations

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

@@ 136-176 (lines=41) @@
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
170
        $cacheItemMock
171
            ->expects($this->never())
172
            ->method('get');
173
174
        $handler = $this->persistenceCacheHandler->sectionHandler();
175
        $handler->create('Intranet', 'intranet');
176
    }
177
178
    /**
179
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::delete
@@ 360-400 (lines=41) @@
357
    /**
358
     * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::update
359
     */
360
    public function testUpdate()
361
    {
362
        $this->loggerMock->expects($this->once())->method('logCall');
363
364
        $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler');
365
        $this->persistenceHandlerMock
366
            ->expects($this->once())
367
            ->method('sectionHandler')
368
            ->will($this->returnValue($innerHandler));
369
370
        $innerHandler
371
            ->expects($this->once())
372
            ->method('update')
373
            ->with(33, 'Old Intranet', 'old_intranet')
374
            ->will(
375
                $this->returnValue(
376
                    new SPISection(
377
                        array('id' => 33, 'name' => 'Old Intranet', 'identifier' => 'old_intranet')
378
                    )
379
                )
380
            );
381
382
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
383
        $this->cacheMock
384
            ->expects($this->once())
385
            ->method('getItem')
386
            ->with('section', 33)
387
            ->will($this->returnValue($cacheItemMock));
388
389
        $cacheItemMock
390
            ->expects($this->once())
391
            ->method('set')
392
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Section'));
393
394
        $cacheItemMock
395
            ->expects($this->never())
396
            ->method('get');
397
398
        $handler = $this->persistenceCacheHandler->sectionHandler();
399
        $handler->update(33, 'Old Intranet', 'old_intranet');
400
    }
401
}
402