| @@ 485-518 (lines=34) @@ | ||
| 482 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 483 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 484 | */ |
|
| 485 | public function testCopySubtreeThrowsUnauthorizedException() |
|
| 486 | { |
|
| 487 | $repository = $this->getRepository(); |
|
| 488 | ||
| 489 | $mediaLocationId = $this->generateId('location', 43); |
|
| 490 | $demoDesignLocationId = $this->generateId('location', 56); |
|
| 491 | /* BEGIN: Use Case */ |
|
| 492 | $user = $this->createMediaUserVersion1(); |
|
| 493 | ||
| 494 | // $mediaLocationId is the ID of the "Media" Location in |
|
| 495 | // an eZ Publish demo installation |
|
| 496 | ||
| 497 | // $demoDesignLocationId is the ID of the "Demo Design" Location in an eZ |
|
| 498 | // Publish demo installation |
|
| 499 | ||
| 500 | // Load the location service |
|
| 501 | $locationService = $repository->getLocationService(); |
|
| 502 | ||
| 503 | // Load location to copy |
|
| 504 | $locationToCopy = $locationService->loadLocation($mediaLocationId); |
|
| 505 | ||
| 506 | // Load new parent location |
|
| 507 | $newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
|
| 508 | ||
| 509 | // Set media editor as current user |
|
| 510 | $repository->setCurrentUser($user); |
|
| 511 | ||
| 512 | // This call will fail with an "UnauthorizedException" |
|
| 513 | $locationService->copySubtree( |
|
| 514 | $locationToCopy, |
|
| 515 | $newParentLocation |
|
| 516 | ); |
|
| 517 | /* END: Use Case */ |
|
| 518 | } |
|
| 519 | ||
| 520 | /** |
|
| 521 | * Test for the moveSubtree() method. |
|
| @@ 527-560 (lines=34) @@ | ||
| 524 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 525 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 526 | */ |
|
| 527 | public function testMoveSubtreeThrowsUnauthorizedException() |
|
| 528 | { |
|
| 529 | $repository = $this->getRepository(); |
|
| 530 | ||
| 531 | $mediaLocationId = $this->generateId('location', 43); |
|
| 532 | $demoDesignLocationId = $this->generateId('location', 56); |
|
| 533 | /* BEGIN: Use Case */ |
|
| 534 | $user = $this->createMediaUserVersion1(); |
|
| 535 | ||
| 536 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 537 | // an eZ Publish demo installation |
|
| 538 | ||
| 539 | // $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
|
| 540 | // Publish demo installation |
|
| 541 | ||
| 542 | // Load the location service |
|
| 543 | $locationService = $repository->getLocationService(); |
|
| 544 | ||
| 545 | // Load location to move |
|
| 546 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 547 | ||
| 548 | // Load new parent location |
|
| 549 | $newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
|
| 550 | ||
| 551 | // Set media editor as current user |
|
| 552 | $repository->setCurrentUser($user); |
|
| 553 | ||
| 554 | // This call will fail with an "UnauthorizedException" |
|
| 555 | $locationService->moveSubtree( |
|
| 556 | $locationToMove, |
|
| 557 | $newParentLocation |
|
| 558 | ); |
|
| 559 | /* END: Use Case */ |
|
| 560 | } |
|
| 561 | } |
|
| 562 | ||
| @@ 1697-1717 (lines=21) @@ | ||
| 1694 | return count($rows); |
|
| 1695 | } |
|
| 1696 | ||
| 1697 | public function testCreateUrlAliasWithRomanianReservedCharacters() |
|
| 1698 | { |
|
| 1699 | $repository = $this->getRepository(); |
|
| 1700 | ||
| 1701 | $locationId = $this->generateId('location', 5); |
|
| 1702 | ||
| 1703 | $basePath = '/Home/ȘșțȚdfdf'; |
|
| 1704 | $expectedPath = '/Home/SstTdfdf'; |
|
| 1705 | ||
| 1706 | $locationService = $repository->getLocationService(); |
|
| 1707 | $urlAliasService = $repository->getURLAliasService(); |
|
| 1708 | ||
| 1709 | $location = $locationService->loadLocation($locationId); |
|
| 1710 | ||
| 1711 | $createdUrlAlias = $urlAliasService->createUrlAlias($location, $basePath, 'eng-US'); |
|
| 1712 | ||
| 1713 | $this->assertEquals( |
|
| 1714 | $expectedPath, |
|
| 1715 | $createdUrlAlias->path |
|
| 1716 | ); |
|
| 1717 | } |
|
| 1718 | } |
|
| 1719 | ||