Code Duplication    Length = 52-53 lines in 2 locations

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

@@ 3217-3269 (lines=53) @@
3214
    /**
3215
     * Test for the createUrlAlias() method.
3216
     */
3217
    public function testCreateUrlAlias()
3218
    {
3219
        $permissionResolverMock = $this->createMock(PermissionResolver::class);
3220
        $permissionResolverMock
3221
            ->expects($this->once())
3222
            ->method('hasAccess')->with(
3223
                $this->equalTo('content'),
3224
                $this->equalTo('urltranslator')
3225
            )->will($this->returnValue(true));
3226
3227
        $repositoryMock = $this->getRepositoryMock();
3228
3229
        $repositoryMock
3230
            ->expects($this->atLeastOnce())
3231
            ->method('getPermissionResolver')
3232
            ->willReturn($permissionResolverMock);
3233
3234
        $mockedService = $this->getPartlyMockedURLAliasServiceService();
3235
        /** @var \PHPUnit\Framework\MockObject\MockObject $urlAliasHandlerMock */
3236
        $urlAliasHandlerMock = $this->getPersistenceMock()->urlAliasHandler();
3237
        $location = $this->getLocationStub();
3238
3239
        $repositoryMock
3240
            ->expects($this->once())
3241
            ->method('beginTransaction');
3242
        $repositoryMock
3243
            ->expects($this->once())
3244
            ->method('commit');
3245
3246
        $urlAliasHandlerMock->expects(
3247
            $this->once()
3248
        )->method(
3249
            'createCustomUrlAlias'
3250
        )->with(
3251
            $this->equalTo($location->id),
3252
            $this->equalTo('path'),
3253
            $this->equalTo('forwarding'),
3254
            $this->equalTo('languageCode'),
3255
            $this->equalTo('alwaysAvailable')
3256
        )->will(
3257
            $this->returnValue(new SPIUrlAlias())
3258
        );
3259
3260
        $urlAlias = $mockedService->createUrlAlias(
3261
            $location,
3262
            'path',
3263
            'languageCode',
3264
            'forwarding',
3265
            'alwaysAvailable'
3266
        );
3267
3268
        self::assertInstanceOf(URLAlias::class, $urlAlias);
3269
    }
3270
3271
    /**
3272
     * Test for the createUrlAlias() method.
@@ 3382-3433 (lines=52) @@
3379
    /**
3380
     * Test for the createGlobalUrlAlias() method.
3381
     */
3382
    public function testCreateGlobalUrlAlias()
3383
    {
3384
        $resource = 'module:content/search';
3385
        $permissionResolverMock = $this->createMock(PermissionResolver::class);
3386
        $permissionResolverMock
3387
            ->expects($this->once())
3388
            ->method('hasAccess')->with(
3389
                $this->equalTo('content'),
3390
                $this->equalTo('urltranslator')
3391
            )->will($this->returnValue(true));
3392
3393
        $repositoryMock = $this->getRepositoryMock();
3394
3395
        $repositoryMock
3396
            ->expects($this->atLeastOnce())
3397
            ->method('getPermissionResolver')
3398
            ->willReturn($permissionResolverMock);
3399
        $mockedService = $this->getPartlyMockedURLAliasServiceService();
3400
        /** @var \PHPUnit\Framework\MockObject\MockObject $urlAliasHandlerMock */
3401
        $urlAliasHandlerMock = $this->getPersistenceMock()->urlAliasHandler();
3402
3403
        $repositoryMock
3404
            ->expects($this->once())
3405
            ->method('beginTransaction');
3406
        $repositoryMock
3407
            ->expects($this->once())
3408
            ->method('commit');
3409
3410
        $urlAliasHandlerMock->expects(
3411
            $this->once()
3412
        )->method(
3413
            'createGlobalUrlAlias'
3414
        )->with(
3415
            $this->equalTo($resource),
3416
            $this->equalTo('path'),
3417
            $this->equalTo('forwarding'),
3418
            $this->equalTo('languageCode'),
3419
            $this->equalTo('alwaysAvailable')
3420
        )->will(
3421
            $this->returnValue(new SPIUrlAlias())
3422
        );
3423
3424
        $urlAlias = $mockedService->createGlobalUrlAlias(
3425
            $resource,
3426
            'path',
3427
            'languageCode',
3428
            'forwarding',
3429
            'alwaysAvailable'
3430
        );
3431
3432
        self::assertInstanceOf(URLAlias::class, $urlAlias);
3433
    }
3434
3435
    /**
3436
     * Test for the createGlobalUrlAlias() method.