You are here

public function EntryPointTest::testIndex in JSON:API 8

@covers ::index

File

tests/src/Kernel/Controller/EntryPointTest.php, line 32

Class

EntryPointTest
@coversDefaultClass \Drupal\jsonapi\Controller\EntryPoint @group jsonapi @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Controller

Code

public function testIndex() {
  $controller = new EntryPoint(\Drupal::service('jsonapi.resource_type.repository'), \Drupal::service('renderer'), new CacheableJsonResponse());
  $processed_response = $controller
    ->index();
  $this
    ->assertEquals([
    'url.site',
  ], $processed_response
    ->getCacheableMetadata()
    ->getCacheContexts());
  $data = json_decode($processed_response
    ->getContent(), TRUE);
  $links = $data['links'];
  $this
    ->assertRegExp('/.*\\/jsonapi/', $links['self']);
  $this
    ->assertRegExp('/.*\\/jsonapi\\/user\\/user/', $links['user--user']);
  $this
    ->assertRegExp('/.*\\/jsonapi\\/node_type\\/node_type/', $links['node_type--node_type']);
}