Completed
Push — ezp-29724 ( 1025e5...495423 )
by
unknown
30:13 queued 07:05
created

TrashHandlerTest::testRecover()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
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\Core\Persistence\Legacy\Tests\TestCase;
12
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler;
13
use eZ\Publish\SPI\Persistence\Content\Location\Trashed;
14
use eZ\Publish\Core\Persistence\Legacy\Content as CoreContent;
15
16
/**
17
 * Test case for TrashHandlerTest.
18
 */
19
class TrashHandlerTest extends TestCase
20
{
21
    /**
22
     * Mocked location handler instance.
23
     *
24
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Handler
25
     */
26
    protected $locationHandler;
27
28
    /**
29
     * Mocked location gateway instance.
30
     *
31
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway
32
     */
33
    protected $locationGateway;
34
35
    /**
36
     * Mocked location mapper instance.
37
     *
38
     * @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper
39
     */
40
    protected $locationMapper;
41
42
    /**
43
     * Mocked content handler instance.
44
     *
45
     * @var \PHPUnit\Framework\MockObject\MockObject
46
     */
47
    protected $contentHandler;
48
49 View Code Duplication
    protected function getTrashHandler()
50
    {
51
        $dbHandler = $this->getDatabaseHandler();
0 ignored issues
show
Unused Code introduced by
$dbHandler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
53
        return new Handler(
54
            $this->locationHandler = $this->createMock(CoreContent\Location\Handler::class),
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\eZ\Pu...ocation\Handler::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<eZ\Publish\Core\P...ntent\Location\Handler> of property $locationHandler.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
55
            $this->locationGateway = $this->createMock(CoreContent\Location\Gateway::class),
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\eZ\Pu...ocation\Gateway::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<eZ\Publish\Core\P...ntent\Location\Gateway> of property $locationGateway.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
56
            $this->locationMapper = $this->createMock(CoreContent\Location\Mapper::class),
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\eZ\Pu...Location\Mapper::class) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<eZ\Publish\Core\P...ontent\Location\Mapper> of property $locationMapper.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
57
            $this->contentHandler = $this->createMock(CoreContent\Handler::class)
58
        );
59
    }
60
61
    /**
62
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::trashSubtree
63
     */
64
    public function testTrashSubtree()
65
    {
66
        $handler = $this->getTrashHandler();
67
68
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
69
            ->expects($this->at(0))
70
            ->method('getSubtreeContent')
71
            ->with(20)
72
            ->will(
73
                $this->returnValue(
74
                    array(
75
                        array(
76
                            'contentobject_id' => 10,
77
                            'node_id' => 20,
78
                            'main_node_id' => 30,
79
                            'parent_node_id' => 40,
80
                        ),
81
                        array(
82
                            'contentobject_id' => 11,
83
                            'node_id' => 21,
84
                            'main_node_id' => 31,
85
                            'parent_node_id' => 41,
86
                        ),
87
                    )
88
                )
89
            );
90
91
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92
            ->expects($this->at(1))
93
            ->method('countLocationsByContentId')
94
            ->with(10)
95
            ->will($this->returnValue(1));
96
97
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
98
            ->expects($this->at(2))
99
            ->method('trashLocation')
100
            ->with(20);
101
102
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
103
            ->expects($this->at(3))
104
            ->method('countLocationsByContentId')
105
            ->with(11)
106
            ->will($this->returnValue(2));
107
108
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
109
            ->expects($this->at(4))
110
            ->method('removeLocation')
111
            ->with(21);
112
113
        $this->locationHandler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
114
            ->expects($this->once())
115
            ->method('markSubtreeModified')
116
            ->with(40);
117
118
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
119
            ->expects($this->at(5))
120
            ->method('loadTrashByLocation')
121
            ->with(20)
122
            ->will($this->returnValue($array = array('data…')));
123
124
        $this->locationMapper
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ontent\Location\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
125
            ->expects($this->once())
126
            ->method('createLocationFromRow')
127
            ->with($array, null, new Trashed())
128
            ->will($this->returnValue(new Trashed(array('id' => 20))));
129
130
        $trashedObject = $handler->trashSubtree(20);
131
        self::assertInstanceOf(Trashed::class, $trashedObject);
132
        self::assertSame(20, $trashedObject->id);
133
    }
134
135
    /**
136
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::trashSubtree
137
     */
138
    public function testTrashSubtreeReturnsNull()
