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