| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File containing the URLAliasServiceTest class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Copyright (C) eZ Systems AS. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license For full copyright and license information view LICENSE file distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace eZ\Publish\API\Repository\Tests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use eZ\Publish\API\Repository\Values\Content\URLAlias; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * Test case for operations in the URLAliasService using in memory storage. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @see eZ\Publish\API\Repository\URLAliasService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @group url-alias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | class URLAliasServiceTest extends BaseTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * Tests that the required <b>LocationService::loadLocation()</b> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * at least returns an object, because this method is utilized in several | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * tests. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             // Load the LocationService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |             $locationService = $this->getRepository()->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             $membersUserGroupLocationId = 12; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             // Load a location instance | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             $location = $locationService->loadLocation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                 $membersUserGroupLocationId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             if (false === is_object($location)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |                 $this->markTestSkipped( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                     'This test cannot be executed, because the utilized ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                     'LocationService::loadLocation() does not ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                     'return an object.' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         } catch (Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             $this->markTestSkipped( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                 'This test cannot be executed, because the utilized ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 'LocationService::loadLocation() failed with ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                 PHP_EOL . PHP_EOL . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                 $e->getTraceAsString() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * Test for the createUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function testCreateUrlAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $locationId = $this->generateId('location', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         // $locationId is the ID of an existing location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         return array($createdUrlAlias, $location->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |      * @param array $testData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      * @depends testCreateUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 94 |  | View Code Duplication |     public function testCreateUrlAliasPropertyValues(array $testData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         list($createdUrlAlias, $locationId) = $testData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                 'type' => URLAlias::LOCATION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                 'destination' => $locationId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 'path' => '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                 'alwaysAvailable' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 'forward' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * Test for the createUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @depends testCreateUrlAliasPropertyValues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 121 |  | View Code Duplication |     public function testCreateUrlAliasWithForwarding() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $locationId = $this->generateId('location', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         // $locationId is the ID of an existing location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         return array($createdUrlAlias, $location->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @param array $testData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      * @depends testCreateUrlAliasWithForwarding | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 151 |  | View Code Duplication |     public function testCreateUrlAliasPropertyValuesWithForwarding(array $testData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         list($createdUrlAlias, $locationId) = $testData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                 'type' => URLAlias::LOCATION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                 'destination' => $locationId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 'path' => '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                 'alwaysAvailable' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                 'forward' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * Test for the createUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias($location, $path, $languageCode, $forwarding, $alwaysAvailable) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 177 |  | View Code Duplication |     public function testCreateUrlAliasWithAlwaysAvailable() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $locationId = $this->generateId('location', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         // $locationId is the ID of an existing location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Home/My-New-Site', 'eng-US', false, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         return array($createdUrlAlias, $location->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      * @param array $testData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      * @depends testCreateUrlAliasWithAlwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 207 |  | View Code Duplication |     public function testCreateUrlAliasPropertyValuesWithAlwaysAvailable(array $testData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         list($createdUrlAlias, $locationId) = $testData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 'type' => URLAlias::LOCATION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                 'destination' => $locationId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                 'path' => '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                 'alwaysAvailable' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                 'forward' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * Test for the createUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createUrlAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |      * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     public function testCreateUrlAliasThrowsInvalidArgumentException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $locationId = $this->generateId('location', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         // $locationId is the ID of an existing location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         // Throws InvalidArgumentException, since this path already exists for the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         // language | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         $createdUrlAlias = $urlAliasService->createUrlAlias($location, '/Design/Plain-site', 'eng-US'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |      * Test for the createGlobalUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 259 |  | View Code Duplication |     public function testCreateGlobalUrlAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |         $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             'module:content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         return $createdUrlAlias; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |      * @param \eZ\Publish\API\Repository\Values\Content\URLAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |      * @depends testCreateGlobalUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 286 |  | View Code Duplication |     public function testCreateGlobalUrlAliasPropertyValues(URLAlias $createdUrlAlias) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                 'type' => URLAlias::RESOURCE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                 'destination' => 'content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |                 'path' => '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |                 'alwaysAvailable' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |                 'forward' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * Test for the createGlobalUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forward) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 310 |  | View Code Duplication |     public function testCreateGlobalUrlAliasWithForward() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |             'module:content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |             '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |             'eng-US', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         return $createdUrlAlias; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * @param \eZ\Publish\API\Repository\Values\Content\URLAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |      * @depends testCreateGlobalUrlAliasWithForward | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 338 |  | View Code Duplication |     public function testCreateGlobalUrlAliasWithForwardPropertyValues(URLAlias $createdUrlAlias) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |                 'type' => URLAlias::RESOURCE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |                 'destination' => 'content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |                 'path' => '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |                 'alwaysAvailable' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |                 'forward' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |      * Test for the createGlobalUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 362 |  | View Code Duplication |     public function testCreateGlobalUrlAliasWithAlwaysAvailable() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |             'module:content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |             '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             'eng-US', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |             true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |         return $createdUrlAlias; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |      * @param \eZ\Publish\API\Repository\Values\Content\URLAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |      * @depends testCreateGlobalUrlAliasWithAlwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 391 |  | View Code Duplication |     public function testCreateGlobalUrlAliasWithAlwaysAvailablePropertyValues(URLAlias $createdUrlAlias) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |                 'type' => URLAlias::RESOURCE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |                 'destination' => 'content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |                 'path' => '/Home/My-New-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |                 'alwaysAvailable' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |                 'forward' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |      * Test for the createUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 415 |  | View Code Duplication |     public function testCreateGlobalUrlAliasForLocation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |         $locationId = $this->generateId('location', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |         // $locationId is the ID of an existing location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |             'module:content/view/full/' . $locationId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |             '/Home/My-New-Site-global', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |             'eng-US', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |             true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |         return array($createdUrlAlias, $location->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |      * Test for the createUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias($resource, $path, $languageCode, $forwarding, $alwaysAvailable) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 450 |  | View Code Duplication |     public function testCreateGlobalUrlAliasForLocationVariation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |         $locationId = $this->generateId('location', 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |         // $locationId is the ID of an existing location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |         $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |             'eznode:' . $locationId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             '/Home/My-New-Site-global', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             'eng-US', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |         return array($createdUrlAlias, $location->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |      * @param \eZ\Publish\API\Repository\Values\Content\URLAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |      * @depends testCreateGlobalUrlAliasForLocation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 485 |  | View Code Duplication |     public function testCreateGlobalUrlAliasForLocationPropertyValues($testData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |         list($createdUrlAlias, $locationId) = $testData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |         $this->assertNotNull($createdUrlAlias->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $this->assertPropertiesCorrect( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |                 'type' => URLAlias::LOCATION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |                 'destination' => $locationId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |                 'path' => '/Home/My-New-Site-global', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |                 'languageCodes' => array('eng-US'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |                 'alwaysAvailable' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |                 'isHistory' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |                 'isCustom' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |                 'forward' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |             $createdUrlAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |      * @param \eZ\Publish\API\Repository\Values\Content\URLAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |      * @depends testCreateGlobalUrlAliasForLocationVariation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |     public function testCreateGlobalUrlAliasForLocationVariationPropertyValues($testData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         $this->testCreateGlobalUrlAliasForLocationPropertyValues($testData); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |      * Test for the createGlobalUrlAlias() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::createGlobalUrlAlias() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |      * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |     public function testCreateGlobalUrlAliasThrowsInvalidArgumentException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |         // Throws InvalidArgumentException, since this path already exists for the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |         // language | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |         $createdUrlAlias = $urlAliasService->createGlobalUrlAlias( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |             'module:content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |             '/Design/Plain-site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |      * Test for the listLocationAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::listLocationAliases() | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 543 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 544 |  |  |     public function testListLocationAliases() | 
            
                                                                        
                            
            
                                    
            
            
                | 545 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 546 |  |  |         $repository = $this->getRepository(); | 
            
                                                                        
                            
            
                                    
            
            
                | 547 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 548 |  |  |         $locationId = $this->generateId('location', 12); | 
            
                                                                        
                            
            
                                    
            
            
                | 549 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 550 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                        
                            
            
                                    
            
            
                | 551 |  |  |         // $locationId contains the ID of an existing Location | 
            
                                                                        
                            
            
                                    
            
            
                | 552 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                        
                            
            
                                    
            
            
                | 553 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                        
                            
            
                                    
            
            
                | 554 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 555 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                        
                            
            
                                    
            
            
                | 556 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 557 |  |  |         // Create a custom URL alias for $location | 
            
                                                                        
                            
            
                                    
            
            
                | 558 |  |  |         $urlAliasService->createUrlAlias($location, '/My/Great-new-Site', 'eng-US'); | 
            
                                                                        
                            
            
                                    
            
            
                | 559 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 560 |  |  |         // $loadedAliases will contain an array of custom URLAlias objects | 
            
                                                                        
                            
            
                                    
            
            
                | 561 |  |  |         $loadedAliases = $urlAliasService->listLocationAliases($location); | 
            
                                                                        
                            
            
                                    
            
            
                | 562 |  |  |         /* END: Use Case */ | 
            
                                                                        
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 564 |  |  |         $this->assertInternalType( | 
            
                                                                        
                            
            
                                    
            
            
                | 565 |  |  |             'array', | 
            
                                                                        
                            
            
                                    
            
            
                | 566 |  |  |             $loadedAliases | 
            
                                                                        
                            
            
                                    
            
            
                | 567 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 568 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 569 |  |  |         // Only 1 non-history alias | 
            
                                                                        
                            
            
                                    
            
            
                | 570 |  |  |         $this->assertEquals(1, count($loadedAliases)); | 
            
                                                                        
                            
            
                                    
            
            
                | 571 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 572 |  |  |         return array($loadedAliases, $location); | 
            
                                                                        
                            
            
                                    
            
            
                | 573 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |      * @param array $testData | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |      * @depends testListLocationAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |     public function testListLocationAliasesLoadsCorrectly(array $testData) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |         list($loadedAliases, $location) = $testData; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |         foreach ($loadedAliases as $loadedAlias) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |             $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |                 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |                 $loadedAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |             $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |                 $location->id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |                 $loadedAlias->destination | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |      * Test for the listLocationAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::listLocationAliases($location, $custom, $languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 601 |  | View Code Duplication |     public function testListLocationAliasesWithCustomFilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |         $locationId = $this->generateId('location', 12); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |         // $locationId contains the ID of an existing Location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |         // Create a second URL alias for $location, this is a "custom" one | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |         $urlAliasService->createUrlAlias($location, '/My/Great-new-Site', 'ger-DE'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |         // $loadedAliases will contain 1 aliases in eng-US only | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |         $loadedAliases = $urlAliasService->listLocationAliases($location, false, 'eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |         $this->assertInternalType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |             'array', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |             $loadedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |         $this->assertEquals(1, count($loadedAliases)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |      * Test for the listLocationAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::listLocationAliases($location, $custom) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 633 |  | View Code Duplication |     public function testListLocationAliasesWithLanguageCodeFilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |         $locationId = $this->generateId('location', 12); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         // $locationId contains the ID of an existing Location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |         $location = $locationService->loadLocation($locationId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |         // Create a custom URL alias for $location | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |         $urlAliasService->createUrlAlias($location, '/My/Great-new-Site', 'eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |         // $loadedAliases will contain only 1 of 3 aliases (custom in eng-US) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |         $loadedAliases = $urlAliasService->listLocationAliases($location, true, 'eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |         $this->assertInternalType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |             'array', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |             $loadedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |         $this->assertEquals(1, count($loadedAliases)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |      * Test for the listGlobalAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 664 |  | View Code Duplication |     public function testListGlobalAliases() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |         // Create some global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |         $this->createGlobalAliases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |         // $loadedAliases will contain all 3 global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |         $loadedAliases = $urlAliasService->listGlobalAliases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         $this->assertInternalType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |             'array', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |             $loadedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |         $this->assertEquals(3, count($loadedAliases)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |      * Creates 3 global aliases. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |     private function createGlobalAliases() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |         /* BEGIN: Inline */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |         $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |             'module:content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |             '/My/Special-Support', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |             'module:content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |             '/My/London-Office', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |             'eng-GB' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |         $urlAliasService->createGlobalUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |             'module:content/search?SearchText=Sindelfingen', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |             '/My/Fancy-Site', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |         /* END: Inline */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |      * Test for the listGlobalAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases($languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 717 |  | View Code Duplication |     public function testListGlobalAliasesWithLanguageFilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |         // Create some global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |         $this->createGlobalAliases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |         // $loadedAliases will contain only 2 of 3 global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |         $loadedAliases = $urlAliasService->listGlobalAliases('eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |         $this->assertInternalType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |             'array', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |             $loadedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |         $this->assertEquals(2, count($loadedAliases)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |         // Create some global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  |         $this->createGlobalAliases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  |         // $loadedAliases will contain only 2 of 3 global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  |         $loadedAliases = $urlAliasService->listGlobalAliases(null, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  |         $this->assertInternalType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  |             'array', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  |             $loadedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |         $this->assertEquals(2, count($loadedAliases)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |      * Test for the listGlobalAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::listGlobalAliases($languageCode, $offset, $limit) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 769 |  | View Code Duplication |     public function testListGlobalAliasesWithLimit() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |         // Create some global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |         $this->createGlobalAliases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |         // $loadedAliases will contain only 1 of 3 global aliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |         $loadedAliases = $urlAliasService->listGlobalAliases(null, 0, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |         $this->assertInternalType( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |             'array', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |             $loadedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |         $this->assertEquals(1, count($loadedAliases)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |      * Test for the removeAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::removeAliases() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |     public function testRemoveAliases() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |         $someLocation = $locationService->loadLocation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |             $this->generateId('location', 12) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |         // $someLocation contains a location with automatically generated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |         // aliases assigned | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |         $initialAliases = $urlAliasService->listLocationAliases($someLocation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |         // Creates a custom alias for $someLocation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |         $urlAliasService->createUrlAlias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |             $someLocation, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |             '/my/fancy/url/alias/sindelfingen', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |         $customAliases = $urlAliasService->listLocationAliases($someLocation); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |         // The custom alias just created will be removed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |         // the automatic aliases stay in tact | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |         $urlAliasService->removeAliases($customAliases); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |             $initialAliases, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |             $urlAliasService->listLocationAliases($someLocation) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |      * Test for the removeAliases() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::removeAliases() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |      * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |     public function testRemoveAliasesThrowsInvalidArgumentExceptionIfAutogeneratedAliasesAreToBeRemoved() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |         $locationService = $repository->getLocationService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |         $someLocation = $locationService->loadLocation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |             $this->generateId('location', 12) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |         // $someLocation contains a location with automatically generated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  |         // aliases assigned | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |         $autogeneratedAliases = $urlAliasService->listLocationAliases($someLocation, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |         // Throws an InvalidArgumentException, since autogeneratedAliases | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |         // cannot be removed with this method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |         $urlAliasService->removeAliases($autogeneratedAliases); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |      * Test for the lookUp() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::lookUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |     public function testLookUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  |         $loadedAlias = $urlAliasService->lookUp('/Setup2'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |             $loadedAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |         return $loadedAlias; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |      * Test for the lookUp() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::lookUp($url, $languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |     public function testLookUpWithLanguageFilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |         // Create aliases in multiple languages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |         $this->createGlobalAliases(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |         $loadedAlias = $urlAliasService->lookUp('/My/Special-Support', 'eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |         $this->assertInstanceOf( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |             'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |             $loadedAlias | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |             'content/search?SearchText=eZ', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |             $loadedAlias->destination | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |      * Test for the lookUp() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::lookUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |      * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |     public function testLookUpThrowsNotFoundException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |         // Throws NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |         $loadedAlias = $urlAliasService->lookUp('/non-existent-url'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |      * Test for the lookUp() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::lookUp($url, $languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |      * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |     public function testLookUpThrowsNotFoundExceptionWithLanguageFilter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |         // Throws NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |         $loadedAlias = $urlAliasService->lookUp('/Contact-Us', 'ger-DE'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |      * Test for the lookUp() method. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |      * @see \eZ\Publish\API\Repository\URLAliasService::lookUp($url, $languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |      * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |     public function testLookUpThrowsInvalidArgumentException() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |         /* BEGIN: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  |         $urlAliasService = $repository->getURLAliasService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |         // Throws InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |         $loadedAlias = $urlAliasService->lookUp(str_repeat('/1', 99), 'ger-DE'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |         /* END: Use Case */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 963 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 964 |  |  |  | 
            
                        
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.