You are here

public function CreateTest::assertCreateEntityWithoutProperPermissions in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/rest/src/Tests/CreateTest.php \Drupal\rest\Tests\CreateTest::assertCreateEntityWithoutProperPermissions()

Try to create an entity without proper permissions.

Parameters

string $entity_type: The type of the entity that should be created.

string $serialized: The body for the POST request.

2 calls to CreateTest::assertCreateEntityWithoutProperPermissions()
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.

File

core/modules/rest/src/Tests/CreateTest.php, line 456
Contains \Drupal\rest\Tests\CreateTest.

Class

CreateTest
Tests the creation of resources.

Namespace

Drupal\rest\Tests

Code

public function assertCreateEntityWithoutProperPermissions($entity_type, $serialized = NULL) {
  $this
    ->drupalLogout();
  $this
    ->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType);

  // Forbidden Error as response.
  $this
    ->assertResponse(403);
  $this
    ->assertFalse(\Drupal::entityManager()
    ->getStorage($entity_type)
    ->loadMultiple(), 'No entity has been created in the database.');
}