| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File containing the BaseTest 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 EzSystems\EzPlatformSolrSearchEngine\Tests\SetupFactory\LegacySetupFactory as LegacySolrSetupFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use PHPUnit_Framework_TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use eZ\Publish\API\Repository\Repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use eZ\Publish\API\Repository\Values\ValueObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use eZ\Publish\API\Repository\Values\User\Limitation\SubtreeLimitation; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use eZ\Publish\Core\REST\Client\Sessionable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use DateTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use ArrayObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use PDOException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * Base class for api specific tests. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | abstract class BaseTest extends PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * Maximum integer number accepted by the different backends. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     const DB_INT_MAX = 2147483647; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @var \eZ\Publish\API\Repository\Tests\SetupFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     private $setupFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @var \eZ\Publish\API\Repository\Repository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     private $repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             // Use setup factory instance here w/o clearing data in case test don't need to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             $repository = $this->getSetupFactory()->getRepository(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             // Set session if we are testing the REST backend to make it | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             // possible to persist data in the memory backend during multiple | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             // requests. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             if ($repository instanceof Sessionable) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |                 $repository->setSession($id = md5(microtime())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         } catch (PDOException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             $this->fail( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                 'The communication with the database cannot be established. ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 "This is required in order to perform the tests.\n\n" . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 'Exception: ' . $e | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         } catch (Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             $this->fail( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                 'Cannot create a repository with predefined user. ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                 'Check the UserService or RoleService implementation. ' . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                 PHP_EOL . PHP_EOL . | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                 'Exception: ' . $e | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      * Resets the temporary used repository between each test run. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     protected function tearDown() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $this->repository = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         parent::tearDown(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * Returns the ID generator, fitting to the repository implementation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @return \eZ\Publish\API\Repository\Tests\IdManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     protected function getIdManager() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         return $this->getSetupFactory()->getIdManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * Generates a repository specific ID value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @param string $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      * @param mixed $rawId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     protected function generateId($type, $rawId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         return $this->getIdManager()->generateId($type, $rawId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      * Parses a repository specific ID value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      * @param string $type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |      * @param mixed $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     protected function parseId($type, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         return $this->getIdManager()->parseId($type, $id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * Returns a config setting provided by the setup factory. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * @param string $configKey | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     protected function getConfigValue($configKey) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         return $this->getSetupFactory()->getConfigValue($configKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |      * Tests if the currently tested api is based on a V4 implementation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * @return bool | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 134 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |     protected function isVersion4() | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 137 |  |  |         return isset($_ENV['backendVersion']) && '4' === $_ENV['backendVersion']; | 
            
                                                                        
                            
            
                                    
            
            
                | 138 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |      * @param bool $initialInitializeFromScratch Only has an effect if set in first call within a test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      * @return \eZ\Publish\API\Repository\Repository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     protected function getRepository($initialInitializeFromScratch = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         if (null === $this->repository) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             $this->repository = $this->getSetupFactory()->getRepository($initialInitializeFromScratch); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         return $this->repository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      * @return \eZ\Publish\API\Repository\Tests\SetupFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |     protected function getSetupFactory() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         if (null === $this->setupFactory) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             if (false === isset($_ENV['setupFactory'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                 throw new \ErrorException('Missing mandatory setting $_ENV["setupFactory"].'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             $setupClass = $_ENV['setupFactory']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             if (false === class_exists($setupClass)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |                 throw new \ErrorException('$_ENV["setupFactory"] does not reference an existing class.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             $this->setupFactory = new $setupClass(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         return $this->setupFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * Asserts that properties given in $expectedValues are correctly set in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * $actualObject. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      * @param mixed[] $expectedValues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * @param \eZ\Publish\API\Repository\Values\ValueObject $actualObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     protected function assertPropertiesCorrect(array $expectedValues, ValueObject $actualObject) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         foreach ($expectedValues as $propertyName => $propertyValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             $this->assertPropertiesEqual($propertyName, $propertyValue, $actualObject->$propertyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * Asserts that properties given in $expectedValues are correctly set in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * $actualObject. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * If the property type is array, it will be sorted before comparison. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      * @TODO: introduced because of randomly failing tests, ref: https://jira.ez.no/browse/EZP-21734 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |      * @param mixed[] $expectedValues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * @param \eZ\Publish\API\Repository\Values\ValueObject $actualObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     protected function assertPropertiesCorrectUnsorted(array $expectedValues, ValueObject $actualObject) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         foreach ($expectedValues as $propertyName => $propertyValue) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             $this->assertPropertiesEqual($propertyName, $propertyValue, $actualObject->$propertyName, true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * Asserts all properties from $expectedValues are correctly set in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * $actualObject. Additional (virtual) properties can be asserted using | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      * $additionalProperties. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * @param \eZ\Publish\API\Repository\Values\ValueObject $expectedValues | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * @param \eZ\Publish\API\Repository\Values\ValueObject $actualObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @param array $propertyNames | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     protected function assertStructPropertiesCorrect(ValueObject $expectedValues, ValueObject $actualObject, array $additionalProperties = array()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         foreach ($expectedValues as $propertyName => $propertyValue) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |             $this->assertPropertiesEqual($propertyName, $propertyValue, $actualObject->$propertyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         foreach ($additionalProperties as $propertyName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             $this->assertPropertiesEqual($propertyName, $expectedValues->$propertyName, $actualObject->$propertyName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |      * @see \eZ\Publish\API\Repository\Tests\BaseTest::assertPropertiesCorrectUnsorted() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |      * @param array $items An array of scalar values | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     private function sortItems(array &$items) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $sorter = function ($a, $b) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             if (!is_scalar($a) || !is_scalar($b)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |                 $this->fail('Wrong usage: method ' . __METHOD__ . ' accepts only an array of scalar values'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             return strcmp($a, $b); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         usort($items, $sorter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     private function assertPropertiesEqual($propertyName, $expectedValue, $actualValue, $sortArray = false) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         if ($expectedValue instanceof ArrayObject) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             $expectedValue = $expectedValue->getArrayCopy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         } elseif ($expectedValue instanceof DateTime) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             $expectedValue = $expectedValue->format(DateTime::RFC850); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         if ($actualValue instanceof ArrayObject) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             $actualValue = $actualValue->getArrayCopy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |         } elseif ($actualValue instanceof DateTime) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             $actualValue = $actualValue->format(DateTime::RFC850); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         if ($sortArray && is_array($actualValue) && is_array($expectedValue)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |             $this->sortItems($actualValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |             $this->sortItems($expectedValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             $expectedValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |             $actualValue, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |             sprintf('Object property "%s" incorrect.', $propertyName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |      * Create a user in editor user group. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |      * @return \eZ\Publish\API\Repository\Values\User\User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |     protected function createUserVersion1() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |         /* BEGIN: Inline */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         // ID of the "Editors" user group in an eZ Publish demo installation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         $editorsGroupId = 13; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         $userService = $repository->getUserService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         // Instantiate a create struct with mandatory properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |         $userCreate = $userService->newUserCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             'user', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             '[email protected]', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |             'secret', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $userCreate->enabled = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         // Set some fields required by the user ContentType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |         $userCreate->setField('first_name', 'Example'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         $userCreate->setField('last_name', 'User'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         // Load parent group for the user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |         $group = $userService->loadUserGroup($editorsGroupId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |         // Create a new user instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |         $user = $userService->createUser($userCreate, array($group)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         /* END: Inline */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |         return $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * Create a user in new user group with editor rights limited to Media Library (/1/48/). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      * @uses ::createCustomUserVersion1() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |      * @return \eZ\Publish\API\Repository\Values\User\User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |     protected function createMediaUserVersion1() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |         return $this->createCustomUserVersion1( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |             'Media Editor', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |             'Editor', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |             new SubtreeLimitation(array('limitationValues' => array('/1/43/'))) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |      * Create a user with new user group and assign a existing role (optionally with RoleLimitation). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |      * @param string $userGroupName Name of the new user group to create | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |      * @param string $roleIdentifier Role identifier to assign to the new group | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |      * @param RoleLimitation|null $roleLimitation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |      * @return \eZ\Publish\API\Repository\Values\User\User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |     protected function createCustomUserVersion1($userGroupName, $roleIdentifier, RoleLimitation $roleLimitation = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         return $this->createCustomUserWithLogin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |             'user', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |             '[email protected]', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |             $userGroupName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |             $roleIdentifier, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |             $roleLimitation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |      * Create a user with new user group and assign a existing role (optionally with RoleLimitation). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |      * @param string $login User login | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |      * @param string $email User e-mail | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |      * @param string $userGroupName Name of the new user group to create | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |      * @param string $roleIdentifier Role identifier to assign to the new group | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |      * @param RoleLimitation|null $roleLimitation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |      * @return \eZ\Publish\API\Repository\Values\User\User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |     protected function createCustomUserWithLogin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         $login, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |         $email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         $userGroupName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         $roleIdentifier, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |         RoleLimitation $roleLimitation = null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         /* BEGIN: Inline */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |         // ID of the "Users" user group in an eZ Publish demo installation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |         $rootUsersGroupId = $this->generateId('location', 4); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         $roleService = $repository->getRoleService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         $userService = $repository->getUserService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         // Get a group create struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         $userGroupCreate = $userService->newUserGroupCreateStruct('eng-US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         $userGroupCreate->setField('name', $userGroupName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |         // Create new group with media editor rights | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         $userGroup = $userService->createUserGroup( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |             $userGroupCreate, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |             $userService->loadUserGroup($rootUsersGroupId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |         $roleService->assignRoleToUserGroup( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             $roleService->loadRoleByIdentifier($roleIdentifier), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |             $userGroup, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |             $roleLimitation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |         // Instantiate a create struct with mandatory properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         $userCreate = $userService->newUserCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             $login, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |             $email, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |             'secret', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |         $userCreate->enabled = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |         // Set some fields required by the user ContentType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         $userCreate->setField('first_name', 'Example'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |         $userCreate->setField('last_name', ucfirst($login)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         // Create a new user instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |         $user = $userService->createUser($userCreate, array($userGroup)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         /* END: Inline */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |         return $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |      * Create a user using given data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |      * @param string $login | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |      * @param string $firstName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |      * @param string $lastName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |      * @return \eZ\Publish\API\Repository\Values\User\User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |     protected function createUser($login, $firstName, $lastName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         $repository = $this->getRepository(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         $userService = $repository->getUserService(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |         $userGroup = $userService->loadUserGroup(13); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |         // Instantiate a create struct with mandatory properties | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         $userCreate = $userService->newUserCreateStruct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |             $login, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |             "{$login}@example.com", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |             'secret', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |             'eng-US' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $userCreate->enabled = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         // Set some fields required by the user ContentType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         $userCreate->setField('first_name', $firstName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |         $userCreate->setField('last_name', $lastName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |         // Create a new user instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |         $user = $userService->createUser($userCreate, array($userGroup)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         return $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |      * Only for internal use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |      * Creates a \DateTime object for $timestamp in the current time zone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |      * @param int $timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |      * @return \DateTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 447 |  | View Code Duplication |     public function createDateTime($timestamp = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |         $dateTime = new \DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |         if ($timestamp !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |             $dateTime->setTimestamp($timestamp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |         return $dateTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |      * Calls given Repository's aggregated SearchHandler::refresh(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |      * Currently implemented only in Solr search engine. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |      * @param \eZ\Publish\API\Repository\Repository $repository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |     protected function refreshSearch(Repository $repository) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |         $setupFactory = $this->getSetupFactory(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |         if (!$setupFactory instanceof LegacySolrSetupFactory) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |         while (true) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             $repositoryReflection = new \ReflectionObject($repository); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |             // If the repository is decorated, we need to recurse in the "repository" property | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |             if (!$repositoryReflection->hasProperty('repository')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                 break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |             $repositoryProperty = $repositoryReflection->getProperty('repository'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |             $repositoryProperty->setAccessible(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |             $repository = $repositoryProperty->getValue($repository); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |         $searchHandlerProperty = new \ReflectionProperty($repository, 'searchHandler'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |         $searchHandlerProperty->setAccessible(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |         /** @var \EzSystems\EzPlatformSolrSearchEngine\Handler $searchHandler */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         $searchHandler = $searchHandlerProperty->getValue($repository); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         $searchHandler->commit(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 492 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 493 |  |  |  | 
            
                        
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.