139
    {
140
        $handler = $this->getTrashHandler();
141
142
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
143
            ->expects($this->at(0))
144
            ->method('getSubtreeContent')
145
            ->with(20)
146
            ->will(
147
                $this->returnValue(
148
                    array(
149
                        array(
150
                            'contentobject_id' => 10,
151
                            'node_id' => 20,
152
                            'main_node_id' => 30,
153
                            'parent_node_id' => 40,
154
                        ),
155
                        array(
156
                            'contentobject_id' => 11,
157
                            'node_id' => 21,
158
                            'main_node_id' => 31,
159
                            'parent_node_id' => 41,
160
                        ),
161
                    )
162
                )
163
            );
164
165
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
166
            ->expects($this->at(1))
167
            ->method('countLocationsByContentId')
168
            ->with(10)
169
            ->will($this->returnValue(2));
170
171
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
172
            ->expects($this->at(2))
173
            ->method('removeLocation')
174
            ->with(20);
175
176
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
177
            ->expects($this->at(3))
178
            ->method('countLocationsByContentId')
179
            ->with(11)
180
            ->will($this->returnValue(1));
181
182
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
183
            ->expects($this->at(4))
184
            ->method('trashLocation')
185
            ->with(21);
186
187
        $this->locationHandler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
188
            ->expects($this->once())
189
            ->method('markSubtreeModified')
190
            ->with(40);
191
192
        $returnValue = $handler->trashSubtree(20);
193
        self::assertNull($returnValue);
194
    }
195
196
    /**
197
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::trashSubtree
198
     */
199
    public function testTrashSubtreeUpdatesMainLocation()
200
    {
201
        $handler = $this->getTrashHandler();
202
203
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
204
            ->expects($this->at(0))
205
            ->method('getSubtreeContent')
206
            ->with(20)
207
            ->will(
208
                $this->returnValue(
209
                    array(
210
                        array(
211
                            'contentobject_id' => 10,
212
                            'node_id' => 20,
213
                            'main_node_id' => 30,
214
                            'parent_node_id' => 40,
215
                        ),
216
                        array(
217
                            'contentobject_id' => 11,
218
                            'node_id' => 21,
219
                            'main_node_id' => 21,
220
                            'parent_node_id' => 41,
221
                        ),
222
                    )
223
                )
224
            );
225
226
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
227
            ->expects($this->at(1))
228
            ->method('countLocationsByContentId')
229
            ->with(10)
230
            ->will($this->returnValue(1));
231
232
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
233
            ->expects($this->at(2))
234
            ->method('trashLocation')
235
            ->with(20);
236
237
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
238
            ->expects($this->at(3))
239
            ->method('countLocationsByContentId')
240
            ->with(11)
241
            ->will($this->returnValue(2));
242
243
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
244
            ->expects($this->at(4))
245
            ->method('removeLocation')
246
            ->with(21);
247
248
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
249
            ->expects($this->at(5))
250
            ->method('getFallbackMainNodeData')
251
            ->with(11, 21)
252
            ->will(
253
                $this->returnValue(
254
                    array(
255
                        'node_id' => 100,
256
                        'contentobject_version' => 101,
257
                        'parent_node_id' => 102,
258
                    )
259
                )
260
            );
261
262
        $this->locationHandler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
263
            ->expects($this->once())
264
            ->method('changeMainLocation')
265
            ->with(11, 100, 101, 102);
266
267
        $this->locationHandler
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Handler>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
268
            ->expects($this->once())
269
            ->method('markSubtreeModified')
270
            ->with(40);
271
272
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
273
            ->expects($this->at(6))
274
            ->method('loadTrashByLocation')
275
            ->with(20)
276
            ->will($this->returnValue($array = array('data…')));
277
278
        $this->locationMapper
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ontent\Location\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
279
            ->expects($this->once())
280
            ->method('createLocationFromRow')
281
            ->with($array, null, new Trashed())
282
            ->will($this->returnValue(new Trashed(array('id' => 20))));
283
284
        $trashedObject = $handler->trashSubtree(20);
285
        self::assertInstanceOf(Trashed::class, $trashedObject);
286
        self::assertSame(20, $trashedObject->id);
287
    }
288
289
    /**
290
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::recover
291
     */
292
    public function testRecover()
293
    {
294
        $handler = $this->getTrashHandler();
295
296
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
297
            ->expects($this->at(0))
298
            ->method('untrashLocation')
299
            ->with(69, 23)
300
            ->will(
301
                $this->returnValue(
302
                    new Trashed(array('id' => 70))
303
                )
304
            );
305
306
        self::assertSame(70, $handler->recover(69, 23));
307
    }
308
309
    /**
310
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::loadTrashItem
311
     */
312
    public function testLoadTrashItem()
313
    {
314
        $handler = $this->getTrashHandler();
315
316
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
317
            ->expects($this->at(0))
318
            ->method('loadTrashByLocation')
319
            ->with(69)
320
            ->will($this->returnValue($array = array('data…')));
321
322
        $this->locationMapper
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ontent\Location\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
323
            ->expects($this->at(0))
324
            ->method('createLocationFromRow')
325
            ->with($array, null, new Trashed());
326
327
        $handler->loadTrashItem(69);
328
    }
329
330
    /**
331
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::emptyTrash
332
     */
333
    public function testEmptyTrash()
