Code Duplication    Length = 30-30 lines in 2 locations

eZ/Publish/Core/Repository/Tests/Service/Mock/SearchTest.php 2 locations

@@ 206-235 (lines=30) @@
203
     * @expectedException \Exception
204
     * @expectedExceptionMessage Handler threw an exception
205
     */
206
    public function testFindContentThrowsHandlerException()
207
    {
208
        $repositoryMock = $this->getRepositoryMock();
209
        /** @var \eZ\Publish\SPI\Search\Handler $searchHandlerMock */
210
        $searchHandlerMock = $this->getSPIMockHandler('Search\\Handler');
211
        $permissionsCriterionResolverMock = $this->getPermissionCriterionResolverMock();
212
213
        $service = new SearchService(
214
            $repositoryMock,
215
            $searchHandlerMock,
216
            $this->getDomainMapperMock(),
217
            $permissionsCriterionResolverMock,
218
            new NullIndexer(),
219
            array()
220
        );
221
222
        /** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterionMock */
223
        $criterionMock = $this
224
            ->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\Criterion')
225
            ->disableOriginalConstructor()
226
            ->getMock();
227
        $query = new Query(array('filter' => $criterionMock));
228
229
        $permissionsCriterionResolverMock->expects($this->once())
230
            ->method('getPermissionsCriterion')
231
            ->with('content', 'read')
232
            ->will($this->throwException(new Exception('Handler threw an exception')));
233
234
        $service->findContent($query, array(), true);
235
    }
236
237
    /**
238
     * Test for the findContent() method.
@@ 787-816 (lines=30) @@
784
     * @expectedException \Exception
785
     * @expectedExceptionMessage Handler threw an exception
786
     */
787
    public function testFindLocationsThrowsHandlerException()
788
    {
789
        $repositoryMock = $this->getRepositoryMock();
790
        /** @var \eZ\Publish\SPI\Search\Handler $searchHandlerMock */
791
        $searchHandlerMock = $this->getSPIMockHandler('Search\\Handler');
792
        $permissionsCriterionResolverMock = $this->getPermissionCriterionResolverMock();
793
794
        $service = new SearchService(
795
            $repositoryMock,
796
            $searchHandlerMock,
797
            $this->getDomainMapperMock(),
798
            $permissionsCriterionResolverMock,
799
            new NullIndexer(),
800
            array()
801
        );
802
803
        /** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterionMock */
804
        $criterionMock = $this
805
            ->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\Criterion')
806
            ->disableOriginalConstructor()
807
            ->getMock();
808
        $query = new LocationQuery(array('filter' => $criterionMock));
809
810
        $permissionsCriterionResolverMock->expects($this->once())
811
            ->method('getPermissionsCriterion')
812
            ->with('content', 'read')
813
            ->will($this->throwException(new Exception('Handler threw an exception')));
814
815
        $service->findLocations($query, array(), true);
816
    }
817
818
    /**
819
     * Test for the findLocations() method.