Code Duplication    Length = 25-28 lines in 2 locations

eZ/Publish/API/Repository/Tests/TrashServiceTest.php 2 locations

@@ 455-482 (lines=28) @@
452
     * @see \eZ\Publish\API\Repository\TrashService::findTrashItems()
453
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash
454
     */
455
    public function testFindTrashItems()
456
    {
457
        $repository = $this->getRepository();
458
        $trashService = $repository->getTrashService();
459
460
        /* BEGIN: Use Case */
461
        $this->createTrashItem();
462
463
        // Create a search query for all trashed items
464
        $query = new Query();
465
        $query->filter = new Criterion\LogicalAnd(
466
            array(
467
                new Criterion\Field('title', Criterion\Operator::LIKE, '*'),
468
            )
469
        );
470
471
        // Load all trashed locations
472
        $searchResult = $trashService->findTrashItems($query);
473
        /* END: Use Case */
474
475
        $this->assertInstanceOf(
476
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\SearchResult',
477
            $searchResult
478
        );
479
480
        // 4 trashed locations from the sub tree
481
        $this->assertEquals(4, $searchResult->count);
482
    }
483
484
    /**
485
     * Test for the emptyTrash() method.
@@ 490-514 (lines=25) @@
487
     * @see \eZ\Publish\API\Repository\TrashService::emptyTrash()
488
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testFindTrashItems
489
     */
490
    public function testEmptyTrash()
491
    {
492
        $repository = $this->getRepository();
493
        $trashService = $repository->getTrashService();
494
495
        /* BEGIN: Use Case */
496
        $this->createTrashItem();
497
498
        // Empty the trash
499
        $trashService->emptyTrash();
500
501
        // Create a search query for all trashed items
502
        $query = new Query();
503
        $query->filter = new Criterion\LogicalAnd(
504
            array(
505
                new Criterion\Field('title', Criterion\Operator::LIKE, '*'),
506
            )
507
        );
508
509
        // Load all trashed locations, search result should be empty
510
        $searchResult = $trashService->findTrashItems($query);
511
        /* END: Use Case */
512
513
        $this->assertEquals(0, $searchResult->count);
514
    }
515
516
    /**
517
     * Test for the deleteTrashItem() method.