protected function FieldResolverTest::setUp in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Context/FieldResolverTest.php \Drupal\Tests\jsonapi\Kernel\Context\FieldResolverTest::setUp()
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ Context/ FieldResolverTest.php, line 46
Class
- FieldResolverTest
- @coversDefaultClass \Drupal\jsonapi\Context\FieldResolver @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ContextCode
protected function setUp() {
parent::setUp();
$this->sut = \Drupal::service('jsonapi.field_resolver');
$this
->makeBundle('bundle1');
$this
->makeBundle('bundle2');
$this
->makeBundle('bundle3');
$this
->makeField('string', 'field_test1', 'entity_test_with_bundle', [
'bundle1',
]);
$this
->makeField('string', 'field_test2', 'entity_test_with_bundle', [
'bundle1',
]);
$this
->makeField('string', 'field_test3', 'entity_test_with_bundle', [
'bundle2',
'bundle3',
]);
// Provides entity reference fields.
$settings = [
'target_type' => 'entity_test_with_bundle',
];
$this
->makeField('entity_reference', 'field_test_ref1', 'entity_test_with_bundle', [
'bundle1',
], $settings, [
'handler_settings' => [
'target_bundles' => [
'bundle2',
'bundle3',
],
],
]);
$this
->makeField('entity_reference', 'field_test_ref2', 'entity_test_with_bundle', [
'bundle1',
], $settings);
$this
->makeField('entity_reference', 'field_test_ref3', 'entity_test_with_bundle', [
'bundle2',
'bundle3',
], $settings);
// Add a field with multiple properties.
$this
->makeField('text', 'field_test_text', 'entity_test_with_bundle', [
'bundle1',
'bundle2',
]);
$this->resourceTypeRepository = $this->container
->get('jsonapi.resource_type.repository');
}