| @@ 248-262 (lines=15) @@ | ||
| 245 | /** |
|
| 246 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler::delete |
|
| 247 | */ |
|
| 248 | public function testDeleteSuccess() |
|
| 249 | { |
|
| 250 | $handler = $this->getLanguageHandler(); |
|
| 251 | $gatewayMock = $this->getGatewayMock(); |
|
| 252 | ||
| 253 | $gatewayMock->expects($this->once()) |
|
| 254 | ->method('canDeleteLanguage') |
|
| 255 | ->with($this->equalTo(2)) |
|
| 256 | ->will($this->returnValue(true)); |
|
| 257 | $gatewayMock->expects($this->once()) |
|
| 258 | ->method('deleteLanguage') |
|
| 259 | ->with($this->equalTo(2)); |
|
| 260 | ||
| 261 | $result = $handler->delete(2); |
|
| 262 | } |
|
| 263 | ||
| 264 | /** |
|
| 265 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler::delete |
|
| @@ 268-281 (lines=14) @@ | ||
| 265 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler::delete |
|
| 266 | * @expectedException LogicException |
|
| 267 | */ |
|
| 268 | public function testDeleteFail() |
|
| 269 | { |
|
| 270 | $handler = $this->getLanguageHandler(); |
|
| 271 | $gatewayMock = $this->getGatewayMock(); |
|
| 272 | ||
| 273 | $gatewayMock->expects($this->once()) |
|
| 274 | ->method('canDeleteLanguage') |
|
| 275 | ->with($this->equalTo(2)) |
|
| 276 | ->will($this->returnValue(false)); |
|
| 277 | $gatewayMock->expects($this->never()) |
|
| 278 | ->method('deleteLanguage'); |
|
| 279 | ||
| 280 | $result = $handler->delete(2); |
|
| 281 | } |
|
| 282 | ||
| 283 | /** |
|
| 284 | * Returns the language handler to test. |
|
| @@ 224-242 (lines=19) @@ | ||
| 221 | /** |
|
| 222 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Section\Handler::delete |
|
| 223 | */ |
|
| 224 | public function testDelete() |
|
| 225 | { |
|
| 226 | $handler = $this->getSectionHandler(); |
|
| 227 | ||
| 228 | $gatewayMock = $this->getGatewayMock(); |
|
| 229 | ||
| 230 | $gatewayMock->expects($this->once()) |
|
| 231 | ->method('countContentObjectsInSection') |
|
| 232 | ->with($this->equalTo(23)) |
|
| 233 | ->will($this->returnValue(0)); |
|
| 234 | ||
| 235 | $gatewayMock->expects($this->once()) |
|
| 236 | ->method('deleteSection') |
|
| 237 | ->with( |
|
| 238 | $this->equalTo(23) |
|
| 239 | ); |
|
| 240 | ||
| 241 | $result = $handler->delete(23); |
|
| 242 | } |
|
| 243 | ||
| 244 | /** |
|
| 245 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Section\Handler::delete |
|
| @@ 248-263 (lines=16) @@ | ||
| 245 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Section\Handler::delete |
|
| 246 | * @expectedException RuntimeException |
|
| 247 | */ |
|
| 248 | public function testDeleteFailure() |
|
| 249 | { |
|
| 250 | $handler = $this->getSectionHandler(); |
|
| 251 | ||
| 252 | $gatewayMock = $this->getGatewayMock(); |
|
| 253 | ||
| 254 | $gatewayMock->expects($this->once()) |
|
| 255 | ->method('countContentObjectsInSection') |
|
| 256 | ->with($this->equalTo(23)) |
|
| 257 | ->will($this->returnValue(2)); |
|
| 258 | ||
| 259 | $gatewayMock->expects($this->never()) |
|
| 260 | ->method('deleteSection'); |
|
| 261 | ||
| 262 | $result = $handler->delete(23); |
|
| 263 | } |
|
| 264 | ||
| 265 | /** |
|
| 266 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Section\Handler::assign |
|
| @@ 163-176 (lines=14) @@ | ||
| 160 | /** |
|
| 161 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler::deleteGroup |
|
| 162 | */ |
|
| 163 | public function testDeleteGroupSuccess() |
|
| 164 | { |
|
| 165 | $gatewayMock = $this->getGatewayMock(); |
|
| 166 | $gatewayMock->expects($this->once()) |
|
| 167 | ->method('countTypesInGroup') |
|
| 168 | ->with($this->equalTo(23)) |
|
| 169 | ->will($this->returnValue(0)); |
|
| 170 | $gatewayMock->expects($this->once()) |
|
| 171 | ->method('deleteGroup') |
|
| 172 | ->with($this->equalTo(23)); |
|
| 173 | ||
| 174 | $handler = $this->getHandler(); |
|
| 175 | $handler->deleteGroup(23); |
|
| 176 | } |
|
| 177 | ||
| 178 | /** |
|
| 179 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler::deleteGroup |
|
| @@ 184-196 (lines=13) @@ | ||
| 181 | * @expectedException eZ\Publish\Core\Persistence\Legacy\Exception\GroupNotEmpty |
|
| 182 | * @expectedExceptionMessage Group with ID "23" is not empty. |
|
| 183 | */ |
|
| 184 | public function testDeleteGroupFailure() |
|
| 185 | { |
|
| 186 | $gatewayMock = $this->getGatewayMock(); |
|
| 187 | $gatewayMock->expects($this->once()) |
|
| 188 | ->method('countTypesInGroup') |
|
| 189 | ->with($this->equalTo(23)) |
|
| 190 | ->will($this->returnValue(42)); |
|
| 191 | $gatewayMock->expects($this->never()) |
|
| 192 | ->method('deleteGroup'); |
|
| 193 | ||
| 194 | $handler = $this->getHandler(); |
|
| 195 | $handler->deleteGroup(23); |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * @covers eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler::loadGroup |
|
| @@ 632-651 (lines=20) @@ | ||
| 629 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler::delete |
|
| 630 | * @expectedException \eZ\Publish\Core\Base\Exceptions\NotFoundException |
|
| 631 | */ |
|
| 632 | public function testDeleteThrowsNotFoundException() |
|
| 633 | { |
|
| 634 | $gatewayMock = $this->getGatewayMock(); |
|
| 635 | ||
| 636 | $gatewayMock->expects( |
|
| 637 | $this->once() |
|
| 638 | )->method( |
|
| 639 | 'loadTypeData' |
|
| 640 | )->with( |
|
| 641 | $this->equalTo(23), |
|
| 642 | $this->equalTo(0) |
|
| 643 | )->will( |
|
| 644 | $this->returnValue(array()) |
|
| 645 | ); |
|
| 646 | ||
| 647 | $gatewayMock->expects($this->never())->method('delete'); |
|
| 648 | ||
| 649 | $handler = $this->getHandler(); |
|
| 650 | $res = $handler->delete(23, 0); |
|
| 651 | } |
|
| 652 | ||
| 653 | /** |
|
| 654 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Type\Handler::delete |
|