protected function RoutesTest::setUp in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Unit/Routing/RoutesTest.php \Drupal\Tests\jsonapi\Unit\Routing\RoutesTest::setUp()
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Routing/ RoutesTest.php, line 31
Class
- RoutesTest
- @coversDefaultClass \Drupal\jsonapi\Routing\Routes @group jsonapi
Namespace
Drupal\Tests\jsonapi\Unit\RoutingCode
protected function setUp() {
parent::setUp();
$type_1 = new ResourceType('entity_type_1', 'bundle_1_1', EntityInterface::class);
$type_2 = new ResourceType('entity_type_2', 'bundle_2_1', EntityInterface::class, TRUE);
$relatable_resource_types = [
'external' => [
$type_1,
],
'internal' => [
$type_2,
],
'both' => [
$type_1,
$type_2,
],
];
$type_1
->setRelatableResourceTypes($relatable_resource_types);
$type_2
->setRelatableResourceTypes($relatable_resource_types);
// This type ensures that we can create routes for bundle IDs which might be
// cast from strings to integers. It should not affect related resource
// routing.
$type_3 = new ResourceType('entity_type_3', '123', EntityInterface::class, TRUE);
$type_3
->setRelatableResourceTypes([]);
$resource_type_repository = $this
->prophesize(ResourceTypeRepository::class);
$resource_type_repository
->all()
->willReturn([
$type_1,
$type_2,
$type_3,
]);
$container = $this
->prophesize(ContainerInterface::class);
$container
->get('jsonapi.resource_type.repository')
->willReturn($resource_type_repository
->reveal());
$container
->getParameter('jsonapi.base_path')
->willReturn('/jsonapi');
$container
->getParameter('authentication_providers')
->willReturn([
'lorem' => [],
'ipsum' => [],
]);
$this->routes['ok'] = Routes::create($container
->reveal());
}