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