protected function JsonApiExtrasFunctionalTestBase::setUp in JSON:API Extras 8.3
Overrides JsonApiFunctionalTestBase::setUp
File
- tests/
src/ Functional/ JsonApiExtrasFunctionalTestBase.php, line 21
Class
- JsonApiExtrasFunctionalTestBase
- Provides helper methods for the JSON API Extras module's functional tests.
Namespace
Drupal\Tests\jsonapi_extras\FunctionalCode
protected function setUp() {
parent::setUp();
// Add vocabs field to the tags.
$this
->createEntityReferenceField('taxonomy_term', 'tags', 'vocabs', 'Vocabularies', 'taxonomy_vocabulary', 'default', [
'target_bundles' => [
'tags' => 'taxonomy_vocabulary',
],
'auto_create' => TRUE,
], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
FieldStorageConfig::create([
'field_name' => 'field_timestamp',
'entity_type' => 'node',
'type' => 'timestamp',
'settings' => [],
'cardinality' => 1,
])
->save();
$field_config = FieldConfig::create([
'field_name' => 'field_timestamp',
'label' => 'Timestamp',
'entity_type' => 'node',
'bundle' => 'article',
'required' => FALSE,
'settings' => [],
'description' => '',
]);
$field_config
->save();
$config = \Drupal::configFactory()
->getEditable('jsonapi_extras.settings');
$config
->set('path_prefix', 'api');
$config
->set('include_count', TRUE);
$config
->save(TRUE);
$this
->grantPermissions(Role::load(Role::ANONYMOUS_ID), [
'access jsonapi resource list',
]);
static::overrideResources();
$this
->resetAll();
$role = $this->user
->get('roles')[0]->entity;
$this
->grantPermissions($role, [
'administer nodes',
'administer site configuration',
]);
}