Code Duplication    Length = 17-28 lines in 6 locations

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

@@ 97-114 (lines=18) @@
94
     *
95
     * @depends testFindContentInfoFullTextIsSearchable
96
     */
97
    public function testFindContentInfoFullTextIsNotSearchable()
98
    {
99
        $searchTerm = 'pamplemousse';
100
        $this->createFullTextIsSearchableContent($searchTerm, false);
101
102
        $repository = $this->getRepository();
103
        $searchService = $repository->getSearchService();
104
105
        $query = new Query(
106
            [
107
                'query' => new Criterion\FullText($searchTerm),
108
            ]
109
        );
110
111
        $searchResult = $searchService->findContentInfo($query);
112
113
        $this->assertEquals(0, $searchResult->totalCount);
114
    }
115
116
    /**
117
     * Test that indexing full text data depends on the isSearchable flag on the field definition.
@@ 121-137 (lines=17) @@
118
     *
119
     * @depends testFindLocationsFullTextIsSearchable
120
     */
121
    public function testFindLocationsFullTextIsNotSearchable()
122
    {
123
        $searchTerm = 'pamplemousse';
124
125
        $repository = $this->getRepository(false);
126
        $searchService = $repository->getSearchService();
127
128
        $query = new LocationQuery(
129
            [
130
                'query' => new Criterion\FullText($searchTerm),
131
            ]
132
        );
133
134
        $searchResult = $searchService->findLocations($query);
135
136
        $this->assertEquals(0, $searchResult->totalCount);
137
    }
138
139
    /**
140
     * Creates Content for testing full text search depending on the isSearchable flag.

eZ/Publish/API/Repository/Tests/SearchServiceLocationTest.php 1 location

@@ 140-158 (lines=19) @@
137
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
138
     * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains
139
     */
140
    public function testFieldCollectionContainsNoMatch()
141
    {
142
        $this->createMultipleCountriesContent();
143
        $query = new LocationQuery(
144
            array(
145
                'query' => new Criterion\Field(
146
                    'countries',
147
                    Criterion\Operator::CONTAINS,
148
                    'Netherlands Antilles'
149
                ),
150
            )
151
        );
152
153
        $repository = $this->getRepository();
154
        $searchService = $repository->getSearchService();
155
        $result = $searchService->findLocations($query);
156
157
        $this->assertEquals(0, $result->totalCount);
158
    }
159
160
    /**
161
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException

eZ/Publish/API/Repository/Tests/SearchServiceTest.php 1 location

@@ 1217-1235 (lines=19) @@
1214
     * @see \eZ\Publish\API\Repository\SearchService::findContent()
1215
     * @depends eZ\Publish\API\Repository\Tests\SearchServiceTest::testFieldCollectionContains
1216
     */
1217
    public function testFieldCollectionContainsNoMatch()
1218
    {
1219
        $this->createMultipleCountriesContent();
1220
        $query = new Query(
1221
            array(
1222
                'query' => new Criterion\Field(
1223
                    'countries',
1224
                    Criterion\Operator::CONTAINS,
1225
                    'Netherlands Antilles'
1226
                ),
1227
            )
1228
        );
1229
1230
        $repository = $this->getRepository();
1231
        $searchService = $repository->getSearchService();
1232
        $result = $searchService->findContent($query);
1233
1234
        $this->assertEquals(0, $result->totalCount);
1235
    }
1236
1237
    /**
1238
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException

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

@@ 632-659 (lines=28) @@
629
     * @see \eZ\Publish\API\Repository\TrashService::findTrashItems()
630
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash
631
     */
632
    public function testFindTrashItems()
633
    {
634
        $repository = $this->getRepository();
635
        $trashService = $repository->getTrashService();
636
637
        /* BEGIN: Use Case */
638
        $this->createTrashItem();
639
640
        // Create a search query for all trashed items
641
        $query = new Query();
642
        $query->filter = new Criterion\LogicalAnd(
643
            array(
644
                new Criterion\Field('title', Criterion\Operator::LIKE, '*'),
645
            )
646
        );
647
648
        // Load all trashed locations
649
        $searchResult = $trashService->findTrashItems($query);
650
        /* END: Use Case */
651
652
        $this->assertInstanceOf(
653
            '\\eZ\\Publish\\API\\Repository\\Values\\Content\\SearchResult',
654
            $searchResult
655
        );
656
657
        // 4 trashed locations from the sub tree
658
        $this->assertEquals(4, $searchResult->count);
659
    }
660
661
    /**
662
     * Test for the findTrashItems() method.
@@ 708-732 (lines=25) @@
705
     * @see \eZ\Publish\API\Repository\TrashService::emptyTrash()
706
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testFindTrashItems
707
     */
708
    public function testEmptyTrash()
709
    {
710
        $repository = $this->getRepository();
711
        $trashService = $repository->getTrashService();
712
713
        /* BEGIN: Use Case */
714
        $this->createTrashItem();
715
716
        // Empty the trash
717
        $trashService->emptyTrash();
718
719
        // Create a search query for all trashed items
720
        $query = new Query();
721
        $query->filter = new Criterion\LogicalAnd(
722
            array(
723
                new Criterion\Field('title', Criterion\Operator::LIKE, '*'),
724
            )
725
        );
726
727
        // Load all trashed locations, search result should be empty
728
        $searchResult = $trashService->findTrashItems($query);
729
        /* END: Use Case */
730
731
        $this->assertEquals(0, $searchResult->count);
732
    }
733
734
    /**
735
     * Test for the deleteTrashItem() method.