public function EntryPointTest::testFarmMeta in farmOS 2.x
Test that the meta.farm data is correct.
File
- modules/
core/ api/ tests/ src/ Functional/ EntryPointTest.php, line 76
Class
- EntryPointTest
- Tests the API entry point functionality.
Namespace
Drupal\Tests\farm_api\FunctionalCode
public function testFarmMeta() {
$request_options = [];
$request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
$response = $this
->request('GET', Url::fromUri('base://api'), $request_options);
$document = Json::decode((string) $response
->getBody());
// Assert that the meta key exists.
$this
->assertArrayHasKey('meta', $document);
// Assert that the meta.farm key exists.
$this
->assertArrayHasKey('farm', $document['meta']);
// Array of expected values.
$expected_values = [
'name' => $this
->config('system.site')
->get('name'),
'url' => $this->baseUrl,
'version' => '2.x',
];
foreach ($expected_values as $key => $value) {
$this
->assertArrayHasKey($key, $document['meta']['farm']);
$this
->assertEquals($value, $document['meta']['farm'][$key]);
}
}