334
    {
335
        $handler = $this->getTrashHandler();
336
337
        $expectedTrashed = array(
338
            array(
339
                'node_id' => 69,
340
                'path_string' => '/1/2/69/',
341
                'contentobject_id' => 67,
342
            ),
343
            array(
344
                'node_id' => 70,
345
                'path_string' => '/1/2/70/',
346
                'contentobject_id' => 68,
347
            ),
348
        );
349
350
        // Index for locationGateway calls
351
        $i = 0;
352
        // Index for contentHandler calls
353
        $iContent = 0;
354
        // Index for locationMapper calls
355
        $iLocation = 0;
356
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
357
            ->expects($this->at($i++))
358
            ->method('listTrashed')
359
            ->will(
360
                $this->returnValue($expectedTrashed)
361
            );
362
363
        foreach ($expectedTrashed as $trashedElement) {
364
            $this->locationMapper
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ontent\Location\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
365
                ->expects($this->at($iLocation++))
366
                ->method('createLocationFromRow')
367
                ->will(
368
                    $this->returnValue(
369
                        new Trashed(
370
                            array(
371
                                'id' => $trashedElement['node_id'],
372
                                'contentId' => $trashedElement['contentobject_id'],
373
                                'pathString' => $trashedElement['path_string'],
374
                            )
375
                        )
376
                    )
377
                );
378
            $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
379
                ->expects($this->at($i++))
380
                ->method('removeElementFromTrash')
381
                ->with($trashedElement['node_id']);
382
383
            $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
384
                ->expects($this->at($i++))
385
                ->method('countLocationsByContentId')
386
                ->with($trashedElement['contentobject_id'])
387
                ->will($this->returnValue(0));
388
389
            $this->contentHandler
390
                ->expects($this->at($iContent++))
391
                ->method('deleteContent')
392
                ->with($trashedElement['contentobject_id']);
393
        }
394
395
        $handler->emptyTrash();
396
    }
397
398
    /**
399
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem
400
     */
401 View Code Duplication
    public function testDeleteTrashItemNoMoreLocations()
402
    {
403
        $handler = $this->getTrashHandler();
404
405
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
406
            ->expects($this->once())
407
            ->method('loadTrashByLocation')
408
            ->with(69)
409
            ->will(
410
                $this->returnValue(
411
                    array(
412
                        'node_id' => 69,
413
                        'contentobject_id' => 67,
414
                        'path_string' => '/1/2/69',
415
                    )
416
                )
417
            );
418
419
        $this->locationMapper
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ontent\Location\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
420
            ->expects($this->once())
421
            ->method('createLocationFromRow')
422
            ->will(
423
                $this->returnValue(
424
                    new Trashed(
425
                        array(
426
                            'id' => 69,
427
                            'contentId' => 67,
428
                            'pathString' => '/1/2/69',
429
                        )
430
                    )
431
                )
432
            );
433
434
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
435
            ->expects($this->once())
436
            ->method('removeElementFromTrash')
437
            ->with(69);
438
439
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
440
            ->expects($this->once())
441
            ->method('countLocationsByContentId')
442
            ->with(67)
443
            ->will($this->returnValue(0));
444
445
        $this->contentHandler
446
            ->expects($this->once())
447
            ->method('deleteContent')
448
            ->with(67);
449
450
        $handler->deleteTrashItem(69);
451
    }
452
453
    /**
454
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem
455
     */
456 View Code Duplication
    public function testDeleteTrashItemStillHaveLocations()
457
    {
458
        $handler = $this->getTrashHandler();
459
460
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
461
            ->expects($this->once())
462
            ->method('loadTrashByLocation')
463
            ->with(69)
464
            ->will(
465
                $this->returnValue(
466
                    array(
467
                        'node_id' => 69,
468
                        'contentobject_id' => 67,
469
                        'path_string' => '/1/2/69',
470
                    )
471
                )
472
            );
473
474
        $this->locationMapper
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ontent\Location\Mapper>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
475
            ->expects($this->once())
476
            ->method('createLocationFromRow')
477
            ->will(
478
                $this->returnValue(
479
                    new Trashed(
480
                        array(
481
                            'id' => 69,
482
                            'contentId' => 67,
483
                            'pathString' => '/1/2/69',
484
                        )
485
                    )
486
                )
487
            );
488
489
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
490
            ->expects($this->once())
491
            ->method('removeElementFromTrash')
492
            ->with(69);
493
494
        $this->locationGateway
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<eZ\Publish\Core\P...ntent\Location\Gateway>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
495
            ->expects($this->once())
496
            ->method('countLocationsByContentId')
497
            ->with(67)
498
            ->will($this->returnValue(1));
499
500
        $this->contentHandler
501
            ->expects($this->never())
502
            ->method('deleteContent');
503
504
        $handler->deleteTrashItem(69);
505
    }
506
}
507