public function IndexResourceTest::testResultCounting in JSON:API Search API 8
Tests that the result count is added.
File
- tests/
src/ Functional/ IndexResourceTest.php, line 106
Class
- IndexResourceTest
- Tests index resource..
Namespace
Drupal\Tests\jsonapi_search_api\FunctionalCode
public function testResultCounting() {
$original_entity_count = count($this->entities);
$request_options = [];
$request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
$url = Url::fromRoute('jsonapi_search_api.index_database_search_index', [], []);
$response = $this
->request('GET', $url, $request_options);
$response_document = Json::decode((string) $response
->getBody());
$this
->assertEquals($original_entity_count, $response_document['meta']['count']);
$this
->removeTestEntity(1);
$response = $this
->request('GET', $url, $request_options);
$response_document = Json::decode((string) $response
->getBody());
$this
->assertEquals($original_entity_count - 1, $response_document['meta']['count']);
}