Code Duplication    Length = 24-26 lines in 4 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/TreeHandlerTest.php 1 location

@@ 331-356 (lines=26) @@
328
        $treeHandler->changeMainLocation(12, 34);
329
    }
330
331
    public function testLoadLocation()
332
    {
333
        $treeHandler = $this->getTreeHandler();
334
335
        $this->getLocationGatewayMock()
336
            ->expects($this->once())
337
            ->method('getBasicNodeData')
338
            ->with(77)
339
            ->will(
340
                $this->returnValue(
341
                    array(
342
                        'node_id' => 77,
343
                    )
344
                )
345
            );
346
347
        $this->getLocationMapperMock()
348
            ->expects($this->once())
349
            ->method('createLocationFromRow')
350
            ->with(array('node_id' => 77))
351
            ->will($this->returnValue(new Location()));
352
353
        $location = $treeHandler->loadLocation(77);
354
355
        $this->assertTrue($location instanceof Location);
356
    }
357
358
    /**
359
     * @var \PHPUnit_Framework_MockObject_MockObject|\eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway

eZ/Publish/Core/Persistence/Legacy/Tests/Content/LocationHandlerTest.php 3 locations

@@ 119-144 (lines=26) @@
116
        $this->assertEquals(2, count($this->getLocationHandler()->loadSubtreeIds(77)));
117
    }
118
119
    public function testLoadLocationByRemoteId()
120
    {
121
        $handler = $this->getLocationHandler();
122
123
        $this->locationGateway
124
            ->expects($this->once())
125
            ->method('getBasicNodeDataByRemoteId')
126
            ->with('abc123')
127
            ->will(
128
                $this->returnValue(
129
                    array(
130
                        'node_id' => 77,
131
                    )
132
                )
133
            );
134
135
        $this->locationMapper
136
            ->expects($this->once())
137
            ->method('createLocationFromRow')
138
            ->with(array('node_id' => 77))
139
            ->will($this->returnValue(new \eZ\Publish\SPI\Persistence\Content\Location()));
140
141
        $location = $handler->loadByRemoteId('abc123');
142
143
        $this->assertTrue($location instanceof \eZ\Publish\SPI\Persistence\Content\Location);
144
    }
145
146
    public function testLoadLocationsByContent()
147
    {
@@ 146-169 (lines=24) @@
143
        $this->assertTrue($location instanceof \eZ\Publish\SPI\Persistence\Content\Location);
144
    }
145
146
    public function testLoadLocationsByContent()
147
    {
148
        $handler = $this->getLocationHandler();
149
150
        $this->locationGateway
151
            ->expects($this->once())
152
            ->method('loadLocationDataByContent')
153
            ->with(23, 42)
154
            ->will(
155
                $this->returnValue(
156
                    array()
157
                )
158
            );
159
160
        $this->locationMapper
161
            ->expects($this->once())
162
            ->method('createLocationsFromRows')
163
            ->with(array())
164
            ->will($this->returnValue(array('a', 'b')));
165
166
        $locations = $handler->loadLocationsByContent(23, 42);
167
168
        $this->assertInternalType('array', $locations);
169
    }
170
171
    public function loadParentLocationsForDraftContent()
172
    {
@@ 171-194 (lines=24) @@
168
        $this->assertInternalType('array', $locations);
169
    }
170
171
    public function loadParentLocationsForDraftContent()
172
    {
173
        $handler = $this->getLocationHandler();
174
175
        $this->locationGateway
176
            ->expects($this->once())
177
            ->method('loadParentLocationsDataForDraftContent')
178
            ->with(23)
179
            ->will(
180
                $this->returnValue(
181
                    array()
182
                )
183
            );
184
185
        $this->locationMapper
186
            ->expects($this->once())
187
            ->method('createLocationsFromRows')
188
            ->with(array())
189
            ->will($this->returnValue(array('a', 'b')));
190
191
        $locations = $handler->loadParentLocationsForDraftContent(23);
192
193
        $this->assertInternalType('array', $locations);
194
    }
195
196
    public function testMoveSubtree()
197
    {