public function EntityResourceTest::testCreateIndividualConfig in JSON:API 8
@covers ::createIndividual
File
- tests/src/ Kernel/ Controller/ EntityResourceTest.php, line 446 
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testCreateIndividualConfig() {
  $node_type = NodeType::create([
    'type' => 'test',
    'name' => 'Test Type',
    'description' => 'Lorem ipsum',
  ]);
  Role::load(Role::ANONYMOUS_ID)
    ->grantPermission('administer content types')
    ->save();
  $entity_resource = $this
    ->buildEntityResource('node', 'article');
  $response = $entity_resource
    ->createIndividual($node_type, new Request());
  // As a side effect, the node type will also be saved.
  $this
    ->assertNotEmpty($node_type
    ->id());
  $this
    ->assertInstanceOf(JsonApiDocumentTopLevel::class, $response
    ->getResponseData());
  $this
    ->assertEquals('test', $response
    ->getResponseData()
    ->getData()
    ->id());
  $this
    ->assertEquals(201, $response
    ->getStatusCode());
}