You are here

public function RoutesTest::routeDataProvider in JSON:API Search API 8

Test data for route generation.

Return value

\Generator The test data.

File

tests/src/Unit/RoutesTest.php, line 95

Class

RoutesTest
Tests route generation.

Namespace

Drupal\Tests\jsonapi_search_api\Unit

Code

public function routeDataProvider() : \Generator {
  $index = $this
    ->getStubMockedIndex();
  $mocked_datasource = $this
    ->prophesize(DatasourceInterface::class);
  $mocked_datasource
    ->getEntityTypeId()
    ->willReturn('node');
  $mocked_datasource
    ->getBundles()
    ->willReturn([
    'articles' => 'Articles',
  ]);
  $index
    ->getDatasources()
    ->willReturn([
    $mocked_datasource
      ->reveal(),
  ]);
  (yield [
    $index
      ->reveal(),
    FALSE,
    [
      'node',
    ],
    $this
      ->getMockedResourceTypes('node', [
      'articles',
    ]),
  ]);
  $index = $this
    ->getStubMockedIndex('test_index', FALSE);
  $mocked_datasource = $this
    ->prophesize(DatasourceInterface::class);
  $mocked_datasource
    ->getEntityTypeId()
    ->willReturn('node');
  $mocked_datasource
    ->getBundles()
    ->willReturn([
    'articles' => 'Articles',
  ]);
  $index
    ->getDatasources()
    ->willReturn([
    $mocked_datasource
      ->reveal(),
  ]);
  (yield [
    $index
      ->reveal(),
    TRUE,
    [
      'node',
    ],
    $this
      ->getMockedResourceTypes('node', [
      'articles',
    ]),
  ]);
  $index = $this
    ->getStubMockedIndex();
  $mocked_datasource = $this
    ->prophesize(DatasourceInterface::class);
  $mocked_datasource
    ->getEntityTypeId()
    ->willReturn('node');
  $mocked_datasource
    ->getBundles()
    ->willReturn([
    'articles' => 'Articles',
    'pages' => 'Pages',
  ]);
  $index
    ->getDatasources()
    ->willReturn([
    $mocked_datasource
      ->reveal(),
  ]);
  (yield [
    $index
      ->reveal(),
    FALSE,
    [
      'node',
    ],
    $this
      ->getMockedResourceTypes('node', [
      'articles',
      'pages',
    ]),
  ]);
}