| @@ 3190-3231 (lines=42) @@ | ||
| 3187 | /** |
|
| 3188 | * Test for the createUrlAlias() method. |
|
| 3189 | */ |
|
| 3190 | public function testCreateUrlAlias() |
|
| 3191 | { |
|
| 3192 | $repositoryMock = $this->getRepositoryMock(); |
|
| 3193 | $mockedService = $this->getPartlyMockedURLAliasServiceService(); |
|
| 3194 | /** @var \PHPUnit_Framework_MockObject_MockObject $urlAliasHandlerMock */ |
|
| 3195 | $urlAliasHandlerMock = $this->getPersistenceMock()->urlAliasHandler(); |
|
| 3196 | $location = $this->getLocationStub(); |
|
| 3197 | ||
| 3198 | $repositoryMock |
|
| 3199 | ->expects($this->once()) |
|
| 3200 | ->method('beginTransaction'); |
|
| 3201 | $repositoryMock |
|
| 3202 | ->expects($this->once()) |
|
| 3203 | ->method('commit'); |
|
| 3204 | ||
| 3205 | $urlAliasHandlerMock->expects( |
|
| 3206 | $this->once() |
|
| 3207 | )->method( |
|
| 3208 | 'createCustomUrlAlias' |
|
| 3209 | )->with( |
|
| 3210 | $this->equalTo($location->id), |
|
| 3211 | $this->equalTo('path'), |
|
| 3212 | $this->equalTo('forwarding'), |
|
| 3213 | $this->equalTo('languageCode'), |
|
| 3214 | $this->equalTo('alwaysAvailable') |
|
| 3215 | )->will( |
|
| 3216 | $this->returnValue(new SPIUrlAlias()) |
|
| 3217 | ); |
|
| 3218 | ||
| 3219 | $urlAlias = $mockedService->createUrlAlias( |
|
| 3220 | $location, |
|
| 3221 | 'path', |
|
| 3222 | 'languageCode', |
|
| 3223 | 'forwarding', |
|
| 3224 | 'alwaysAvailable' |
|
| 3225 | ); |
|
| 3226 | ||
| 3227 | self::assertInstanceOf( |
|
| 3228 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
|
| 3229 | $urlAlias |
|
| 3230 | ); |
|
| 3231 | } |
|
| 3232 | ||
| 3233 | /** |
|
| 3234 | * Test for the createUrlAlias() method. |
|
| @@ 3314-3355 (lines=42) @@ | ||
| 3311 | /** |
|
| 3312 | * Test for the createGlobalUrlAlias() method. |
|
| 3313 | */ |
|
| 3314 | public function testCreateGlobalUrlAlias() |
|
| 3315 | { |
|
| 3316 | $resource = 'module:content/search'; |
|
| 3317 | $repositoryMock = $this->getRepositoryMock(); |
|
| 3318 | $mockedService = $this->getPartlyMockedURLAliasServiceService(); |
|
| 3319 | /** @var \PHPUnit_Framework_MockObject_MockObject $urlAliasHandlerMock */ |
|
| 3320 | $urlAliasHandlerMock = $this->getPersistenceMock()->urlAliasHandler(); |
|
| 3321 | ||
| 3322 | $repositoryMock |
|
| 3323 | ->expects($this->once()) |
|
| 3324 | ->method('beginTransaction'); |
|
| 3325 | $repositoryMock |
|
| 3326 | ->expects($this->once()) |
|
| 3327 | ->method('commit'); |
|
| 3328 | ||
| 3329 | $urlAliasHandlerMock->expects( |
|
| 3330 | $this->once() |
|
| 3331 | )->method( |
|
| 3332 | 'createGlobalUrlAlias' |
|
| 3333 | )->with( |
|
| 3334 | $this->equalTo($resource), |
|
| 3335 | $this->equalTo('path'), |
|
| 3336 | $this->equalTo('forwarding'), |
|
| 3337 | $this->equalTo('languageCode'), |
|
| 3338 | $this->equalTo('alwaysAvailable') |
|
| 3339 | )->will( |
|
| 3340 | $this->returnValue(new SPIUrlAlias()) |
|
| 3341 | ); |
|
| 3342 | ||
| 3343 | $urlAlias = $mockedService->createGlobalUrlAlias( |
|
| 3344 | $resource, |
|
| 3345 | 'path', |
|
| 3346 | 'languageCode', |
|
| 3347 | 'forwarding', |
|
| 3348 | 'alwaysAvailable' |
|
| 3349 | ); |
|
| 3350 | ||
| 3351 | self::assertInstanceOf( |
|
| 3352 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
|
| 3353 | $urlAlias |
|
| 3354 | ); |
|
| 3355 | } |
|
| 3356 | ||
| 3357 | /** |
|
| 3358 | * Test for the createGlobalUrlAlias() method. |
|