public function EntityResourceTest::testCreateIndividualWithMissingRequiredData 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::testCreateIndividualWithMissingRequiredData()
@covers ::createIndividual
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 432
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testCreateIndividualWithMissingRequiredData() {
Role::load(Role::ANONYMOUS_ID)
->grantPermission('create article content')
->save();
$this
->setExpectedException(HttpException::class, 'Unprocessable Entity: validation failed.');
$resource_type = new ResourceType('node', 'article', Node::class);
$payload = Json::encode([
'data' => [
'type' => 'article',
],
]);
$this->entityResource
->createIndividual($resource_type, Request::create('/jsonapi/node/article', 'POST', [], [], [], [], $payload));
}