|
@@ 200-222 (lines=23) @@
|
| 197 |
|
/** |
| 198 |
|
* Test for the removeAliases() method. |
| 199 |
|
*/ |
| 200 |
|
public function testRemoveAliases() |
| 201 |
|
{ |
| 202 |
|
$aliasList = [new UrlAlias(['isCustom' => true])]; |
| 203 |
|
$spiAliasList = [new SPIUrlAlias(['isCustom' => true])]; |
| 204 |
|
$repositoryMock = $this->getRepositoryMock(); |
| 205 |
|
$mockedService = $this->getPartlyMockedURLAliasServiceService(); |
| 206 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject $urlAliasHandlerMock */ |
| 207 |
|
$urlAliasHandlerMock = $this->getPersistenceMock()->urlAliasHandler(); |
| 208 |
|
|
| 209 |
|
$repositoryMock |
| 210 |
|
->expects($this->once()) |
| 211 |
|
->method('beginTransaction'); |
| 212 |
|
$repositoryMock |
| 213 |
|
->expects($this->once()) |
| 214 |
|
->method('commit'); |
| 215 |
|
|
| 216 |
|
$urlAliasHandlerMock |
| 217 |
|
->expects($this->once()) |
| 218 |
|
->method('removeURLAliases') |
| 219 |
|
->with($spiAliasList); |
| 220 |
|
|
| 221 |
|
$mockedService->removeAliases($aliasList); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
|
/** |
| 225 |
|
* Test for the removeAliases() method. |
|
@@ 230-253 (lines=24) @@
|
| 227 |
|
* @expectedException \Exception |
| 228 |
|
* @expectedExceptionMessage Handler threw an exception |
| 229 |
|
*/ |
| 230 |
|
public function testRemoveAliasesWithRollback() |
| 231 |
|
{ |
| 232 |
|
$aliasList = [new UrlAlias(['isCustom' => true])]; |
| 233 |
|
$spiAliasList = [new SPIUrlAlias(['isCustom' => true])]; |
| 234 |
|
$repositoryMock = $this->getRepositoryMock(); |
| 235 |
|
$mockedService = $this->getPartlyMockedURLAliasServiceService(); |
| 236 |
|
/** @var \PHPUnit_Framework_MockObject_MockObject $urlAliasHandlerMock */ |
| 237 |
|
$urlAliasHandlerMock = $this->getPersistenceMock()->urlAliasHandler(); |
| 238 |
|
|
| 239 |
|
$repositoryMock |
| 240 |
|
->expects($this->once()) |
| 241 |
|
->method('beginTransaction'); |
| 242 |
|
$repositoryMock |
| 243 |
|
->expects($this->once()) |
| 244 |
|
->method('rollback'); |
| 245 |
|
|
| 246 |
|
$urlAliasHandlerMock |
| 247 |
|
->expects($this->once()) |
| 248 |
|
->method('removeURLAliases') |
| 249 |
|
->with($spiAliasList) |
| 250 |
|
->will($this->throwException(new Exception('Handler threw an exception'))); |
| 251 |
|
|
| 252 |
|
$mockedService->removeAliases($aliasList); |
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
public function providerForTestListAutogeneratedLocationAliasesPath() |
| 256 |
|
{ |