public function CreateTest::assertCreateEntityInvalidSerialized in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/Tests/CreateTest.php \Drupal\rest\Tests\CreateTest::assertCreateEntityInvalidSerialized()
Send an invalid UUID to trigger the entity validation.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity we want to check that was inserted correctly.
string $entity_type: The type of the entity that should be created.
array $context: Options normalizers/encoders have access to.
4 calls to CreateTest::assertCreateEntityInvalidSerialized()
- CreateTest::testCreateComment in core/
modules/ rest/ src/ Tests/ CreateTest.php - Test comment creation.
- CreateTest::testCreateEntityTest in core/
modules/ rest/ src/ Tests/ CreateTest.php - Tests valid and invalid create requests for 'entity_test' entity type.
- CreateTest::testCreateNode in core/
modules/ rest/ src/ Tests/ CreateTest.php - Tests several valid and invalid create requests for 'node' entity type.
- CreateTest::testCreateUser in core/
modules/ rest/ src/ Tests/ CreateTest.php - Tests several valid and invalid create requests for 'user' entity type.
File
- core/
modules/ rest/ src/ Tests/ CreateTest.php, line 433 - Contains \Drupal\rest\Tests\CreateTest.
Class
- CreateTest
- Tests the creation of resources.
Namespace
Drupal\rest\TestsCode
public function assertCreateEntityInvalidSerialized(EntityInterface $entity, $entity_type, array $context = array()) {
// Add a UUID that is too long.
$entity
->set('uuid', $this
->randomMachineName(129));
$invalid_serialized = $this->serializer
->serialize($entity, $this->defaultFormat, $context);
$response = $this
->httpRequest('entity/' . $entity_type, 'POST', $invalid_serialized, $this->defaultMimeType);
// Unprocessable Entity as response.
$this
->assertResponse(422);
// Verify that the text of the response is correct.
$error = Json::decode($response);
$this
->assertEqual($error['error'], "Unprocessable Entity: validation failed.\nuuid.0.value: <em class=\"placeholder\">UUID</em>: may not be longer than 128 characters.\n");
}