You are here

private function RoutesTest::getMockedResourceTypes in JSON:API Search API 8

Get mocked resource types.

Parameters

string $entity_type_id: The entity type ID.

array $bundles: The bundles.

Return value

\Drupal\jsonapi\ResourceType\ResourceType[] The mocked resource types.

1 call to RoutesTest::getMockedResourceTypes()
RoutesTest::routeDataProvider in tests/src/Unit/RoutesTest.php
Test data for route generation.

File

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

Class

RoutesTest
Tests route generation.

Namespace

Drupal\Tests\jsonapi_search_api\Unit

Code

private function getMockedResourceTypes(string $entity_type_id, array $bundles) : array {
  return array_map(function (string $bundle) use ($entity_type_id) {
    $mocked_resource_type = $this
      ->prophesize(ResourceType::class);
    $mocked_resource_type
      ->getEntityTypeId()
      ->willReturn($entity_type_id);
    $mocked_resource_type
      ->getBundle()
      ->willReturn($bundle);
    $mocked_resource_type
      ->getTypeName()
      ->willReturn("{$entity_type_id}--{$bundle}");
    return $mocked_resource_type
      ->reveal();
  }, $bundles);
}