Code Duplication    Length = 34-36 lines in 2 locations

eZ/Publish/Core/Repository/Tests/Service/Mock/UrlWildcardTest.php 2 locations

@@ 325-358 (lines=34) @@
322
     * @depends testConstructor
323
     * @covers \eZ\Publish\Core\Repository\URLWildcardService::remove
324
     */
325
    public function testRemove()
326
    {
327
        $wildcard = new URLWildcard(['id' => 'McBomb']);
328
329
        $mockedService = $this->getPartlyMockedURLWildcardService();
330
        /** @var \PHPUnit_Framework_MockObject_MockObject $handlerMock */
331
        $handlerMock = $this->getPersistenceMock()->urlWildcardHandler();
332
        $repositoryMock = $this->getRepositoryMock();
333
334
        $repositoryMock->expects(
335
            $this->once()
336
        )->method(
337
            'canUser'
338
        )->with(
339
            $this->equalTo('content'),
340
            $this->equalTo('urltranslator'),
341
            $this->equalTo($wildcard)
342
        )->will(
343
            $this->returnValue(true)
344
        );
345
346
        $repositoryMock->expects($this->once())->method('beginTransaction');
347
        $repositoryMock->expects($this->once())->method('commit');
348
349
        $handlerMock->expects(
350
            $this->once()
351
        )->method(
352
            'remove'
353
        )->with(
354
            $this->equalTo('McBomb')
355
        );
356
357
        $mockedService->remove($wildcard);
358
    }
359
360
    /**
361
     * Test for the remove() method.
@@ 367-402 (lines=36) @@
364
     * @covers \eZ\Publish\Core\Repository\URLWildcardService::remove
365
     * @expectedException \Exception
366
     */
367
    public function testRemoveWithRollback()
368
    {
369
        $wildcard = new URLWildcard(['id' => 'McBoo']);
370
371
        $mockedService = $this->getPartlyMockedURLWildcardService();
372
        /** @var \PHPUnit_Framework_MockObject_MockObject $handlerMock */
373
        $handlerMock = $this->getPersistenceMock()->urlWildcardHandler();
374
        $repositoryMock = $this->getRepositoryMock();
375
376
        $repositoryMock->expects(
377
            $this->once()
378
        )->method(
379
            'canUser'
380
        )->with(
381
            $this->equalTo('content'),
382
            $this->equalTo('urltranslator'),
383
            $this->equalTo($wildcard)
384
        )->will(
385
            $this->returnValue(true)
386
        );
387
388
        $repositoryMock->expects($this->once())->method('beginTransaction');
389
        $repositoryMock->expects($this->once())->method('rollback');
390
391
        $handlerMock->expects(
392
            $this->once()
393
        )->method(
394
            'remove'
395
        )->with(
396
            $this->equalTo('McBoo')
397
        )->will(
398
            $this->throwException(new \Exception())
399
        );
400
401
        $mockedService->remove($wildcard);
402
    }
403
404
    /**
405
     * Test for the load() method.