public function EntityResourceTest::testDeleteIndividual in JSON:API 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/Controller/EntityResourceTest.php \Drupal\Tests\jsonapi\Kernel\Controller\EntityResourceTest::testDeleteIndividual()
@covers ::deleteIndividual
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 524
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testDeleteIndividual() {
$node = Node::create([
'type' => 'article',
'title' => 'Lorem ipsum',
]);
$nid = $node
->id();
$node
->save();
Role::load(Role::ANONYMOUS_ID)
->grantPermission('delete own article content')
->save();
$response = $this->entityResource
->deleteIndividual($node);
// As a side effect, the node will also be deleted.
$count = $this->container
->get('entity_type.manager')
->getStorage('node')
->getQuery()
->condition('nid', $nid)
->count()
->execute();
$this
->assertEquals(0, $count);
$this
->assertNull($response
->getResponseData());
$this
->assertEquals(204, $response
->getStatusCode());
}