|
@@ 180-212 (lines=33) @@
|
| 177 |
|
* @covers \eZ\Publish\Core\Repository\SearchService::addPermissionsCriterion |
| 178 |
|
* @covers \eZ\Publish\Core\Repository\SearchService::findContent |
| 179 |
|
*/ |
| 180 |
|
public function testFindContentThrowsHandlerException() |
| 181 |
|
{ |
| 182 |
|
$this->expectException(\Exception::class); |
| 183 |
|
$this->expectExceptionMessage('Handler threw an exception'); |
| 184 |
|
|
| 185 |
|
$repositoryMock = $this->getRepositoryMock(); |
| 186 |
|
/** @var \eZ\Publish\SPI\Search\Handler $searchHandlerMock */ |
| 187 |
|
$searchHandlerMock = $this->getSPIMockHandler('Search\\Handler'); |
| 188 |
|
$permissionsCriterionResolverMock = $this->getPermissionCriterionResolverMock(); |
| 189 |
|
|
| 190 |
|
$service = new SearchService( |
| 191 |
|
$repositoryMock, |
| 192 |
|
$searchHandlerMock, |
| 193 |
|
$this->getContentDomainMapperMock(), |
| 194 |
|
$permissionsCriterionResolverMock, |
| 195 |
|
new NullIndexer(), |
| 196 |
|
[] |
| 197 |
|
); |
| 198 |
|
|
| 199 |
|
/** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterionMock */ |
| 200 |
|
$criterionMock = $this |
| 201 |
|
->getMockBuilder(Criterion::class) |
| 202 |
|
->disableOriginalConstructor() |
| 203 |
|
->getMock(); |
| 204 |
|
$query = new Query(['filter' => $criterionMock]); |
| 205 |
|
|
| 206 |
|
$permissionsCriterionResolverMock->expects($this->once()) |
| 207 |
|
->method('getPermissionsCriterion') |
| 208 |
|
->with('content', 'read') |
| 209 |
|
->will($this->throwException(new Exception('Handler threw an exception'))); |
| 210 |
|
|
| 211 |
|
$service->findContent($query, [], true); |
| 212 |
|
} |
| 213 |
|
|
| 214 |
|
/** |
| 215 |
|
* Test for the findContent() method when search is out of sync with persistence. |
|
@@ 845-877 (lines=33) @@
|
| 842 |
|
/** |
| 843 |
|
* Test for the findLocations() method. |
| 844 |
|
*/ |
| 845 |
|
public function testFindLocationsThrowsHandlerException() |
| 846 |
|
{ |
| 847 |
|
$this->expectException(\Exception::class); |
| 848 |
|
$this->expectExceptionMessage('Handler threw an exception'); |
| 849 |
|
|
| 850 |
|
$repositoryMock = $this->getRepositoryMock(); |
| 851 |
|
/** @var \eZ\Publish\SPI\Search\Handler $searchHandlerMock */ |
| 852 |
|
$searchHandlerMock = $this->getSPIMockHandler('Search\\Handler'); |
| 853 |
|
$permissionsCriterionResolverMock = $this->getPermissionCriterionResolverMock(); |
| 854 |
|
|
| 855 |
|
$service = new SearchService( |
| 856 |
|
$repositoryMock, |
| 857 |
|
$searchHandlerMock, |
| 858 |
|
$this->getContentDomainMapperMock(), |
| 859 |
|
$permissionsCriterionResolverMock, |
| 860 |
|
new NullIndexer(), |
| 861 |
|
[] |
| 862 |
|
); |
| 863 |
|
|
| 864 |
|
/** @var \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterionMock */ |
| 865 |
|
$criterionMock = $this |
| 866 |
|
->getMockBuilder(Criterion::class) |
| 867 |
|
->disableOriginalConstructor() |
| 868 |
|
->getMock(); |
| 869 |
|
$query = new LocationQuery(['filter' => $criterionMock]); |
| 870 |
|
|
| 871 |
|
$permissionsCriterionResolverMock->expects($this->once()) |
| 872 |
|
->method('getPermissionsCriterion') |
| 873 |
|
->with('content', 'read') |
| 874 |
|
->will($this->throwException(new Exception('Handler threw an exception'))); |
| 875 |
|
|
| 876 |
|
$service->findLocations($query, [], true); |
| 877 |
|
} |
| 878 |
|
|
| 879 |
|
/** |
| 880 |
|
* Test for the findLocations() method. |