public function EntityResourceTest::testCreateIndividualDuplicateError in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Kernel/Controller/EntityResourceTest.php \Drupal\Tests\jsonapi\Kernel\Controller\EntityResourceTest::testCreateIndividualDuplicateError()
@covers ::createIndividual
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 467
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testCreateIndividualDuplicateError() {
Role::load(Role::ANONYMOUS_ID)
->grantPermission('create article content')
->save();
$node = Node::create([
'type' => 'article',
'title' => 'Lorem ipsum',
]);
$node
->save();
$node
->enforceIsNew();
$this
->setExpectedException(ConflictHttpException::class, 'Conflict: Entity already exists.');
$entity_resource = $this
->buildEntityResource('node', 'article');
$entity_resource
->createIndividual($node, new Request());
}