| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File contains: eZ\Publish\Core\Persistence\Legacy\Tests\Content\Trash\TrashHandlerTest 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\Core\Persistence\Legacy\Tests\Content\Location; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use eZ\Publish\API\Repository\Values\Content\Trash\TrashItemDeleteResultList; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use eZ\Publish\Core\Persistence\Legacy\Tests\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use eZ\Publish\SPI\Persistence\Content\Location\Trash\TrashResult; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use eZ\Publish\SPI\Persistence\Content\Location\Trashed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content as CoreContent; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * Test case for TrashHandlerTest. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | class TrashHandlerTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * Mocked location handler instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Handler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     protected $locationHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * Mocked location gateway instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     protected $locationGateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * Mocked location mapper instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     protected $locationMapper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * Mocked content handler instance. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var \PHPUnit\Framework\MockObject\MockObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected $contentHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 52 |  | View Code Duplication |     protected function getTrashHandler() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $dbHandler = $this->getDatabaseHandler(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         return new Handler( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             $this->locationHandler = $this->createMock(CoreContent\Location\Handler::class), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             $this->locationGateway = $this->createMock(CoreContent\Location\Gateway::class), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             $this->locationMapper = $this->createMock(CoreContent\Location\Mapper::class), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             $this->contentHandler = $this->createMock(CoreContent\Handler::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::trashSubtree | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     public function testTrashSubtree() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             ->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             ->method('getSubtreeContent') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             ->with(20) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                             'contentobject_id' => 10, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                             'node_id' => 20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                             'main_node_id' => 30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                             'parent_node_id' => 40, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                             'contentobject_id' => 11, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                             'node_id' => 21, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                             'main_node_id' => 31, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                             'parent_node_id' => 41, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                     ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             ->expects($this->at(1)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             ->with(10) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             ->will($this->returnValue(1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             ->expects($this->at(2)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ->method('trashLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             ->with(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             ->expects($this->at(3)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             ->with(11) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             ->will($this->returnValue(2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             ->expects($this->at(4)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             ->method('removeLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             ->with(21); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $this->locationHandler | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             ->method('markSubtreeModified') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             ->with(40); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             ->expects($this->at(5)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             ->method('loadTrashByLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             ->with(20) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             ->will($this->returnValue($array = ['data…'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             ->method('createLocationFromRow') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             ->with($array, null, new Trashed()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             ->will($this->returnValue(new Trashed(['id' => 20]))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $trashedObject = $handler->trashSubtree(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |         self::assertInstanceOf(Trashed::class, $trashedObject); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         self::assertSame(20, $trashedObject->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::trashSubtree | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     public function testTrashSubtreeReturnsNull() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             ->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             ->method('getSubtreeContent') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             ->with(20) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |                             'contentobject_id' => 10, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                             'node_id' => 20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                             'main_node_id' => 30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                             'parent_node_id' => 40, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |                             'contentobject_id' => 11, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |                             'node_id' => 21, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |                             'main_node_id' => 31, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |                             'parent_node_id' => 41, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |                     ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             ->expects($this->at(1)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             ->with(10) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             ->will($this->returnValue(2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             ->expects($this->at(2)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             ->method('removeLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             ->with(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |             ->expects($this->at(3)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             ->with(11) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             ->will($this->returnValue(1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             ->expects($this->at(4)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             ->method('trashLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             ->with(21); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         $this->locationHandler | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             ->method('markSubtreeModified') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             ->with(40); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         $returnValue = $handler->trashSubtree(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |         self::assertNull($returnValue); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::trashSubtree | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     public function testTrashSubtreeUpdatesMainLocation() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             ->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             ->method('getSubtreeContent') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             ->with(20) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                             'contentobject_id' => 10, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                             'node_id' => 20, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                             'main_node_id' => 30, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                             'parent_node_id' => 40, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                             'contentobject_id' => 11, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                             'node_id' => 21, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |                             'main_node_id' => 21, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |                             'parent_node_id' => 41, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                         ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                     ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             ->expects($this->at(1)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             ->with(10) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |             ->will($this->returnValue(1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             ->expects($this->at(2)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             ->method('trashLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             ->with(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             ->expects($this->at(3)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             ->with(11) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             ->will($this->returnValue(2)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             ->expects($this->at(4)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |             ->method('removeLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             ->with(21); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |             ->expects($this->at(5)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |             ->method('getFallbackMainNodeData') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             ->with(11, 21) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |                     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |                         'node_id' => 100, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |                         'contentobject_version' => 101, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |                         'parent_node_id' => 102, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |                     ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         $this->locationHandler | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |             ->method('changeMainLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |             ->with(11, 100, 101, 102); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         $this->locationHandler | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |             ->method('markSubtreeModified') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |             ->with(40); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |             ->expects($this->at(6)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |             ->method('loadTrashByLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             ->with(20) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             ->will($this->returnValue($array = ['data…'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |             ->method('createLocationFromRow') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |             ->with($array, null, new Trashed()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             ->will($this->returnValue(new Trashed(['id' => 20]))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |         $trashedObject = $handler->trashSubtree(20); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         self::assertInstanceOf(Trashed::class, $trashedObject); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         self::assertSame(20, $trashedObject->id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::recover | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |     public function testRecover() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |             ->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             ->method('untrashLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             ->with(69, 23) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                     new Trashed(['id' => 70]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         self::assertSame(70, $handler->recover(69, 23)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::loadTrashItem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     public function testLoadTrashItem() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |             ->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |             ->method('loadTrashByLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |             ->with(69) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |             ->will($this->returnValue($array = ['data…'])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             ->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |             ->method('createLocationFromRow') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |             ->with($array, null, new Trashed()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |         $handler->loadTrashItem(69); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::emptyTrash | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 335 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 336 |  |  |     public function testEmptyTrash() | 
            
                                                                        
                            
            
                                    
            
            
                | 337 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 338 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                        
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 340 |  |  |         $expectedTrashed = [ | 
            
                                                                        
                            
            
                                    
            
            
                | 341 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 342 |  |  |                 'node_id' => 69, | 
            
                                                                        
                            
            
                                    
            
            
                | 343 |  |  |                 'path_string' => '/1/2/69/', | 
            
                                                                        
                            
            
                                    
            
            
                | 344 |  |  |                 'contentobject_id' => 67, | 
            
                                                                        
                            
            
                                    
            
            
                | 345 |  |  |             ], | 
            
                                                                        
                            
            
                                    
            
            
                | 346 |  |  |             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 347 |  |  |                 'node_id' => 70, | 
            
                                                                        
                            
            
                                    
            
            
                | 348 |  |  |                 'path_string' => '/1/2/70/', | 
            
                                                                        
                            
            
                                    
            
            
                | 349 |  |  |                 'contentobject_id' => 68, | 
            
                                                                        
                            
            
                                    
            
            
                | 350 |  |  |             ], | 
            
                                                                        
                            
            
                                    
            
            
                | 351 |  |  |         ]; | 
            
                                                                        
                            
            
                                    
            
            
                | 352 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 353 |  |  |         // Index for locationGateway calls | 
            
                                                                        
                            
            
                                    
            
            
                | 354 |  |  |         $i = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 355 |  |  |         // Index for contentHandler calls | 
            
                                                                        
                            
            
                                    
            
            
                | 356 |  |  |         $iContent = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 357 |  |  |         // Index for locationMapper calls | 
            
                                                                        
                            
            
                                    
            
            
                | 358 |  |  |         $iLocation = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 359 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 360 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 361 |  |  |             ->expects($this->at($i++)) | 
            
                                                                        
                            
            
                                    
            
            
                | 362 |  |  |             ->method('countTrashed') | 
            
                                                                        
                            
            
                                    
            
            
                | 363 |  |  |             ->willReturn(2); | 
            
                                                                        
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 365 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 366 |  |  |             ->expects($this->at($i++)) | 
            
                                                                        
                            
            
                                    
            
            
                | 367 |  |  |             ->method('listTrashed') | 
            
                                                                        
                            
            
                                    
            
            
                | 368 |  |  |             ->will( | 
            
                                                                        
                            
            
                                    
            
            
                | 369 |  |  |                 $this->returnValue($expectedTrashed) | 
            
                                                                        
                            
            
                                    
            
            
                | 370 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 371 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 372 |  |  |         $trashedItemIds = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 373 |  |  |         $trashedContentIds = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 374 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 375 |  |  |         foreach ($expectedTrashed as $trashedElement) { | 
            
                                                                        
                            
            
                                    
            
            
                | 376 |  |  |             $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 377 |  |  |                 ->expects($this->at($iLocation++)) | 
            
                                                                        
                            
            
                                    
            
            
                | 378 |  |  |                 ->method('createLocationFromRow') | 
            
                                                                        
                            
            
                                    
            
            
                | 379 |  |  |                 ->will( | 
            
                                                                        
                            
            
                                    
            
            
                | 380 |  |  |                     $this->returnValue( | 
            
                                                                        
                            
            
                                    
            
            
                | 381 |  |  |                         new Trashed( | 
            
                                                                        
                            
            
                                    
            
            
                | 382 |  |  |                             [ | 
            
                                                                        
                            
            
                                    
            
            
                | 383 |  |  |                                 'id' => $trashedElement['node_id'], | 
            
                                                                        
                            
            
                                    
            
            
                | 384 |  |  |                                 'contentId' => $trashedElement['contentobject_id'], | 
            
                                                                        
                            
            
                                    
            
            
                | 385 |  |  |                                 'pathString' => $trashedElement['path_string'], | 
            
                                                                        
                            
            
                                    
            
            
                | 386 |  |  |                             ] | 
            
                                                                        
                            
            
                                    
            
            
                | 387 |  |  |                         ) | 
            
                                                                        
                            
            
                                    
            
            
                | 388 |  |  |                     ) | 
            
                                                                        
                            
            
                                    
            
            
                | 389 |  |  |                 ); | 
            
                                                                        
                            
            
                                    
            
            
                | 390 |  |  |             $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 391 |  |  |                 ->expects($this->at($i++)) | 
            
                                                                        
                            
            
                                    
            
            
                | 392 |  |  |                 ->method('removeElementFromTrash') | 
            
                                                                        
                            
            
                                    
            
            
                | 393 |  |  |                 ->with($trashedElement['node_id']); | 
            
                                                                        
                            
            
                                    
            
            
                | 394 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 395 |  |  |             $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 396 |  |  |                 ->expects($this->at($i++)) | 
            
                                                                        
                            
            
                                    
            
            
                | 397 |  |  |                 ->method('countLocationsByContentId') | 
            
                                                                        
                            
            
                                    
            
            
                | 398 |  |  |                 ->with($trashedElement['contentobject_id']) | 
            
                                                                        
                            
            
                                    
            
            
                | 399 |  |  |                 ->will($this->returnValue(0)); | 
            
                                                                        
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 401 |  |  |             $this->contentHandler | 
            
                                                                        
                            
            
                                    
            
            
                | 402 |  |  |                 ->expects($this->at($iContent++)) | 
            
                                                                        
                            
            
                                    
            
            
                | 403 |  |  |                 ->method('deleteContent') | 
            
                                                                        
                            
            
                                    
            
            
                | 404 |  |  |                 ->with($trashedElement['contentobject_id']); | 
            
                                                                        
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 406 |  |  |             $trashedItemIds[] = $trashedElement['node_id']; | 
            
                                                                        
                            
            
                                    
            
            
                | 407 |  |  |             $trashedContentIds[] = $trashedElement['contentobject_id']; | 
            
                                                                        
                            
            
                                    
            
            
                | 408 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 410 |  |  |         $returnValue = $handler->emptyTrash(); | 
            
                                                                        
                            
            
                                    
            
            
                | 411 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 412 |  |  |         $this->assertInstanceOf(TrashItemDeleteResultList::class, $returnValue); | 
            
                                                                        
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 414 |  |  |         foreach ($returnValue->items as $key => $trashItemDeleteResult) { | 
            
                                                                        
                            
            
                                    
            
            
                | 415 |  |  |             $this->assertEquals($trashItemDeleteResult->trashItemId, $trashedItemIds[$key]); | 
            
                                                                        
                            
            
                                    
            
            
                | 416 |  |  |             $this->assertEquals($trashItemDeleteResult->contentId, $trashedContentIds[$key]); | 
            
                                                                        
                            
            
                                    
            
            
                | 417 |  |  |             $this->assertTrue($trashItemDeleteResult->contentRemoved); | 
            
                                                                        
                            
            
                                    
            
            
                | 418 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 419 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 424 |  | View Code Duplication |     public function testDeleteTrashItemNoMoreLocations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         $trashItemId = 69; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         $contentId = 67; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             ->method('loadTrashByLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |             ->with($trashItemId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                         'node_id' => $trashItemId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                         'contentobject_id' => $contentId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                         'path_string' => '/1/2/69', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                     ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |             ->method('createLocationFromRow') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |                     new Trashed( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |                             'id' => $trashItemId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |                             'contentId' => $contentId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |                             'pathString' => '/1/2/69', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |                         ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |             ->method('removeElementFromTrash') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |             ->with($trashItemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             ->with($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |             ->will($this->returnValue(0)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         $this->contentHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |             ->method('deleteContent') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |             ->with($contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |         $trashItemDeleteResult = $handler->deleteTrashItem($trashItemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |         $this->assertInstanceOf(TrashItemDeleteResult::class, $trashItemDeleteResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |         $this->assertEquals($trashItemId, $trashItemDeleteResult->trashItemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |         $this->assertEquals($contentId, $trashItemDeleteResult->contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |         $this->assertTrue($trashItemDeleteResult->contentRemoved); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 486 |  | View Code Duplication |     public function testDeleteTrashItemStillHaveLocations() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         $trashItemId = 69; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $contentId = 67; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |             ->method('loadTrashByLocation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |             ->with($trashItemId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |                     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |                         'node_id' => $trashItemId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |                         'contentobject_id' => $contentId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |                         'path_string' => '/1/2/69', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |                     ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |             ->method('createLocationFromRow') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |             ->will( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |                 $this->returnValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |                     new Trashed( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |                         [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |                             'id' => $trashItemId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |                             'contentId' => $contentId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |                             'pathString' => '/1/2/69', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |                         ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |             ->method('removeElementFromTrash') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |             ->with($trashItemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |             ->method('countLocationsByContentId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |             ->with($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             ->will($this->returnValue(1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |         $this->contentHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |             ->expects($this->never()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |             ->method('deleteContent'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |         $trashItemDeleteResult = $handler->deleteTrashItem($trashItemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |         $this->assertInstanceOf(TrashItemDeleteResult::class, $trashItemDeleteResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |         $this->assertEquals($trashItemId, $trashItemDeleteResult->trashItemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |         $this->assertEquals($contentId, $trashItemDeleteResult->contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |         $this->assertFalse($trashItemDeleteResult->contentRemoved); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::findTrashItems | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |     public function testFindTrashItemsWhenEmpty() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |             ->method('countTrashed') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |             ->willReturn(0); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |             ->expects($this->never()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |             ->method('listTrashed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |             ->expects($this->never()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |             ->method($this->anything()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |         $trashResult = $handler->findTrashItems(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |         $this->assertInstanceOf(TrashResult::class, $trashResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |         $this->assertEquals(0, $trashResult->totalCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |         $this->assertIsArray($trashResult->items); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |         $this->assertEmpty($trashResult->items); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |         $this->assertIsIterable($trashResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |         $this->assertCount(0, $trashResult);// Can't assert as empty, however we can count it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |      * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::findTrashItems | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |     public function testFindTrashItemsWithLimits() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |         $handler = $this->getTrashHandler(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |             ->method('countTrashed') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |             ->willReturn(2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |         $this->locationGateway | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |             ->method('listTrashed') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |             ->with(1, 1, null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |             ->willReturn([['fake data']]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |         $this->locationMapper | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |             ->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |             ->method('createLocationFromRow') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |             ->with(['fake data']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |             ->willReturn(new \stdClass()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |         $trashResult = $handler->findTrashItems(null, 1, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |         $this->assertInstanceOf(TrashResult::class, $trashResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |         $this->assertEquals(2, $trashResult->totalCount); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |         $this->assertIsArray($trashResult->items); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |         $this->assertCount(1, $trashResult->items); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |         $this->assertIsIterable($trashResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |         $this->assertCount(1, $trashResult); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 607 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 608 |  |  |  | 
            
                        
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.