class EntityFormDisplayTest
JSON:API integration test for the "EntityFormDisplay" config entity type.
@group jsonapi @group #slow
Hierarchy
- class \Drupal\Tests\jsonapi\Functional\ResourceTestBase uses \Drupal\Tests\jsonapi\Functional\ResourceResponseTestTrait, \Drupal\Tests\content_moderation\Traits\ContentModerationTestTrait, \Drupal\Tests\jsonapi\Traits\GetDocumentFromResponseTrait, \Drupal\Tests\jsonapi\Functional\JsonApiRequestTestTrait
- class \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase extends \Drupal\Tests\jsonapi\Functional\ResourceTestBase
- class \Drupal\Tests\jsonapi\Functional\EntityFormDisplayTest extends \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase
- class \Drupal\Tests\jsonapi\Functional\ConfigEntityResourceTestBase extends \Drupal\Tests\jsonapi\Functional\ResourceTestBase
Expanded class hierarchy of EntityFormDisplayTest
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ EntityFormDisplayTest.php, line 17
Namespace
Drupal\Tests\jsonapi\FunctionalView source
class EntityFormDisplayTest extends ConfigEntityResourceTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'field_ui',
];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'entity_form_display';
/**
* {@inheritdoc}
*/
protected static $resourceTypeName = 'entity_form_display--entity_form_display';
/**
* {@inheritdoc}
*
* @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this->grantPermissionsToTestedRole([
'administer node form display',
]);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
// Create a "Camelids" node type.
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
]);
$camelids->save();
// Create a form display.
$form_display = EntityFormDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'camelids',
'mode' => 'default',
]);
$form_display->save();
return $form_display;
}
/**
* {@inheritdoc}
*/
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/entity_form_display/entity_form_display/' . $this->entity
->uuid())
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl();
return [
'jsonapi' => [
'meta' => [
'links' => [
'self' => [
'href' => 'http://jsonapi.org/format/1.0/',
],
],
],
'version' => '1.0',
],
'links' => [
'self' => [
'href' => $self_url,
],
],
'data' => [
'id' => $this->entity
->uuid(),
'type' => 'entity_form_display--entity_form_display',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'bundle' => 'camelids',
'content' => [
'created' => [
'type' => 'datetime_timestamp',
'weight' => 10,
'region' => 'content',
'settings' => [],
'third_party_settings' => [],
],
'promote' => [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 15,
'region' => 'content',
'third_party_settings' => [],
],
'status' => [
'type' => 'boolean_checkbox',
'weight' => 120,
'region' => 'content',
'settings' => [
'display_label' => TRUE,
],
'third_party_settings' => [],
],
'sticky' => [
'type' => 'boolean_checkbox',
'settings' => [
'display_label' => TRUE,
],
'weight' => 16,
'region' => 'content',
'third_party_settings' => [],
],
'title' => [
'type' => 'string_textfield',
'weight' => -5,
'region' => 'content',
'settings' => [
'size' => 60,
'placeholder' => '',
],
'third_party_settings' => [],
],
'uid' => [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'match_limit' => 10,
'size' => 60,
'placeholder' => '',
],
'region' => 'content',
'third_party_settings' => [],
],
],
'dependencies' => [
'config' => [
'node.type.camelids',
],
],
'hidden' => [],
'langcode' => 'en',
'mode' => 'default',
'status' => NULL,
'targetEntityType' => 'node',
'drupal_internal__id' => 'node.camelids.default',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
return [];
}
/**
* {@inheritdoc}
*/
protected function getExpectedUnauthorizedAccessMessage($method) {
return "The 'administer node form display' permission is required.";
}
/**
* {@inheritdoc}
*/
protected function createAnotherEntity($key) {
NodeType::create([
'name' => 'Llamaids',
'type' => 'llamaids',
])->save();
$entity = EntityFormDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'llamaids',
'mode' => 'default',
]);
$entity->save();
return $entity;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ConfigEntityResourceTestBase::setUp | public | function | Overrides ResourceTestBase::setUp | ||
ConfigEntityResourceTestBase::SKIP_METHODS | constant | A list of test methods to skip. | |||
EntityFormDisplayTest::$defaultTheme | protected | property | |||
EntityFormDisplayTest::$entity | protected | property | Overrides ResourceTestBase::$entity | ||
EntityFormDisplayTest::$entityTypeId | protected static | property | The tested entity type. | Overrides ResourceTestBase::$entityTypeId | |
EntityFormDisplayTest::$modules | protected static | property | Overrides ResourceTestBase::$modules | ||
EntityFormDisplayTest::$resourceTypeName | protected static | property | The name of the tested JSON:API resource type. | Overrides ResourceTestBase::$resourceTypeName | |
EntityFormDisplayTest::createAnotherEntity | protected | function | Creates another entity to be tested. | Overrides ResourceTestBase::createAnotherEntity | |
EntityFormDisplayTest::createEntity | protected | function | Creates the entity to be tested. | Overrides ResourceTestBase::createEntity | |
EntityFormDisplayTest::getExpectedDocument | protected | function | Returns the expected JSON:API document for the entity. | Overrides ResourceTestBase::getExpectedDocument | |
EntityFormDisplayTest::getExpectedUnauthorizedAccessMessage | protected | function | Return the expected error message. | Overrides ResourceTestBase::getExpectedUnauthorizedAccessMessage | |
EntityFormDisplayTest::getPostDocument | protected | function | Returns the JSON:API POST document. | Overrides ResourceTestBase::getPostDocument | |
EntityFormDisplayTest::setUpAuthorization | protected | function | Sets up the necessary authorization. | Overrides ResourceTestBase::setUpAuthorization | |
GetDocumentFromResponseTrait::getDocumentFromResponse | protected | function | Retrieve document from response, with basic validation. | ||
ResourceResponseTestTrait::addOmittedObject | protected static | function | Add the omitted object to the document or merges it if one already exists. | ||
ResourceResponseTestTrait::collectionHasResourceIdentifier | protected static | function | Determines if a given resource exists in a list of resources. | ||
ResourceResponseTestTrait::errorsToOmittedObject | protected static | function | Maps error objects into an omitted object. | ||
ResourceResponseTestTrait::extractLinks | protected static | function | Extracts links from a document using a list of relationship field names. | ||
ResourceResponseTestTrait::getAccessDeniedResponse | protected static | function | Gets a generic forbidden response. | ||
ResourceResponseTestTrait::getEmptyCollectionResponse | protected | function | Gets a generic empty collection response. | ||
ResourceResponseTestTrait::getExpectedIncludedResourceResponse | protected | function | Gets an array of expected ResourceResponses for the given include paths. | ||
ResourceResponseTestTrait::getLinkPaths | protected static | function | Turns a list of relationship field names into an array of link paths. | ||
ResourceResponseTestTrait::getRelatedLink | protected static | function | Creates a related resource link for a given resource identifier and field. | ||
ResourceResponseTestTrait::getRelatedResponses | protected | function | Gets an array of related responses for the given field names. | ||
ResourceResponseTestTrait::getRelationshipLink | protected static | function | Creates a relationship link for a given resource identifier and field. | ||
ResourceResponseTestTrait::getRelationshipResponses | protected | function | Gets an array of relationship responses for the given field names. | ||
ResourceResponseTestTrait::getResourceLink | protected static | function | Creates an individual resource link for a given resource identifier. | ||
ResourceResponseTestTrait::getResourceLinks | protected static | function | Creates individual resource links for a list of resource identifiers. | ||
ResourceResponseTestTrait::getResponses | protected | function | Gets responses from an array of links. | ||
ResourceResponseTestTrait::isResourceIdentifier | protected static | function | Checks if a given array is a resource identifier. | ||
ResourceResponseTestTrait::mergeOmittedObjects | protected static | function | Merges the links of two omitted objects and returns a new omitted object. | ||
ResourceResponseTestTrait::resetOmittedLinkKeys | protected static | function | Resets omitted link keys. | ||
ResourceResponseTestTrait::sortOmittedLinks | protected static | function | Sorts an omitted link object array by href. | ||
ResourceResponseTestTrait::sortResourceCollection | protected static | function | Sorts a collection of resources or resource identifiers. | ||
ResourceResponseTestTrait::toCollectionResourceResponse | protected static | function | Merges individual responses into a collection response. | ||
ResourceResponseTestTrait::toResourceIdentifier | protected static | function | Maps an entity to a resource identifier. | ||
ResourceResponseTestTrait::toResourceResponse | protected static | function | Maps a response object to a JSON:API ResourceResponse. | ||
ResourceResponseTestTrait::toResourceResponses | protected static | function | Maps an array of PSR responses to JSON:API ResourceResponses. | ||
ResourceTestBase::$account | protected | property | The account to use for authentication. | ||
ResourceTestBase::$anonymousUsersCanViewLabels | protected static | property | Whether anonymous users can view labels of this resource type. | 3 | |
ResourceTestBase::$anotherEntity | protected | property | Another entity of the same type used for testing. | ||
ResourceTestBase::$entityStorage | protected | property | The entity storage. | ||
ResourceTestBase::$firstCreatedEntityId | protected static | property | The entity ID for the first created entity in testPost(). | 2 | |
ResourceTestBase::$jsonApiMember | protected static | property | The standard `jsonapi` top-level document member. | ||
ResourceTestBase::$labelFieldName | protected static | property | Specify which field is the 'label' field for testing a POST edge case. | 1 | |
ResourceTestBase::$newRevisionsShouldBeAutomatic | protected static | property | Whether new revisions of updated entities should be created by default. | 2 | |
ResourceTestBase::$patchProtectedFieldNames | protected static | property | The fields that are protected against modification during PATCH requests. | 14 | |
ResourceTestBase::$resourceType | protected | property | The JSON:API resource type for the tested entity type plus bundle. | ||
ResourceTestBase::$resourceTypeIsVersionable | protected static | property | Whether the tested JSON:API resource is versionable. | 7 | |
ResourceTestBase::$secondCreatedEntityId | protected static | property | The entity ID for the second created entity in testPost(). | 2 | |
ResourceTestBase::$serializer | protected | property | The serializer service. | ||
ResourceTestBase::$uniqueFieldNames | protected static | property | Fields that need unique values. | 1 | |
ResourceTestBase::$uuidKey | protected | property | The UUID key. | ||
ResourceTestBase::alterExpectedDocumentForRevision | protected | function | Alters the expected JSON:API document for revisions. | ||
ResourceTestBase::assertResourceErrorResponse | protected | function | Asserts that a resource error response has the given message. | ||
ResourceTestBase::assertResourceResponse | protected | function | Asserts that a resource response has the given status code and body. | ||
ResourceTestBase::assertSameDocument | protected | function | Asserts that an expected document matches the response body. | ||
ResourceTestBase::decorateExpectedResponseForIncludedFields | protected static | function | Decorates the expected response with included data and cache metadata. | ||
ResourceTestBase::decorateResourceIdentifierWithDrupalInternalTargetId | protected static | function | Adds drupal_internal__target_id to the meta of a resource identifier. | ||
ResourceTestBase::doTestDeleteIndividual | protected | function | Tests DELETEing an individual resource, plus edge cases to ensure good DX. | 1 | |
ResourceTestBase::doTestIncluded | protected | function | Tests included resources. | ||
ResourceTestBase::doTestPatchIndividual | protected | function | Tests PATCHing an individual resource, plus edge cases to ensure good DX. | 1 | |
ResourceTestBase::doTestPostIndividual | protected | function | Tests POSTing an individual resource, plus edge cases to ensure good DX. | 1 | |
ResourceTestBase::doTestRelated | protected | function | Performs one round of related route testing. | ||
ResourceTestBase::doTestRelationshipGet | protected | function | Performs one round of relationship route testing. | ||
ResourceTestBase::doTestRelationshipMutation | protected | function | Performs one round of relationship POST, PATCH and DELETE route testing. | 1 | |
ResourceTestBase::doTestSparseFieldSets | protected | function | Tests sparse field sets. | ||
ResourceTestBase::entityAccess | protected static | function | Checks access for the given operation on the given entity. | 3 | |
ResourceTestBase::entityFieldAccess | protected static | function | Checks access for the given field operation on the given entity. | ||
ResourceTestBase::entityLoadUnchanged | protected | function | Loads an entity in the test container, ignoring the static cache. | ||
ResourceTestBase::getAuthenticationRequestOptions | protected | function | Returns Guzzle request options for authentication. | ||
ResourceTestBase::getData | protected | function | Sets up a collection of entities of the same type for testing. | ||
ResourceTestBase::getEditorialPermissions | protected | function | Gets an array of permissions required to view and update any tested entity. | 1 | |
ResourceTestBase::getEntityDuplicate | protected | function | |||
ResourceTestBase::getExpectedCacheContexts | protected | function | The expected cache contexts for the GET/HEAD response of the test entity. | 8 | |
ResourceTestBase::getExpectedCacheTags | protected | function | The expected cache tags for the GET/HEAD response of the test entity. | 5 | |
ResourceTestBase::getExpectedCollectionCacheability | protected static | function | Computes the cacheability for a given entity collection. | 5 | |
ResourceTestBase::getExpectedCollectionResponse | protected | function | Returns a JSON:API collection document for the expected entities. | ||
ResourceTestBase::getExpectedGetIndividualResourceResponse | protected | function | Gets the expected individual ResourceResponse for GET. | ||
ResourceTestBase::getExpectedGetRelationshipDocument | protected | function | Gets an expected document for the given relationship. | ||
ResourceTestBase::getExpectedGetRelationshipDocumentData | protected | function | Gets the expected document data for the given relationship. | 2 | |
ResourceTestBase::getExpectedGetRelationshipResponse | protected | function | Gets an expected ResourceResponse for the given relationship. | ||
ResourceTestBase::getExpectedRelatedResponse | protected | function | Builds an expected related ResourceResponse for the given field. | ||
ResourceTestBase::getExpectedRelatedResponses | protected | function | Builds an array of expected related ResourceResponses, keyed by field name. | ||
ResourceTestBase::getExpectedUnauthorizedAccessCacheability | protected | function | Returns the expected cacheability for an unauthorized response. | 8 | |
ResourceTestBase::getExtraRevisionCacheTags | protected | function | The expected cache tags when checking revision responses. | ||
ResourceTestBase::getIncludePermissions | protected static | function | Authorize the user under test with additional permissions to view includes. | 2 | |
ResourceTestBase::getModifiedEntityForPatchTesting | protected static | function | Clones the given entity and modifies all PATCH-protected fields. | ||
ResourceTestBase::getModifiedEntityForPostTesting | protected | function | Gets the normalized POST entity with random values for its unique fields. | 2 | |
ResourceTestBase::getNestedIncludePaths | protected | function | Gets an array of all nested include paths to be tested. | ||
ResourceTestBase::getPatchDocument | protected | function | Returns the JSON:API PATCH document. | 2 | |
ResourceTestBase::getRelationshipFieldNames | protected | function | Gets a list of public relationship names for the resource type under test. | ||
ResourceTestBase::getSparseFieldSets | protected | function | Returns an array of sparse fields sets to test. | 4 | |
ResourceTestBase::grantIncludedPermissions | protected | function | Grants authorization to view includes. | ||
ResourceTestBase::grantPermissionsToTestedRole | protected | function | Grants permissions to the authenticated role. | ||
ResourceTestBase::isReferenceFieldDefinition | protected static | function | Determines if a given field definition is a reference field. | ||
ResourceTestBase::makeNormalizationInvalid | protected | function | Makes the given JSON:API document invalid. | 1 | |
ResourceTestBase::normalize | protected | function | Generates a JSON:API normalization for the given entity. | ||
ResourceTestBase::recursiveKsort | protected static | function | Recursively sorts an array by key. | ||
ResourceTestBase::removeResourceTypeFromDocument | protected | function | Makes the JSON:API document violate the spec by omitting the resource type. | ||
ResourceTestBase::resaveEntity | protected | function | |||
ResourceTestBase::revokePermissions | protected | function | Ensure the anonymous and authenticated roles have no permissions at all. | ||
ResourceTestBase::revokePermissionsFromTestedRole | protected | function | Revokes permissions from the authenticated role. | ||
ResourceTestBase::setUpFields | protected | function | Sets up additional fields for testing. | ||
ResourceTestBase::setUpRevisionAuthorization | protected | function | Sets up the necessary authorization for handling revisions. | 4 | |
ResourceTestBase::testCollection | public | function | Tests GETting a collection of resources. | ||
ResourceTestBase::testGetIndividual | public | function | Tests GETting an individual resource, plus edge cases to ensure good DX. | 1 | |
ResourceTestBase::testIndividual | public | function | Tests POST/PATCH/DELETE for an individual resource. | 1 | |
ResourceTestBase::testRelated | public | function | Tests GET of the related resource of an individual resource. | 1 | |
ResourceTestBase::testRelationships | public | function | Tests CRUD of individual resource relationship data. | ||
ResourceTestBase::testRevisions | public | function | Tests individual and collection revisions. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.