public function EntityResourceTest::testDeleteIndividualConfig in JSON:API 8
@covers ::deleteIndividual
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 647
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testDeleteIndividualConfig() {
$node_type = NodeType::create([
'type' => 'test',
'name' => 'Test Type',
'description' => 'Lorem ipsum',
]);
$id = $node_type
->id();
$node_type
->save();
Role::load(Role::ANONYMOUS_ID)
->grantPermission('administer content types')
->save();
$entity_resource = $this
->buildEntityResource('node', 'article');
$response = $entity_resource
->deleteIndividual($node_type, new Request());
// As a side effect, the node will also be deleted.
$count = $this->container
->get('entity_type.manager')
->getStorage('node_type')
->getQuery()
->condition('type', $id)
->count()
->execute();
$this
->assertEquals(0, $count);
$this
->assertNull($response
->getResponseData());
$this
->assertEquals(204, $response
->getStatusCode());
}