Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like URLAliasServiceTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use URLAliasServiceTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 28 | class URLAliasServiceTest extends BaseTest |
||
| 29 | { |
||
| 30 | /** |
||
| 31 | * Tests that the required <b>LocationService::loadLocation()</b> |
||
| 32 | * at least returns an object, because this method is utilized in several |
||
| 33 | * tests. |
||
| 34 | */ |
||
| 35 | View Code Duplication | protected function setUp(): void |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Test for the createUrlAlias() method. |
||
| 69 | * |
||
| 70 | * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias() |
||
| 71 | */ |
||
| 72 | public function testCreateUrlAlias() |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @param array $testData |
||
| 99 | * |
||
| 100 | * @depends testCreateUrlAlias |
||
| 101 | */ |
||
| 102 | View Code Duplication | public function testCreateUrlAliasPropertyValues(array $testData) |
|
| 122 | |||
| 123 | /** |
||
| 124 | * Test for the createUrlAlias() method. |
||
| 125 | * |
||
| 126 | * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding) |
||
| 127 | * @depends testCreateUrlAliasPropertyValues |
||
| 128 | */ |
||
| 129 | View Code Duplication | public function testCreateUrlAliasWithForwarding() |
|
| 153 | |||
| 154 | /** |
||
| 155 | * @param array $testData |
||
| 156 | * |
||
| 157 | * @depends testCreateUrlAliasWithForwarding |
||
| 158 | */ |
||
| 159 | View Code Duplication | public function testCreateUrlAliasPropertyValuesWithForwarding(array $testData) |
|
| 179 | |||
| 180 | /** |
||
| 181 | * Test for the createUrlAlias() method. |
||
| 182 | * |
||
| 183 | * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable) |
||
| 184 | */ |
||
| 185 | View Code Duplication | public function testCreateUrlAliasWithAlwaysAvailable() |
|
| 209 | |||
| 210 | /** |
||
| 211 | * @param array $testData |
||
| 212 | * |
||
| 213 | * @depends testCreateUrlAliasWithAlwaysAvailable |
||
| 214 | */ |
||
| 215 | View Code Duplication | public function testCreateUrlAliasPropertyValuesWithAlwaysAvailable(array $testData) |
|
| 235 | |||
| 236 | /** |
||
| 237 | * Test for the createUrlAlias() method. |
||
| 238 | * |
||
| 239 | * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias() |
||
| 240 | */ |
||
| 241 | public function testCreateUrlAliasThrowsInvalidArgumentException() |
||
| 242 | { |
||
| 243 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); |
||
| 244 | |||
| 245 | $repository = $this->getRepository(); |
||
| 246 | |||
| 247 | $locationId = $this->generateId('location', 5); |
||
| 248 | |||
| 249 | /* BEGIN: Use Case */ |
||
| 250 | // $locationId is the ID of an existing location |
||
| 251 | |||
| 252 | $locationService = $repository->getLocationService(); |
||
| 253 | $urlAliasService = $repository->getURLAliasService(); |
||
| 254 | |||
| 255 | $location = $locationService->loadLocation($locationId); |
||
| 256 | |||
| 257 | // Throws InvalidArgumentException, since this path already exists for the |
||
| 258 | // language |
||
| 259 | $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Design/Plain-site', 'eng-US'); |
||
|
|
|||
| 260 | /* END: Use Case */ |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Test for the createGlobalUrlAlias() method. |
||
| 265 | * |
||
| 266 | * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias() |
||
| 267 | */ |
||
| 268 | View Code Duplication | public function testCreateGlobalUrlAlias() |
|
| 269 | { |
||
| 270 | $repository = $this->getRepository(); |
||
| 271 | |||
| 272 | /* BEGIN: Use Case */ |
||
| 273 | $urlAliasService = $repository->getURLAliasService(); |
||
| 274 | |||
| 275 | $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( |
||
| 276 | 'module:content/search?SearchText=eZ', |
||
| 277 | '/Home/My-New-Site', |
||
| 278 | 'eng-US' |
||
| 279 | ); |
||
| 280 | /* END: Use Case */ |
||
| 281 | |||
| 282 | $this->assertInstanceOf( |
||
| 283 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
||
| 284 | $createdUrlAlias |
||
| 285 | ); |
||
| 286 | |||
| 287 | return $createdUrlAlias; |
||
| 288 | } |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @param \eZ\Publish\API\Repository\Values\Content\URLAlias |
||
| 292 | * |
||
| 293 | * @depends testCreateGlobalUrlAlias |
||
| 294 | */ |
||
| 295 | View Code Duplication | public function testCreateGlobalUrlAliasPropertyValues(URLAlias $createdUrlAlias) |
|
| 296 | { |
||
| 297 | $this->assertNotNull($createdUrlAlias->id); |
||
| 298 | |||
| 299 | $this->assertPropertiesCorrect( |
||
| 300 | [ |
||
| 301 | 'type' => URLAlias::RESOURCE, |
||
| 302 | 'destination' => 'content/search?SearchText=eZ', |
||
| 303 | 'path' => '/Home/My-New-Site', |
||
| 304 | 'languageCodes' => ['eng-US'], |
||
| 305 | 'alwaysAvailable' => false, |
||
| 306 | 'isHistory' => false, |
||
| 307 | 'isCustom' => true, |
||
| 308 | 'forward' => false, |
||
| 309 | ], |
||
| 310 | $createdUrlAlias |
||
| 311 | ); |
||
| 312 | } |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Test for the createGlobalUrlAlias() method. |
||
| 316 | * |
||
| 317 | * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forward) |
||
| 318 | */ |
||
| 319 | View Code Duplication | public function testCreateGlobalUrlAliasWithForward() |
|
| 320 | { |
||
| 321 | $repository = $this->getRepository(); |
||
| 322 | |||
| 323 | /* BEGIN: Use Case */ |
||
| 324 | $urlAliasService = $repository->getURLAliasService(); |
||
| 325 | |||
| 326 | $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( |
||
| 327 | 'module:content/search?SearchText=eZ', |
||
| 328 | '/Home/My-New-Site', |
||
| 329 | 'eng-US', |
||
| 330 | true |
||
| 331 | ); |
||
| 332 | /* END: Use Case */ |
||
| 333 | |||
| 334 | $this->assertInstanceOf( |
||
| 335 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
||
| 336 | $createdUrlAlias |
||
| 337 | ); |
||
| 338 | |||
| 339 | return $createdUrlAlias; |
||
| 340 | } |
||
| 341 | |||
| 342 | /** |
||
| 343 | * @param \eZ\Publish\API\Repository\Values\Content\URLAlias |
||
| 344 | * |
||
| 345 | * @depends testCreateGlobalUrlAliasWithForward |
||
| 346 | */ |
||
| 347 | View Code Duplication | public function testCreateGlobalUrlAliasWithForwardPropertyValues(URLAlias $createdUrlAlias) |
|
| 348 | { |
||
| 349 | $this->assertNotNull($createdUrlAlias->id); |
||
| 350 | |||
| 351 | $this->assertPropertiesCorrect( |
||
| 352 | [ |
||
| 353 | 'type' => URLAlias::RESOURCE, |
||
| 354 | 'destination' => 'content/search?SearchText=eZ', |
||
| 355 | 'path' => '/Home/My-New-Site', |
||
| 356 | 'languageCodes' => ['eng-US'], |
||
| 357 | 'alwaysAvailable' => false, |
||
| 358 | 'isHistory' => false, |
||
| 359 | 'isCustom' => true, |
||
| 360 | 'forward' => true, |
||
| 361 | ], |
||
| 362 | $createdUrlAlias |
||
| 363 | ); |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * Test for the createGlobalUrlAlias() method. |
||
| 368 | * |
||
| 369 | * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable) |
||
| 370 | */ |
||
| 371 | View Code Duplication | public function testCreateGlobalUrlAliasWithAlwaysAvailable() |
|
| 372 | { |
||
| 373 | $repository = $this->getRepository(); |
||
| 374 | |||
| 375 | /* BEGIN: Use Case */ |
||
| 376 | $urlAliasService = $repository->getURLAliasService(); |
||
| 377 | |||
| 378 | $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( |
||
| 379 | 'module:content/search?SearchText=eZ', |
||
| 380 | '/Home/My-New-Site', |
||
| 381 | 'eng-US', |
||
| 382 | false, |
||
| 383 | true |
||
| 384 | ); |
||
| 385 | /* END: Use Case */ |
||
| 386 | |||
| 387 | $this->assertInstanceOf( |
||
| 388 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
||
| 389 | $createdUrlAlias |
||
| 390 | ); |
||
| 391 | |||
| 392 | return $createdUrlAlias; |
||
| 393 | } |
||
| 394 | |||
| 395 | /** |
||
| 396 | * @param \eZ\Publish\API\Repository\Values\Content\URLAlias |
||
| 397 | * |
||
| 398 | * @depends testCreateGlobalUrlAliasWithAlwaysAvailable |
||
| 399 | */ |
||
| 400 | View Code Duplication | public function testCreateGlobalUrlAliasWithAlwaysAvailablePropertyValues(URLAlias $createdUrlAlias) |
|
| 401 | { |
||
| 402 | $this->assertNotNull($createdUrlAlias->id); |
||
| 403 | |||
| 404 | $this->assertPropertiesCorrect( |
||
| 405 | [ |
||
| 406 | 'type' => URLAlias::RESOURCE, |
||
| 407 | 'destination' => 'content/search?SearchText=eZ', |
||
| 408 | 'path' => '/Home/My-New-Site', |
||
| 409 | 'languageCodes' => ['eng-US'], |
||
| 410 | 'alwaysAvailable' => true, |
||
| 411 | 'isHistory' => false, |
||
| 412 | 'isCustom' => true, |
||
| 413 | 'forward' => false, |
||
| 414 | ], |
||
| 415 | $createdUrlAlias |
||
| 416 | ); |
||
| 417 | } |
||
| 418 | |||
| 419 | /** |
||
| 420 | * Test for the createUrlAlias() method. |
||
| 421 | * |
||
| 422 | * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable) |
||
| 423 | */ |
||
| 424 | View Code Duplication | public function testCreateGlobalUrlAliasForLocation() |
|
| 425 | { |
||
| 426 | $repository = $this->getRepository(); |
||
| 427 | |||
| 428 | $locationId = $this->generateId('location', 5); |
||
| 429 | $locationService = $repository->getLocationService(); |
||
| 430 | $location = $locationService->loadLocation($locationId); |
||
| 431 | |||
| 432 | /* BEGIN: Use Case */ |
||
| 433 | // $locationId is the ID of an existing location |
||
| 434 | |||
| 435 | $urlAliasService = $repository->getURLAliasService(); |
||
| 436 | |||
| 437 | $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( |
||
| 438 | 'module:content/view/full/' . $locationId, |
||
| 439 | '/Home/My-New-Site-global', |
||
| 440 | 'eng-US', |
||
| 441 | false, |
||
| 442 | true |
||
| 443 | ); |
||
| 444 | /* END: Use Case */ |
||
| 445 | |||
| 446 | $this->assertInstanceOf( |
||
| 447 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
||
| 448 | $createdUrlAlias |
||
| 449 | ); |
||
| 450 | |||
| 451 | return [$createdUrlAlias, $location->id]; |
||
| 452 | } |
||
| 453 | |||
| 454 | /** |
||
| 455 | * Test for the createUrlAlias() method. |
||
| 456 | * |
||
| 457 | * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable) |
||
| 458 | */ |
||
| 459 | View Code Duplication | public function testCreateGlobalUrlAliasForLocationVariation() |
|
| 460 | { |
||
| 461 | $repository = $this->getRepository(); |
||
| 462 | |||
| 463 | $locationId = $this->generateId('location', 5); |
||
| 464 | $locationService = $repository->getLocationService(); |
||
| 465 | $location = $locationService->loadLocation($locationId); |
||
| 466 | |||
| 467 | /* BEGIN: Use Case */ |
||
| 468 | // $locationId is the ID of an existing location |
||
| 469 | |||
| 470 | $urlAliasService = $repository->getURLAliasService(); |
||
| 471 | |||
| 472 | $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( |
||
| 473 | 'eznode:' . $locationId, |
||
| 474 | '/Home/My-New-Site-global', |
||
| 475 | 'eng-US', |
||
| 476 | false, |
||
| 477 | true |
||
| 478 | ); |
||
| 479 | /* END: Use Case */ |
||
| 480 | |||
| 481 | $this->assertInstanceOf( |
||
| 482 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
||
| 483 | $createdUrlAlias |
||
| 484 | ); |
||
| 485 | |||
| 486 | return [$createdUrlAlias, $location->id]; |
||
| 487 | } |
||
| 488 | |||
| 489 | /** |
||
| 490 | * @param \eZ\Publish\API\Repository\Values\Content\URLAlias |
||
| 491 | * |
||
| 492 | * @depends testCreateGlobalUrlAliasForLocation |
||
| 493 | */ |
||
| 494 | View Code Duplication | public function testCreateGlobalUrlAliasForLocationPropertyValues($testData) |
|
| 495 | { |
||
| 496 | list($createdUrlAlias, $locationId) = $testData; |
||
| 497 | |||
| 498 | $this->assertNotNull($createdUrlAlias->id); |
||
| 499 | |||
| 500 | $this->assertPropertiesCorrect( |
||
| 501 | [ |
||
| 502 | 'type' => URLAlias::LOCATION, |
||
| 503 | 'destination' => $locationId, |
||
| 504 | 'path' => '/Home/My-New-Site-global', |
||
| 505 | 'languageCodes' => ['eng-US'], |
||
| 506 | 'alwaysAvailable' => true, |
||
| 507 | 'isHistory' => false, |
||
| 508 | 'isCustom' => true, |
||
| 509 | 'forward' => false, |
||
| 510 | ], |
||
| 511 | $createdUrlAlias |
||
| 512 | ); |
||
| 513 | } |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @param \eZ\Publish\API\Repository\Values\Content\URLAlias |
||
| 517 | * |
||
| 518 | * @depends testCreateGlobalUrlAliasForLocationVariation |
||
| 519 | */ |
||
| 520 | public function testCreateGlobalUrlAliasForLocationVariationPropertyValues($testData) |
||
| 521 | { |
||
| 522 | $this->testCreateGlobalUrlAliasForLocationPropertyValues($testData); |
||
| 523 | } |
||
| 524 | |||
| 525 | /** |
||
| 526 | * Test for the createGlobalUrlAlias() method. |
||
| 527 | * |
||
| 528 | * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias() |
||
| 529 | */ |
||
| 530 | public function testCreateGlobalUrlAliasThrowsInvalidArgumentException() |
||
| 531 | { |
||
| 532 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); |
||
| 533 | |||
| 534 | $repository = $this->getRepository(); |
||
| 535 | |||
| 536 | /* BEGIN: Use Case */ |
||
| 537 | $urlAliasService = $repository->getURLAliasService(); |
||
| 538 | |||
| 539 | // Throws InvalidArgumentException, since this path already exists for the |
||
| 540 | // language |
||
| 541 | $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( |
||
| 542 | 'module:content/search?SearchText=eZ', |
||
| 543 | '/Design/Plain-site', |
||
| 544 | 'eng-US' |
||
| 545 | ); |
||
| 546 | /* END: Use Case */ |
||
| 547 | } |
||
| 548 | |||
| 549 | /** |
||
| 550 | * Test for the listLocationAliases() method. |
||
| 551 | * |
||
| 552 | * @see \eZ\Publish\API\Repository\URLAliasService::listLocationAliases() |
||
| 553 | */ |
||
| 554 | public function testListLocationAliases() |
||
| 555 | { |
||
| 556 | $repository = $this->getRepository(); |
||
| 557 | |||
| 558 | $locationId = $this->generateId('location', 12); |
||
| 559 | |||
| 560 | /* BEGIN: Use Case */ |
||
| 561 | // $locationId contains the ID of an existing Location |
||
| 562 | $urlAliasService = $repository->getURLAliasService(); |
||
| 563 | $locationService = $repository->getLocationService(); |
||
| 564 | |||
| 565 | $location = $locationService->loadLocation($locationId); |
||
| 566 | |||
| 567 | // Create a custom URL alias for $location |
||
| 568 | $urlAliasService->createUrlAlias($location, '/My/Great-new-Site', 'eng-US'); |
||
| 569 | |||
| 570 | // $loadedAliases will contain an array of custom URLAlias objects |
||
| 571 | $loadedAliases = $urlAliasService->listLocationAliases($location); |
||
| 572 | /* END: Use Case */ |
||
| 573 | |||
| 574 | $this->assertIsArray($loadedAliases |
||
| 575 | ); |
||
| 576 | |||
| 577 | // Only 1 non-history alias |
||
| 578 | $this->assertCount(1, $loadedAliases); |
||
| 579 | |||
| 580 | return [$loadedAliases, $location]; |
||
| 581 | } |
||
| 582 | |||
| 583 | /** |
||
| 584 | * @param array $testData |
||
| 585 | * |
||
| 586 | * @depends testListLocationAliases |
||
| 587 | */ |
||
| 588 | public function testListLocationAliasesLoadsCorrectly(array $testData) |
||
| 603 | |||
| 604 | /** |
||
| 605 | * Test for the listLocationAliases() method. |
||
| 606 | * |
||
| 607 | * @see \eZ\Publish\API\Repository\URLAliasService::listLocationAliases($location, $custom, $languageCode) |
||
| 608 | */ |
||
| 609 | View Code Duplication | public function testListLocationAliasesWithCustomFilter() |
|
| 610 | { |
||
| 611 | $repository = $this->getRepository(); |
||
| 612 | |||
| 613 | $locationId = $this->generateId('location', 12); |
||
| 614 | |||
| 615 | /* BEGIN: Use Case */ |
||
| 616 | // $locationId contains the ID of an existing Location |
||
| 633 | |||
| 634 | /** |
||
| 635 | * Test for the listLocationAliases() method. |
||
| 636 | * |
||
| 637 | * @see \eZ\Publish\API\Repository\URLAliasService::listLocationAliases($location, $custom) |
||
| 638 | */ |
||
| 639 | View Code Duplication | public function testListLocationAliasesWithLanguageCodeFilter() |
|
| 662 | |||
| 663 | /** |
||
| 664 | * Test for the listGlobalAliases() method. |
||
| 665 | * |
||
| 666 | * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases() |
||
| 667 | */ |
||
| 668 | View Code Duplication | public function testListGlobalAliases() |
|
| 686 | |||
| 687 | /** |
||
| 688 | * Creates 3 global aliases. |
||
| 689 | */ |
||
| 690 | private function createGlobalAliases() |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Test for the listGlobalAliases() method. |
||
| 716 | * |
||
| 717 | * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases($languageCode) |
||
| 718 | */ |
||
| 719 | View Code Duplication | public function testListGlobalAliasesWithLanguageFilter() |
|
| 737 | |||
| 738 | /** |
||
| 739 | * Test for the listGlobalAliases() method. |
||
| 740 | * |
||
| 741 | * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases($languageCode, $offset) |
||
| 742 | */ |
||
| 743 | View Code Duplication | public function testListGlobalAliasesWithOffset() |
|
| 761 | |||
| 762 | /** |
||
| 763 | * Test for the listGlobalAliases() method. |
||
| 764 | * |
||
| 765 | * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases($languageCode, $offset, $limit) |
||
| 766 | */ |
||
| 767 | View Code Duplication | public function testListGlobalAliasesWithLimit() |
|
| 785 | |||
| 786 | /** |
||
| 787 | * Test for the removeAliases() method. |
||
| 788 | * |
||
| 789 | * @see \eZ\Publish\API\Repository\URLAliasService::removeAliases() |
||
| 790 | */ |
||
| 791 | public function testRemoveAliases() |
||
| 826 | |||
| 827 | /** |
||
| 828 | * Test for the removeAliases() method. |
||
| 829 | * |
||
| 830 | * @see \eZ\Publish\API\Repository\URLAliasService::removeAliases() |
||
| 831 | */ |
||
| 832 | public function testRemoveAliasesThrowsInvalidArgumentExceptionIfAutogeneratedAliasesAreToBeRemoved() |
||
| 855 | |||
| 856 | /** |
||
| 857 | * Test for the lookUp() method. |
||
| 858 | * |
||
| 859 | * @see \eZ\Publish\API\Repository\URLAliasService::lookUp() |
||
| 860 | */ |
||
| 861 | public function testLookUp() |
||
| 878 | |||
| 879 | /** |
||
| 880 | * Test for the lookUp() method. |
||
| 881 | * |
||
| 882 | * @see \eZ\Publish\API\Repository\URLAliasService::lookUp($url, $languageCode) |
||
| 883 | */ |
||
| 884 | public function testLookUpWithLanguageFilter() |
||
| 906 | |||
| 907 | /** |
||
| 908 | * Test for the lookUp() method. |
||
| 909 | * |
||
| 910 | * @see \eZ\Publish\API\Repository\URLAliasService::lookUp() |
||
| 911 | */ |
||
| 912 | public function testLookUpThrowsNotFoundException() |
||
| 925 | |||
| 926 | /** |
||
| 927 | * Test for the lookUp() method. |
||
| 928 | * |
||
| 929 | * @see \eZ\Publish\API\Repository\URLAliasService::lookUp($url, $languageCode) |
||
| 930 | */ |
||
| 931 | public function testLookUpThrowsNotFoundExceptionWithLanguageFilter() |
||
| 944 | |||
| 945 | /** |
||
| 946 | * Test for the lookUp() method. |
||
| 947 | * |
||
| 948 | * @see \eZ\Publish\API\Repository\URLAliasService::lookUp($url, $languageCode) |
||
| 949 | */ |
||
| 950 | public function testLookUpThrowsInvalidArgumentException() |
||
| 963 | |||
| 964 | /** |
||
| 965 | * Test for the lookUp() method after renaming parent which is a part of the lookup path. |
||
| 966 | * |
||
| 967 | * @see https://jira.ez.no/browse/EZP-28046 |
||
| 968 | * @covers \eZ\Publish\API\Repository\URLAliasService::lookUp |
||
| 969 | * @covers \eZ\Publish\API\Repository\URLAliasService::listLocationAliases |
||
| 970 | */ |
||
| 971 | public function testLookupOnRenamedParent() |
||
| 1023 | |||
| 1024 | /** |
||
| 1025 | * Test lookup on multilingual nested Locations returns proper UrlAlias Value. |
||
| 1026 | * |
||
| 1027 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1028 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1029 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1030 | */ |
||
| 1031 | public function testLookupOnMultilingualNestedLocations() |
||
| 1082 | |||
| 1083 | /** |
||
| 1084 | * Test refreshSystemUrlAliasesForLocation historizes and changes current URL alias after |
||
| 1085 | * changing SlugConverter configuration. |
||
| 1086 | * |
||
| 1087 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1088 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1089 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1090 | * @throws \ErrorException |
||
| 1091 | */ |
||
| 1092 | public function testRefreshSystemUrlAliasesForLocationWithChangedSlugConverterConfiguration() |
||
| 1146 | |||
| 1147 | /** |
||
| 1148 | * Test that URL aliases are refreshed after changing URL alias schema Field name of a Content Type. |
||
| 1149 | * |
||
| 1150 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1151 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1152 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1153 | */ |
||
| 1154 | public function testRefreshSystemUrlAliasesForContentsWithUpdatedContentTypes() |
||
| 1200 | |||
| 1201 | /** |
||
| 1202 | * Test that created non-latin aliases are non-empty and unique. |
||
| 1203 | * |
||
| 1204 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1205 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1206 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1207 | */ |
||
| 1208 | public function testCreateNonLatinNonEmptyUniqueAliases() |
||
| 1250 | |||
| 1251 | /** |
||
| 1252 | * Test restoring missing current URL which has existing history. |
||
| 1253 | * |
||
| 1254 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1255 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1256 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1257 | * @throws \Exception |
||
| 1258 | */ |
||
| 1259 | public function testRefreshSystemUrlAliasesForMissingUrlWithHistory() |
||
| 1347 | |||
| 1348 | /** |
||
| 1349 | * Test edge case when updated and archived entry gets moved to another subtree. |
||
| 1350 | * |
||
| 1351 | * @see https://jira.ez.no/browse/EZP-30004 |
||
| 1352 | * |
||
| 1353 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1354 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1355 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1356 | * @throws \Exception |
||
| 1357 | */ |
||
| 1358 | public function testRefreshSystemUrlAliasesForMovedLocation() |
||
| 1416 | |||
| 1417 | /** |
||
| 1418 | * Lookup given URL and check if it is archived and points to the given Location Id. |
||
| 1419 | * |
||
| 1420 | * @param string $lookupUrl |
||
| 1421 | * @param int $expectedDestination Expected Location ID |
||
| 1422 | */ |
||
| 1423 | protected function assertUrlIsHistory($lookupUrl, $expectedDestination) |
||
| 1427 | |||
| 1428 | /** |
||
| 1429 | * Lookup given URL and check if it is current (not archived) and points to the given Location Id. |
||
| 1430 | * |
||
| 1431 | * @param string $lookupUrl |
||
| 1432 | * @param int $expectedDestination Expected Location ID |
||
| 1433 | */ |
||
| 1434 | protected function assertUrlIsCurrent($lookupUrl, $expectedDestination) |
||
| 1438 | |||
| 1439 | /** |
||
| 1440 | * Lookup and URLAlias VO history and destination properties. |
||
| 1441 | * |
||
| 1442 | * @see assertUrlIsHistory |
||
| 1443 | * @see assertUrlIsCurrent |
||
| 1444 | * |
||
| 1445 | * @param bool $expectedIsHistory |
||
| 1446 | * @param int $expectedDestination Expected Location ID |
||
| 1447 | * @param string $lookupUrl |
||
| 1448 | */ |
||
| 1449 | protected function assertLookupHistory($expectedIsHistory, $expectedDestination, $lookupUrl) |
||
| 1469 | |||
| 1470 | /** |
||
| 1471 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
| 1472 | * @param $fieldDefinitionIdentifier |
||
| 1473 | * @param array $fieldValues |
||
| 1474 | * |
||
| 1475 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
| 1476 | * |
||
| 1477 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1478 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1479 | */ |
||
| 1480 | protected function updateContentField(ContentInfo $contentInfo, $fieldDefinitionIdentifier, array $fieldValues) |
||
| 1495 | |||
| 1496 | /** |
||
| 1497 | * Test deleting corrupted URL aliases. |
||
| 1498 | * |
||
| 1499 | * Note: this test will not be needed once we introduce Improved Storage with Foreign keys support. |
||
| 1500 | * |
||
| 1501 | * Note: test depends on already broken URL aliases: eznode:59, eznode:59, eznode:60. |
||
| 1502 | * |
||
| 1503 | * @throws \ErrorException |
||
| 1504 | */ |
||
| 1505 | public function testDeleteCorruptedUrlAliases() |
||
| 1533 | |||
| 1534 | /** |
||
| 1535 | * Mutate 'ezpublish.persistence.slug_converter' Service configuration. |
||
| 1536 | * |
||
| 1537 | * @param string $key |
||
| 1538 | * @param string $value |
||
| 1539 | * |
||
| 1540 | * @throws \ErrorException |
||
| 1541 | * @throws \Exception |
||
| 1542 | */ |
||
| 1543 | protected function changeSlugConverterConfiguration($key, $value) |
||
| 1564 | |||
| 1565 | /** |
||
| 1566 | * Update Content Type URL alias schema pattern. |
||
| 1567 | * |
||
| 1568 | * @param string $contentTypeIdentifier |
||
| 1569 | * @param string $newUrlAliasSchema |
||
| 1570 | * |
||
| 1571 | * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException |
||
| 1572 | * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
| 1573 | * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
||
| 1574 | */ |
||
| 1575 | protected function changeContentTypeUrlAliasSchema($contentTypeIdentifier, $newUrlAliasSchema) |
||
| 1588 | |||
| 1589 | private function assertUrlAliasPropertiesCorrect( |
||
| 1609 | |||
| 1610 | /** |
||
| 1611 | * Insert intentionally broken rows into ezurlalias_ml table to test cleanup API. |
||
| 1612 | * |
||
| 1613 | * @see \eZ\Publish\API\Repository\URLAliasService::deleteCorruptedUrlAliases |
||
| 1614 | * @see testDeleteCorruptedUrlAliases |
||
| 1615 | * |
||
| 1616 | * @param \Doctrine\DBAL\Connection $connection |
||
| 1617 | * |
||
| 1618 | * @return int Number of new rows |
||
| 1619 | */ |
||
| 1620 | private function insertBrokenUrlAliasTableFixtures(Connection $connection) |
||
| 1679 | } |
||
| 1680 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.