@@ -329,7 +329,7 @@ public function testLoadTrashItem()
329
329
/**
330
330
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::emptyTrash
331
331
*/
332
- public function testEmptyTrash ()
332
+ public function testEmptyTrash (): void
333
333
{
334
334
$ handler = $ this ->getTrashHandler ();
335
335
@@ -354,48 +354,51 @@ public function testEmptyTrash()
354
354
$ iLocation = 0 ;
355
355
356
356
$ this ->locationGateway
357
- ->expects ($ this -> at ($ i ++))
357
+ ->expects (self :: at ($ i ++))
358
358
->method ('countTrashed ' )
359
359
->willReturn (2 );
360
360
361
361
$ this ->locationGateway
362
- ->expects ($ this -> at ($ i ++))
362
+ ->expects (self :: at ($ i ++))
363
363
->method ('listTrashed ' )
364
- ->will (
365
- $ this ->returnValue ($ expectedTrashed )
366
- );
364
+ ->willReturn ($ expectedTrashed );
367
365
368
366
$ trashedItemIds = [];
369
367
$ trashedContentIds = [];
370
368
371
369
foreach ($ expectedTrashed as $ trashedElement ) {
372
370
$ this ->locationMapper
373
- ->expects ($ this -> at ($ iLocation ++))
371
+ ->expects (self :: at ($ iLocation ++))
374
372
->method ('createLocationFromRow ' )
375
- ->will (
376
- $ this ->returnValue (
377
- new Trashed (
378
- [
379
- 'id ' => $ trashedElement ['node_id ' ],
380
- 'contentId ' => $ trashedElement ['contentobject_id ' ],
381
- 'pathString ' => $ trashedElement ['path_string ' ],
382
- ]
383
- )
373
+ ->willReturn (
374
+ new Trashed (
375
+ [
376
+ 'id ' => $ trashedElement ['node_id ' ],
377
+ 'contentId ' => $ trashedElement ['contentobject_id ' ],
378
+ 'pathString ' => $ trashedElement ['path_string ' ],
379
+ ]
384
380
)
385
381
);
382
+
383
+ $ this ->contentHandler
384
+ ->expects (self ::at ($ iContent ++))
385
+ ->method ('loadReverseRelations ' )
386
+ ->with ($ trashedElement ['contentobject_id ' ])
387
+ ->willReturn ([]);
388
+
386
389
$ this ->locationGateway
387
- ->expects ($ this -> at ($ i ++))
390
+ ->expects (self :: at ($ i ++))
388
391
->method ('removeElementFromTrash ' )
389
392
->with ($ trashedElement ['node_id ' ]);
390
393
391
394
$ this ->locationGateway
392
- ->expects ($ this -> at ($ i ++))
395
+ ->expects (self :: at ($ i ++))
393
396
->method ('countLocationsByContentId ' )
394
397
->with ($ trashedElement ['contentobject_id ' ])
395
- ->will ( $ this -> returnValue ( 0 ) );
398
+ ->willReturn ( 0 );
396
399
397
400
$ this ->contentHandler
398
- ->expects ($ this -> at ($ iContent ++))
401
+ ->expects (self :: at ($ iContent ++))
399
402
->method ('deleteContent ' )
400
403
->with ($ trashedElement ['contentobject_id ' ]);
401
404
@@ -405,75 +408,78 @@ public function testEmptyTrash()
405
408
406
409
$ returnValue = $ handler ->emptyTrash ();
407
410
408
- $ this -> assertInstanceOf (TrashItemDeleteResultList::class, $ returnValue );
411
+ self :: assertInstanceOf (TrashItemDeleteResultList::class, $ returnValue );
409
412
410
413
foreach ($ returnValue ->items as $ key => $ trashItemDeleteResult ) {
411
- $ this -> assertEquals ($ trashItemDeleteResult ->trashItemId , $ trashedItemIds [$ key ]);
412
- $ this -> assertEquals ($ trashItemDeleteResult ->contentId , $ trashedContentIds [$ key ]);
413
- $ this -> assertTrue ($ trashItemDeleteResult ->contentRemoved );
414
+ self :: assertEquals ($ trashItemDeleteResult ->trashItemId , $ trashedItemIds [$ key ]);
415
+ self :: assertEquals ($ trashItemDeleteResult ->contentId , $ trashedContentIds [$ key ]);
416
+ self :: assertTrue ($ trashItemDeleteResult ->contentRemoved );
414
417
}
415
418
}
416
419
417
420
/**
418
421
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Location\Trash\Handler::deleteTrashItem
419
422
*/
420
- public function testDeleteTrashItemNoMoreLocations ()
423
+ public function testDeleteTrashItemNoMoreLocations (): void
421
424
{
422
425
$ handler = $ this ->getTrashHandler ();
423
426
424
427
$ trashItemId = 69 ;
425
428
$ contentId = 67 ;
429
+
426
430
$ this ->locationGateway
427
- ->expects ($ this -> once ())
431
+ ->expects (self :: once ())
428
432
->method ('loadTrashByLocation ' )
429
433
->with ($ trashItemId )
430
- ->will (
431
- $ this ->returnValue (
432
- [
433
- 'node_id ' => $ trashItemId ,
434
- 'contentobject_id ' => $ contentId ,
435
- 'path_string ' => '/1/2/69 ' ,
436
- ]
437
- )
434
+ ->willReturn (
435
+ [
436
+ 'node_id ' => $ trashItemId ,
437
+ 'contentobject_id ' => $ contentId ,
438
+ 'path_string ' => '/1/2/69 ' ,
439
+ ]
438
440
);
439
441
440
442
$ this ->locationMapper
441
- ->expects ($ this -> once ())
443
+ ->expects (self :: once ())
442
444
->method ('createLocationFromRow ' )
443
- ->will (
444
- $ this ->returnValue (
445
- new Trashed (
446
- [
447
- 'id ' => $ trashItemId ,
448
- 'contentId ' => $ contentId ,
449
- 'pathString ' => '/1/2/69 ' ,
450
- ]
451
- )
445
+ ->willReturn (
446
+ new Trashed (
447
+ [
448
+ 'id ' => $ trashItemId ,
449
+ 'contentId ' => $ contentId ,
450
+ 'pathString ' => '/1/2/69 ' ,
451
+ ]
452
452
)
453
453
);
454
454
455
+ $ this ->contentHandler
456
+ ->expects (self ::once ())
457
+ ->method ('loadReverseRelations ' )
458
+ ->with ($ contentId )
459
+ ->willReturn ([]);
460
+
455
461
$ this ->locationGateway
456
- ->expects ($ this -> once ())
462
+ ->expects (self :: once ())
457
463
->method ('removeElementFromTrash ' )
458
464
->with ($ trashItemId );
459
465
460
466
$ this ->locationGateway
461
- ->expects ($ this -> once ())
467
+ ->expects (self :: once ())
462
468
->method ('countLocationsByContentId ' )
463
469
->with ($ contentId )
464
- ->will ( $ this -> returnValue ( 0 ) );
470
+ ->willReturn ( 0 );
465
471
466
472
$ this ->contentHandler
467
- ->expects ($ this -> once ())
473
+ ->expects (self :: once ())
468
474
->method ('deleteContent ' )
469
475
->with ($ contentId );
470
476
471
477
$ trashItemDeleteResult = $ handler ->deleteTrashItem ($ trashItemId );
472
478
473
- $ this -> assertInstanceOf (TrashItemDeleteResult::class, $ trashItemDeleteResult );
474
- $ this -> assertEquals ($ trashItemId , $ trashItemDeleteResult ->trashItemId );
475
- $ this -> assertEquals ($ contentId , $ trashItemDeleteResult ->contentId );
476
- $ this -> assertTrue ($ trashItemDeleteResult ->contentRemoved );
479
+ self :: assertInstanceOf (TrashItemDeleteResult::class, $ trashItemDeleteResult );
480
+ self :: assertEquals ($ trashItemId , $ trashItemDeleteResult ->trashItemId );
481
+ self :: assertEquals ($ contentId , $ trashItemDeleteResult ->contentId );
482
+ self :: assertTrue ($ trashItemDeleteResult ->contentRemoved );
477
483
}
478
484
479
485
/**
0 commit comments