Commit fab76164 authored by alexpott's avatar alexpott
Browse files

Issue #2418559 by Palashvijay4O, chintan4u, rteijeiro: Fix comment formatting...

Issue #2418559 by Palashvijay4O, chintan4u, rteijeiro: Fix comment formatting in /core/modules/rest/src/Tests/CreateTest.php
parent 0c7e1e98
...@@ -100,13 +100,13 @@ public function testCreateWithoutPermission() { ...@@ -100,13 +100,13 @@ public function testCreateWithoutPermission() {
} }
/** /**
* Tests several valid and invalid create requests for 'entity_test' entity type. * Tests valid and invalid create requests for 'entity_test' entity type.
*/ */
public function testCreateEntityTest() { public function testCreateEntityTest() {
$entity_type = 'entity_test'; $entity_type = 'entity_test';
// Enables the REST service for 'entity_test' entity type. // Enables the REST service for 'entity_test' entity type.
$this->enableService('entity:' . $entity_type, 'POST'); $this->enableService('entity:' . $entity_type, 'POST');
// Create two accounts that have the required permissions to create resources. // Create two accounts with the required permissions to create resources.
// The second one has administrative permissions. // The second one has administrative permissions.
$accounts = $this->createAccountPerEntity($entity_type); $accounts = $this->createAccountPerEntity($entity_type);
...@@ -122,7 +122,8 @@ public function testCreateEntityTest() { ...@@ -122,7 +122,8 @@ public function testCreateEntityTest() {
// Create the entity over the REST API. // Create the entity over the REST API.
$this->assertCreateEntityOverRestApi($entity_type, $serialized); $this->assertCreateEntityOverRestApi($entity_type, $serialized);
// Get the entity ID from the location header and try to read it from the database. // Get the entity ID from the location header and try to read it from the
// database.
$this->assertReadEntityIdFromHeaderAndDb($entity_type, $entity, $entity_values); $this->assertReadEntityIdFromHeaderAndDb($entity_type, $entity, $entity_values);
// Try to create an entity with an access protected field. // Try to create an entity with an access protected field.
...@@ -139,7 +140,8 @@ public function testCreateEntityTest() { ...@@ -139,7 +140,8 @@ public function testCreateEntityTest() {
$serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]); $serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]);
$this->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType); $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType);
// The value selected is not a valid choice because the format must be 'plain_txt'. // The value selected is not a valid choice because the format must be
// 'plain_txt'.
$this->assertResponse(422); $this->assertResponse(422);
$this->assertFalse(EntityTest::loadMultiple(), 'No entity has been created in the database.'); $this->assertFalse(EntityTest::loadMultiple(), 'No entity has been created in the database.');
...@@ -153,7 +155,8 @@ public function testCreateEntityTest() { ...@@ -153,7 +155,8 @@ public function testCreateEntityTest() {
// Try to send no data at all, which does not make sense on POST requests. // Try to send no data at all, which does not make sense on POST requests.
$this->assertCreateEntityNoData($entity_type); $this->assertCreateEntityNoData($entity_type);
// Try to send invalid data to trigger the entity validation constraints. Send a UUID that is too long. // Try to send invalid data to trigger the entity validation constraints.
// Send a UUID that is too long.
$this->assertCreateEntityInvalidSerialized($entity, $entity_type); $this->assertCreateEntityInvalidSerialized($entity, $entity_type);
// Try to create an entity without proper permissions. // Try to create an entity without proper permissions.
...@@ -170,8 +173,8 @@ public function testCreateNode() { ...@@ -170,8 +173,8 @@ public function testCreateNode() {
$entity_type = 'node'; $entity_type = 'node';
// Enables the REST service for 'node' entity type. // Enables the REST service for 'node' entity type.
$this->enableService('entity:' . $entity_type, 'POST'); $this->enableService('entity:' . $entity_type, 'POST');
// Create two accounts that have the required permissions to create resources. // Create two accounts that have the required permissions to create
// The second one has administrative permissions. // resources. The second one has administrative permissions.
$accounts = $this->createAccountPerEntity($entity_type); $accounts = $this->createAccountPerEntity($entity_type);
// Verify create requests per user. // Verify create requests per user.
...@@ -181,7 +184,8 @@ public function testCreateNode() { ...@@ -181,7 +184,8 @@ public function testCreateNode() {
$entity_values = $this->entityValues($entity_type); $entity_values = $this->entityValues($entity_type);
$entity = Node::create($entity_values); $entity = Node::create($entity_values);
// Verify that user cannot create content when trying to write to fields where it is not possible. // Verify that user cannot create content when trying to write to fields
// where it is not possible.
if (!$account->hasPermission('administer nodes')) { if (!$account->hasPermission('administer nodes')) {
$serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]); $serialized = $this->serializer->serialize($entity, $this->defaultFormat, ['account' => $account]);
$this->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType); $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType);
...@@ -200,7 +204,8 @@ public function testCreateNode() { ...@@ -200,7 +204,8 @@ public function testCreateNode() {
// Create the entity over the REST API. // Create the entity over the REST API.
$this->assertCreateEntityOverRestApi($entity_type, $serialized); $this->assertCreateEntityOverRestApi($entity_type, $serialized);
// Get the new entity ID from the location header and try to read it from the database. // Get the new entity ID from the location header and try to read it from
// the database.
$this->assertReadEntityIdFromHeaderAndDb($entity_type, $entity, $entity_values); $this->assertReadEntityIdFromHeaderAndDb($entity_type, $entity, $entity_values);
// Try to send invalid data that cannot be correctly deserialized. // Try to send invalid data that cannot be correctly deserialized.
...@@ -226,8 +231,8 @@ public function testCreateUser() { ...@@ -226,8 +231,8 @@ public function testCreateUser() {
$entity_type = 'user'; $entity_type = 'user';
// Enables the REST service for 'user' entity type. // Enables the REST service for 'user' entity type.
$this->enableService('entity:' . $entity_type, 'POST'); $this->enableService('entity:' . $entity_type, 'POST');
// Create two accounts that have the required permissions to create resources. // Create two accounts that have the required permissions to create
// The second one has administrative permissions. // resources. The second one has administrative permissions.
$accounts = $this->createAccountPerEntity($entity_type); $accounts = $this->createAccountPerEntity($entity_type);
foreach ($accounts as $key => $account) { foreach ($accounts as $key => $account) {
...@@ -251,7 +256,8 @@ public function testCreateUser() { ...@@ -251,7 +256,8 @@ public function testCreateUser() {
// Create the entity over the REST API. // Create the entity over the REST API.
$this->assertCreateEntityOverRestApi($entity_type, $serialized); $this->assertCreateEntityOverRestApi($entity_type, $serialized);
// Get the new entity ID from the location header and try to read it from the database. // Get the new entity ID from the location header and try to read it from
// the database.
$this->assertReadEntityIdFromHeaderAndDb($entity_type, $entity, $entity_values); $this->assertReadEntityIdFromHeaderAndDb($entity_type, $entity, $entity_values);
// Try to send invalid data that cannot be correctly deserialized. // Try to send invalid data that cannot be correctly deserialized.
...@@ -268,8 +274,8 @@ public function testCreateUser() { ...@@ -268,8 +274,8 @@ public function testCreateUser() {
} }
/** /**
* Creates user accounts that have the required permissions to create resources via the REST API. * Creates user accounts that have the required permissions to create
* The second one has administrative permissions. * resources via the REST API. The second one has administrative permissions.
* *
* @param string $entity_type * @param string $entity_type
* Entity type needed to apply user permissions. * Entity type needed to apply user permissions.
...@@ -307,7 +313,8 @@ public function assertCreateEntityOverRestApi($entity_type, $serialized = NULL) ...@@ -307,7 +313,8 @@ public function assertCreateEntityOverRestApi($entity_type, $serialized = NULL)
} }
/** /**
* Get the new entity ID from the location header and try to read it from the database. * Gets the new entity ID from the location header and tries to read it from
* the database.
* *
* @param string $entity_type * @param string $entity_type
* Entity type we need to load the entity from DB. * Entity type we need to load the entity from DB.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment