function SerializerTest::setUp
Same name in this branch
- 10 core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php \Drupal\Tests\rest\Unit\Plugin\views\style\SerializerTest::setUp()
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Kernel/Serializer/SerializerTest.php \Drupal\Tests\jsonapi\Kernel\Serializer\SerializerTest::setUp()
- 9 core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php \Drupal\Tests\rest\Unit\Plugin\views\style\SerializerTest::setUp()
- 8.9.x core/modules/jsonapi/tests/src/Kernel/Serializer/SerializerTest.php \Drupal\Tests\jsonapi\Kernel\Serializer\SerializerTest::setUp()
- 8.9.x core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php \Drupal\Tests\rest\Unit\Plugin\views\style\SerializerTest::setUp()
- 11.x core/modules/jsonapi/tests/src/Kernel/Serializer/SerializerTest.php \Drupal\Tests\jsonapi\Kernel\Serializer\SerializerTest::setUp()
- 11.x core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php \Drupal\Tests\rest\Unit\Plugin\views\style\SerializerTest::setUp()
Overrides KernelTestBase::setUp
File
-
core/
modules/ jsonapi/ tests/ src/ Kernel/ Serializer/ SerializerTest.php, line 72
Class
- SerializerTest
- Tests the JSON:API serializer.
Namespace
Drupal\Tests\jsonapi\Kernel\SerializerCode
protected function setUp() : void {
parent::setUp();
// Add the entity schemas.
$this->installEntitySchema('node');
$this->installEntitySchema('user');
// Add the additional table schemas.
$this->installSchema('node', [
'node_access',
]);
$this->installSchema('user', [
'users_data',
]);
$this->user = User::create([
'name' => $this->randomString(),
'status' => 1,
]);
$this->user
->save();
NodeType::create([
'type' => 'foo',
'name' => 'Foo',
])->save();
$this->createTextField('node', 'foo', 'field_text', 'Text');
$this->node = Node::create([
'title' => 'Test Node',
'type' => 'foo',
'field_text' => [
'value' => 'This is some text.',
'format' => 'text_plain',
],
'uid' => $this->user
->id(),
]);
$this->node
->save();
$this->container
->setAlias('sut', 'jsonapi.serializer');
$this->resourceType = $this->container
->get('jsonapi.resource_type.repository')
->get($this->node
->getEntityTypeId(), $this->node
->bundle());
$this->sut = $this->container
->get('sut');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.