class JsonApiDocumentTopLevelNormalizerTest in JSON:API 8.2
Same name in this branch
- 8.2 tests/src/Unit/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Unit\Normalizer\JsonApiDocumentTopLevelNormalizerTest
- 8.2 tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest
Same name and namespace in other branches
- 8 tests/src/Kernel/Normalizer/JsonApiDocumentTopLevelNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer @group jsonapi @group legacy
@internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses AssertContentTrait, AssertLegacyTrait, AssertHelperTrait, ConfigTestTrait, PhpunitCompatibilityTrait, RandomGeneratorTrait, TestRequirementsTrait
- class \Drupal\Tests\jsonapi\Kernel\JsonapiKernelTestBase
- class \Drupal\Tests\jsonapi\Kernel\Normalizer\JsonApiDocumentTopLevelNormalizerTest uses ImageFieldCreationTrait
- class \Drupal\Tests\jsonapi\Kernel\JsonapiKernelTestBase
Expanded class hierarchy of JsonApiDocumentTopLevelNormalizerTest
File
- tests/
src/ Kernel/ Normalizer/ JsonApiDocumentTopLevelNormalizerTest.php, line 38
Namespace
Drupal\Tests\jsonapi\Kernel\NormalizerView source
class JsonApiDocumentTopLevelNormalizerTest extends JsonapiKernelTestBase {
use ImageFieldCreationTrait;
/**
* {@inheritdoc}
*/
public static $modules = [
'jsonapi',
'field',
'node',
'serialization',
'system',
'taxonomy',
'text',
'filter',
'user',
'file',
'image',
'jsonapi_test_normalizers_kernel',
];
/**
* A node to normalize.
*
* @var \Drupal\Core\Entity\EntityInterface
*/
protected $node;
/**
* A user to normalize.
*
* @var \Drupal\user\Entity\User
*/
protected $user;
/**
* The include resolver.
*
* @var \Drupal\jsonapi\IncludeResolver
*/
protected $includeResolver;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add the entity schemas.
$this
->installEntitySchema('node');
$this
->installEntitySchema('user');
$this
->installEntitySchema('taxonomy_term');
$this
->installEntitySchema('file');
// Add the additional table schemas.
$this
->installSchema('system', [
'sequences',
]);
$this
->installSchema('node', [
'node_access',
]);
$this
->installSchema('user', [
'users_data',
]);
$this
->installSchema('file', [
'file_usage',
]);
$type = NodeType::create([
'type' => 'article',
]);
$type
->save();
$this
->createEntityReferenceField('node', 'article', 'field_tags', 'Tags', 'taxonomy_term', 'default', [
'target_bundles' => [
'tags',
],
], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this
->createTextField('node', 'article', 'body', 'Body');
$this
->createImageField('field_image', 'article');
$this->user = User::create([
'name' => 'user1',
'mail' => 'user@localhost',
]);
$this->user2 = User::create([
'name' => 'user2',
'mail' => 'user2@localhost',
]);
$this->user
->save();
$this->user2
->save();
$this->vocabulary = Vocabulary::create([
'name' => 'Tags',
'vid' => 'tags',
]);
$this->vocabulary
->save();
$this->term1 = Term::create([
'name' => 'term1',
'vid' => $this->vocabulary
->id(),
]);
$this->term2 = Term::create([
'name' => 'term2',
'vid' => $this->vocabulary
->id(),
]);
$this->term1
->save();
$this->term2
->save();
$this->file = File::create([
'uri' => 'public://example.png',
'filename' => 'example.png',
]);
$this->file
->save();
$this->node = Node::create([
'title' => 'dummy_title',
'type' => 'article',
'uid' => 1,
'body' => [
'format' => 'plain_text',
'value' => $this
->randomStringValidate(42),
],
'field_tags' => [
[
'target_id' => $this->term1
->id(),
],
[
'target_id' => $this->term2
->id(),
],
],
'field_image' => [
[
'target_id' => $this->file
->id(),
'alt' => 'test alt',
'title' => 'test title',
'width' => 10,
'height' => 11,
],
],
]);
$this->node
->save();
$this->nodeType = NodeType::load('article');
Role::create([
'id' => RoleInterface::ANONYMOUS_ID,
'permissions' => [
'access content',
],
])
->save();
$this->includeResolver = $this->container
->get('jsonapi.include_resolver');
}
/**
* {@inheritdoc}
*/
public function tearDown() {
if ($this->node) {
$this->node
->delete();
}
if ($this->term1) {
$this->term1
->delete();
}
if ($this->term2) {
$this->term2
->delete();
}
if ($this->vocabulary) {
$this->vocabulary
->delete();
}
if ($this->user) {
$this->user
->delete();
}
if ($this->user2) {
$this->user2
->delete();
}
}
/**
* @covers ::normalize
*/
public function testNormalize() {
list($request, $resource_type) = $this
->generateProphecies('node', 'article');
$resource_object = ResourceObject::createFromEntity($resource_type, $this->node);
$includes = $this->includeResolver
->resolve($resource_object, 'uid,field_tags,field_image');
$jsonapi_doc_object = $this
->getNormalizer()
->normalize(new JsonApiDocumentTopLevel(new ResourceObjectData([
$resource_object,
], 1), $includes, new LinkCollection([])), 'api_json', [
'resource_type' => $resource_type,
'account' => NULL,
'sparse_fieldset' => [
'node--article' => [
'title',
'node_type',
'uid',
'field_tags',
'field_image',
],
'user--user' => [
'name',
],
],
'include' => [
'uid',
'field_tags',
'field_image',
],
]);
$normalized = $jsonapi_doc_object
->getNormalization();
// @see http://jsonapi.org/format/#document-jsonapi-object
$this
->assertEquals($normalized['jsonapi']['version'], '1.0');
$this
->assertEquals($normalized['jsonapi']['meta']['links']['self']['href'], 'http://jsonapi.org/format/1.0/');
$this
->assertSame($normalized['data']['attributes']['title'], 'dummy_title');
$this
->assertEquals($normalized['data']['id'], $this->node
->uuid());
$this
->assertSame([
'data' => [
'type' => 'node_type--node_type',
'id' => NodeType::load('article')
->uuid(),
],
'links' => [
'self' => [
'href' => Url::fromUri('internal:/jsonapi/node/article/' . $this->node
->uuid() . '/relationships/node_type', [
'query' => [
'resourceVersion' => 'id:' . $this->node
->getRevisionId(),
],
])
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl(),
],
'related' => [
'href' => Url::fromUri('internal:/jsonapi/node/article/' . $this->node
->uuid() . '/node_type', [
'query' => [
'resourceVersion' => 'id:' . $this->node
->getRevisionId(),
],
])
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl(),
],
],
], $normalized['data']['relationships']['node_type']);
$this
->assertTrue(!isset($normalized['data']['attributes']['created']));
$this
->assertEquals([
'alt' => 'test alt',
'title' => 'test title',
'width' => 10,
'height' => 11,
], $normalized['data']['relationships']['field_image']['data']['meta']);
$this
->assertSame('node--article', $normalized['data']['type']);
$this
->assertEquals([
'data' => [
'type' => 'user--user',
'id' => $this->user
->uuid(),
],
'links' => [
'self' => [
'href' => Url::fromUri('internal:/jsonapi/node/article/' . $this->node
->uuid() . '/relationships/uid', [
'query' => [
'resourceVersion' => 'id:' . $this->node
->getRevisionId(),
],
])
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl(),
],
'related' => [
'href' => Url::fromUri('internal:/jsonapi/node/article/' . $this->node
->uuid() . '/uid', [
'query' => [
'resourceVersion' => 'id:' . $this->node
->getRevisionId(),
],
])
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl(),
],
],
], $normalized['data']['relationships']['uid']);
$this
->assertTrue(empty($normalized['meta']['omitted']));
$this
->assertSame($this->user
->uuid(), $normalized['included'][0]['id']);
$this
->assertSame('user--user', $normalized['included'][0]['type']);
$this
->assertSame('user1', $normalized['included'][0]['attributes']['name']);
$this
->assertCount(1, $normalized['included'][0]['attributes']);
$this
->assertSame($this->term1
->uuid(), $normalized['included'][1]['id']);
$this
->assertSame('taxonomy_term--tags', $normalized['included'][1]['type']);
$this
->assertSame($this->term1
->label(), $normalized['included'][1]['attributes']['name']);
$this
->assertCount(floatval(\Drupal::VERSION) >= 8.6 ? floatval(\Drupal::VERSION) >= 8.699999999999999 ? 12 : 8 : 7, $normalized['included'][1]['attributes']);
$this
->assertTrue(!isset($normalized['included'][1]['attributes']['created']));
// Make sure that the cache tags for the includes and the requested entities
// are bubbling as expected.
$this
->assertArraySubset([
'file:1',
'node:1',
'taxonomy_term:1',
'taxonomy_term:2',
'user:1',
], $jsonapi_doc_object
->getCacheTags());
$this
->assertSame(Cache::PERMANENT, $jsonapi_doc_object
->getCacheMaxAge());
}
/**
* @covers ::normalize
*/
public function testNormalizeRelated() {
$this
->markTestIncomplete('This fails and should be fixed by https://www.drupal.org/project/jsonapi/issues/2922121');
list($request, $resource_type) = $this
->generateProphecies('node', 'article', 'uid');
$request->query = new ParameterBag([
'fields' => [
'user--user' => 'name,roles',
],
'include' => 'roles',
]);
$document_wrapper = $this
->prophesize(JsonApiDocumentTopLevel::class);
$author = $this->node
->get('uid')->entity;
$document_wrapper
->getData()
->willReturn($author);
$jsonapi_doc_object = $this
->getNormalizer()
->normalize($document_wrapper
->reveal(), 'api_json', [
'resource_type' => $resource_type,
'account' => NULL,
]);
$normalized = $jsonapi_doc_object
->getNormalization();
$this
->assertSame($normalized['data']['attributes']['name'], 'user1');
$this
->assertEquals($normalized['data']['id'], User::load(1)
->uuid());
$this
->assertEquals($normalized['data']['type'], 'user--user');
// Make sure that the cache tags for the includes and the requested entities
// are bubbling as expected.
$this
->assertSame([
'user:1',
], $jsonapi_doc_object
->getCacheTags());
$this
->assertSame(Cache::PERMANENT, $jsonapi_doc_object
->getCacheMaxAge());
}
/**
* @covers ::normalize
*/
public function testNormalizeUuid() {
list($request, $resource_type) = $this
->generateProphecies('node', 'article', 'uuid');
$resource_object = ResourceObject::createFromEntity($resource_type, $this->node);
$include_param = 'uid,field_tags';
$includes = $this->includeResolver
->resolve($resource_object, $include_param);
$document_wrapper = new JsonApiDocumentTopLevel(new ResourceObjectData([
$resource_object,
], 1), $includes, new LinkCollection([]));
$request->query = new ParameterBag([
'fields' => [
'node--article' => 'title,node_type,uid,field_tags',
'user--user' => 'name',
],
'include' => $include_param,
]);
$jsonapi_doc_object = $this
->getNormalizer()
->normalize($document_wrapper, 'api_json', [
'resource_type' => $resource_type,
'account' => NULL,
'include' => [
'uid',
'field_tags',
],
]);
$normalized = $jsonapi_doc_object
->getNormalization();
$this
->assertStringMatchesFormat($this->node
->uuid(), $normalized['data']['id']);
$this
->assertEquals($this->node->type->entity
->uuid(), $normalized['data']['relationships']['node_type']['data']['id']);
$this
->assertEquals($this->user
->uuid(), $normalized['data']['relationships']['uid']['data']['id']);
$this
->assertFalse(empty($normalized['included'][0]['id']));
$this
->assertTrue(empty($normalized['meta']['omitted']));
$this
->assertEquals($this->user
->uuid(), $normalized['included'][0]['id']);
$this
->assertCount(1, $normalized['included'][0]['attributes']);
$this
->assertCount(floatval(\Drupal::VERSION) >= 8.6 ? floatval(\Drupal::VERSION) >= 8.699999999999999 ? 12 : 8 : 7, $normalized['included'][1]['attributes']);
// Make sure that the cache tags for the includes and the requested entities
// are bubbling as expected.
$this
->assertArraySubset([
'node:1',
'taxonomy_term:1',
'taxonomy_term:2',
'user:1',
], $jsonapi_doc_object
->getCacheTags());
}
/**
* @covers ::normalize
*/
public function testNormalizeException() {
$normalized = $this->container
->get('jsonapi.serializer')
->normalize(new JsonApiDocumentTopLevel(new ErrorCollection([
new BadRequestHttpException('Lorem'),
]), new NullIncludedData(), new LinkCollection([])), 'api_json', [])
->getNormalization();
$this
->assertNotEmpty($normalized['errors']);
$this
->assertArrayNotHasKey('data', $normalized);
$this
->assertEquals(400, $normalized['errors'][0]['status']);
$this
->assertEquals('Lorem', $normalized['errors'][0]['detail']);
$this
->assertEquals([
'info' => [
'href' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1',
],
'via' => [
'href' => 'http://localhost/',
],
], $normalized['errors'][0]['links']);
}
/**
* @covers ::normalize
*/
public function testNormalizeConfig() {
list($request, $resource_type) = $this
->generateProphecies('node_type', 'node_type', 'id');
$resource_object = ResourceObject::createFromEntity($resource_type, $this->nodeType);
$document_wrapper = new JsonApiDocumentTopLevel(new ResourceObjectData([
$resource_object,
], 1), new NullIncludedData(), new LinkCollection([]));
$jsonapi_doc_object = $this
->getNormalizer()
->normalize($document_wrapper, 'api_json', [
'resource_type' => $resource_type,
'account' => NULL,
'sparse_fieldset' => [
'node_type--node_type' => [
'description',
'display_submitted',
],
],
]);
$normalized = $jsonapi_doc_object
->getNormalization();
$this
->assertSame([
'description',
'display_submitted',
], array_keys($normalized['data']['attributes']));
$this
->assertSame($normalized['data']['id'], NodeType::load('article')
->uuid());
$this
->assertSame($normalized['data']['type'], 'node_type--node_type');
// Make sure that the cache tags for the includes and the requested entities
// are bubbling as expected.
$this
->assertSame([
'config:node.type.article',
], $jsonapi_doc_object
->getCacheTags());
}
/**
* Try to POST a node and check if it exists afterwards.
*
* @covers ::denormalize
*/
public function testDenormalize() {
$payload = '{"data":{"type":"article","attributes":{"title":"Testing article"}}}';
list($request, $resource_type) = $this
->generateProphecies('node', 'article', 'id');
$node = $this
->getNormalizer()
->denormalize(Json::decode($payload), NULL, 'api_json', [
'resource_type' => $resource_type,
]);
$this
->assertInstanceOf(Node::class, $node);
$this
->assertSame('Testing article', $node
->getTitle());
}
/**
* Try to POST a node and check if it exists afterwards.
*
* @covers ::denormalize
*/
public function testDenormalizeUuid() {
$configurations = [
// Good data.
[
[
[
$this->term2
->uuid(),
$this->term1
->uuid(),
],
$this->user2
->uuid(),
],
[
[
$this->term2
->id(),
$this->term1
->id(),
],
$this->user2
->id(),
],
],
// Good data, without any tags.
[
[
[],
$this->user2
->uuid(),
],
[
[],
$this->user2
->id(),
],
],
// Bad data in first tag.
[
[
[
'invalid-uuid',
$this->term1
->uuid(),
],
$this->user2
->uuid(),
],
[
[
$this->term1
->id(),
],
$this->user2
->id(),
],
'taxonomy_term--tags:invalid-uuid',
],
// Bad data in user and first tag.
[
[
[
'invalid-uuid',
$this->term1
->uuid(),
],
'also-invalid-uuid',
],
[
[
$this->term1
->id(),
],
NULL,
],
'user--user:also-invalid-uuid',
],
];
foreach ($configurations as $configuration) {
list($payload_data, $expected) = $this
->denormalizeUuidProviderBuilder($configuration);
$payload = Json::encode($payload_data);
list($request, $resource_type) = $this
->generateProphecies('node', 'article');
$this->container
->get('request_stack')
->push($request);
try {
$node = $this
->getNormalizer()
->denormalize(Json::decode($payload), NULL, 'api_json', [
'resource_type' => $resource_type,
]);
} catch (NotFoundHttpException $e) {
$non_existing_resource_identifier = $configuration[2];
$this
->assertEquals("The resource identified by `{$non_existing_resource_identifier}` (given as a relationship item) could not be found.", $e
->getMessage());
continue;
}
/* @var \Drupal\node\Entity\Node $node */
$this
->assertInstanceOf(Node::class, $node);
$this
->assertSame('Testing article', $node
->getTitle());
if (!empty($expected['user_id'])) {
$owner = $node
->getOwner();
$this
->assertEquals($expected['user_id'], $owner
->id());
}
$tags = $node
->get('field_tags')
->getValue();
if (!empty($expected['tag_ids'][0])) {
$this
->assertEquals($expected['tag_ids'][0], $tags[0]['target_id']);
}
else {
$this
->assertArrayNotHasKey(0, $tags);
}
if (!empty($expected['tag_ids'][1])) {
$this
->assertEquals($expected['tag_ids'][1], $tags[1]['target_id']);
}
else {
$this
->assertArrayNotHasKey(1, $tags);
}
}
}
/**
* Tests denormalization for related resources with missing or invalid types.
*/
public function testDenormalizeInvalidTypeAndNoType() {
$payload_data = [
'data' => [
'type' => 'node--article',
'attributes' => [
'title' => 'Testing article',
'id' => '33095485-70D2-4E51-A309-535CC5BC0115',
],
'relationships' => [
'uid' => [
'data' => [
'type' => 'user--user',
'id' => $this->user2
->uuid(),
],
],
'field_tags' => [
'data' => [
[
'type' => 'foobar',
'id' => $this->term1
->uuid(),
],
],
],
],
],
];
// Test relationship member with invalid type.
$payload = Json::encode($payload_data);
list($request, $resource_type) = $this
->generateProphecies('node', 'article');
$this->container
->get('request_stack')
->push($request);
try {
$this
->getNormalizer()
->denormalize(Json::decode($payload), NULL, 'api_json', [
'resource_type' => $resource_type,
]);
$this
->fail('No assertion thrown for invalid type');
} catch (BadRequestHttpException $e) {
$this
->assertEquals("Invalid type specified for related resource: 'foobar'", $e
->getMessage());
}
// Test relationship member with no type.
unset($payload_data['data']['relationships']['field_tags']['data'][0]['type']);
$payload = Json::encode($payload_data);
list($request, $resource_type) = $this
->generateProphecies('node', 'article');
$this->container
->get('request_stack')
->push($request);
try {
$this->container
->get('jsonapi_test_normalizers_kernel.jsonapi_document_toplevel')
->denormalize(Json::decode($payload), NULL, 'api_json', [
'resource_type' => $resource_type,
]);
$this
->fail('No assertion thrown for missing type');
} catch (BadRequestHttpException $e) {
$this
->assertEquals("No type specified for related resource", $e
->getMessage());
}
}
/**
* We cannot use a PHPUnit data provider because our data depends on $this.
*
* @param array $options
* Options for how to construct test data.
*
* @return array
* The test data.
*/
protected function denormalizeUuidProviderBuilder(array $options) {
list($input, $expected) = $options;
list($input_tag_uuids, $input_user_uuid) = $input;
list($expected_tag_ids, $expected_user_id) = $expected;
$node = [
[
'data' => [
'type' => 'node--article',
'attributes' => [
'title' => 'Testing article',
],
'relationships' => [
'uid' => [
'data' => [
'type' => 'user--user',
'id' => $input_user_uuid,
],
],
'field_tags' => [
'data' => [],
],
],
],
],
[
'tag_ids' => $expected_tag_ids,
'user_id' => $expected_user_id,
],
];
if (isset($input_tag_uuids[0])) {
$node[0]['data']['relationships']['field_tags']['data'][0] = [
'type' => 'taxonomy_term--tags',
'id' => $input_tag_uuids[0],
];
}
if (isset($input_tag_uuids[1])) {
$node[0]['data']['relationships']['field_tags']['data'][1] = [
'type' => 'taxonomy_term--tags',
'id' => $input_tag_uuids[1],
];
}
return $node;
}
/**
* Ensure that cacheability metadata is properly added.
*
* @param \Drupal\Core\Cache\CacheableMetadata $expected_metadata
* The expected cacheable metadata.
* @param array|null $fields
* Fields to include in the response, keyed by resource type.
* @param array|null $includes
* Resources paths to include in the response.
*
* @dataProvider testCacheableMetadataProvider
*/
public function testCacheableMetadata(CacheableMetadata $expected_metadata, $fields = NULL, $includes = NULL) {
list($request, $resource_type) = $this
->generateProphecies('node', 'article');
$resource_object = ResourceObject::createFromEntity($resource_type, $this->node);
$context = [
'resource_type' => $resource_type,
'account' => NULL,
];
$jsonapi_doc_object = $this
->getNormalizer()
->normalize(new JsonApiDocumentTopLevel(new ResourceObjectData([
$resource_object,
], 1), new NullIncludedData(), new LinkCollection([])), 'api_json', $context);
$this
->assertArraySubset($expected_metadata
->getCacheTags(), $jsonapi_doc_object
->getCacheTags());
$this
->assertArraySubset($expected_metadata
->getCacheContexts(), $jsonapi_doc_object
->getCacheContexts());
$this
->assertSame($expected_metadata
->getCacheMaxAge(), $jsonapi_doc_object
->getCacheMaxAge());
}
/**
* Provides test cases for asserting cacheable metadata behavior.
*/
public function testCacheableMetadataProvider() {
$cacheable_metadata = function ($metadata) {
return CacheableMetadata::createFromRenderArray([
'#cache' => $metadata,
]);
};
return [
[
$cacheable_metadata([
'contexts' => [
'languages:language_interface',
],
]),
[
'node--article' => 'body',
],
],
];
}
/**
* Decorates a request with sparse fieldsets and includes.
*/
protected function decorateRequest(Request $request, array $fields = NULL, array $includes = NULL) {
$parameters = new ParameterBag();
$parameters
->add($fields ? [
'fields' => $fields,
] : []);
$parameters
->add($includes ? [
'include' => $includes,
] : []);
$request->query = $parameters;
return $request;
}
/**
* Helper to load the normalizer.
*/
protected function getNormalizer() {
$normalizer_service = $this->container
->get('jsonapi_test_normalizers_kernel.jsonapi_document_toplevel');
// Simulate what happens when this normalizer service is used via the
// serializer service, as it is meant to be used.
$normalizer_service
->setSerializer($this->container
->get('jsonapi.serializer'));
return $normalizer_service;
}
/**
* Generates the prophecies for the mocked entity request.
*
* @param string $entity_type_id
* The ID of the entity type. Ex: node.
* @param string $bundle
* The bundle. Ex: article.
*
* @return array
* A numeric array containing the request and the ResourceType.
*
* @throws \Exception
*/
protected function generateProphecies($entity_type_id, $bundle) {
$resource_type = $this->container
->get('jsonapi.resource_type.repository')
->get($entity_type_id, $bundle);
return [
new Request(),
$resource_type,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertContentTrait:: |
protected | property | The current raw content. | |
AssertContentTrait:: |
protected | property | The drupalSettings value from the current raw $content. | |
AssertContentTrait:: |
protected | property | The XML structure parsed from the current raw $content. | 1 |
AssertContentTrait:: |
protected | property | The plain-text content of raw $content (text nodes). | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page by the given XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a field exists in the current page with a given Xpath result. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is found. | |
AssertContentTrait:: |
protected | function | Asserts that each HTML ID is used for just a single element. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS NOT found escaped on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name or ID. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given ID and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist with the given name and value. | |
AssertContentTrait:: |
protected | function | Asserts that a field does not exist or its value does not match, by XPath. | |
AssertContentTrait:: |
protected | function | Asserts that a checkbox field in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Passes if a link with the specified label is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href (part) is not found. | |
AssertContentTrait:: |
protected | function | Passes if a link containing a given href is not found in the main region. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page does not exist. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is not checked. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) does not contains the text. | |
AssertContentTrait:: |
protected | function | Pass if the page title is not the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option with the visible text exists. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page is checked. | |
AssertContentTrait:: |
protected | function | Asserts that a select option in the current page exists. | |
AssertContentTrait:: |
protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |
AssertContentTrait:: |
protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |
AssertContentTrait:: |
protected | function | Passes if the page (with HTML stripped) contains the text. | |
AssertContentTrait:: |
protected | function | Helper for assertText and assertNoText. | |
AssertContentTrait:: |
protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | |
AssertContentTrait:: |
protected | function | Asserts themed output. | |
AssertContentTrait:: |
protected | function | Pass if the page title is the given string. | |
AssertContentTrait:: |
protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | |
AssertContentTrait:: |
protected | function | Helper for assertUniqueText and assertNoUniqueText. | |
AssertContentTrait:: |
protected | function | Builds an XPath query. | |
AssertContentTrait:: |
protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |
AssertContentTrait:: |
protected | function | Searches elements using a CSS selector in the raw content. | |
AssertContentTrait:: |
protected | function | Get all option elements, including nested options, in a select. | |
AssertContentTrait:: |
protected | function | Gets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Gets the current raw content. | |
AssertContentTrait:: |
protected | function | Get the selected value from a select field. | |
AssertContentTrait:: |
protected | function | Retrieves the plain-text content from the current raw content. | |
AssertContentTrait:: |
protected | function | Get the current URL from the cURL handler. | 1 |
AssertContentTrait:: |
protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |
AssertContentTrait:: |
protected | function | Removes all white-space between HTML tags from the raw content. | |
AssertContentTrait:: |
protected | function | Sets the value of drupalSettings for the currently-loaded page. | |
AssertContentTrait:: |
protected | function | Sets the raw content (e.g. HTML). | |
AssertContentTrait:: |
protected | function | Performs an xpath search on the contents of the internal browser. | |
AssertHelperTrait:: |
protected static | function | Casts MarkupInterface objects into strings. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead. | |
AssertLegacyTrait:: |
protected | function | Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead. | |
AssertLegacyTrait:: |
protected | function | ||
ConfigTestTrait:: |
protected | function | Returns a ConfigImporter object to import test configuration. | |
ConfigTestTrait:: |
protected | function | Copies configuration objects from source storage to target storage. | |
ImageFieldCreationTrait:: |
protected | function | Create a new image field. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | property | The include resolver. | |
JsonApiDocumentTopLevelNormalizerTest:: |
public static | property |
Modules to enable. Overrides JsonapiKernelTestBase:: |
|
JsonApiDocumentTopLevelNormalizerTest:: |
protected | property | A node to normalize. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | property | A user to normalize. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | function | Decorates a request with sparse fieldsets and includes. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | function | We cannot use a PHPUnit data provider because our data depends on $this. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | function | Generates the prophecies for the mocked entity request. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | function | Helper to load the normalizer. | |
JsonApiDocumentTopLevelNormalizerTest:: |
protected | function |
Overrides KernelTestBase:: |
|
JsonApiDocumentTopLevelNormalizerTest:: |
public | function |
Overrides KernelTestBase:: |
|
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | Ensure that cacheability metadata is properly added. | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | Provides test cases for asserting cacheable metadata behavior. | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | Try to POST a node and check if it exists afterwards. | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | Tests denormalization for related resources with missing or invalid types. | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | Try to POST a node and check if it exists afterwards. | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | @covers ::normalize | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | @covers ::normalize | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | @covers ::normalize | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | @covers ::normalize | |
JsonApiDocumentTopLevelNormalizerTest:: |
public | function | @covers ::normalize | |
JsonapiKernelTestBase:: |
protected | function | Creates a field of an entity reference field storage on the bundle. | |
JsonapiKernelTestBase:: |
protected | function | Creates a field of an entity reference field storage on the bundle. | |
KernelTestBase:: |
protected | property | Back up and restore any global variables that may be changed by tests. | |
KernelTestBase:: |
protected | property | Back up and restore static class properties that may be changed by tests. | |
KernelTestBase:: |
protected | property | Contains a few static class properties for performance. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | @todo Move into Config test base class. | 7 |
KernelTestBase:: |
protected static | property | An array of config object names that are excluded from schema checking. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Do not forward any global state from the parent process to the processes that run the actual tests. | |
KernelTestBase:: |
protected | property | The app root. | |
KernelTestBase:: |
protected | property | Kernel tests are run in separate processes because they allow autoloading of code from extensions. Running the test in a separate process isolates this behavior from other tests. Subclasses should not override this property. | |
KernelTestBase:: |
protected | property | ||
KernelTestBase:: |
protected | property | Set to TRUE to strict check all configuration saved. | 6 |
KernelTestBase:: |
protected | property | The virtual filesystem root directory. | |
KernelTestBase:: |
protected | function | 1 | |
KernelTestBase:: |
protected | function | Bootstraps a basic test environment. | |
KernelTestBase:: |
private | function | Bootstraps a kernel for a test. | |
KernelTestBase:: |
protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |
KernelTestBase:: |
protected | function | Disables modules for this test. | |
KernelTestBase:: |
protected | function | Enables modules for this test. | |
KernelTestBase:: |
protected | function | Gets the config schema exclusions for this test. | |
KernelTestBase:: |
protected | function | Returns the Database connection info to be used for this test. | 1 |
KernelTestBase:: |
public | function | ||
KernelTestBase:: |
private | function | Returns Extension objects for $modules to enable. | |
KernelTestBase:: |
private static | function | Returns the modules to enable for this test. | |
KernelTestBase:: |
protected | function | Initializes the FileCache component. | |
KernelTestBase:: |
protected | function | Installs default configuration for a given list of modules. | |
KernelTestBase:: |
protected | function | Installs the storage schema for a specific entity type. | |
KernelTestBase:: |
protected | function | Installs database tables from a module schema definition. | |
KernelTestBase:: |
protected | function | Returns whether the current test method is running in a separate process. | |
KernelTestBase:: |
protected | function | ||
KernelTestBase:: |
public | function |
Registers test-specific services. Overrides ServiceProviderInterface:: |
26 |
KernelTestBase:: |
protected | function | Renders a render array. | 1 |
KernelTestBase:: |
protected | function | Sets the install profile and rebuilds the container to update it. | |
KernelTestBase:: |
protected | function | Sets an in-memory Settings variable. | |
KernelTestBase:: |
public static | function | 1 | |
KernelTestBase:: |
protected | function | Sets up the filesystem, so things like the file directory. | 2 |
KernelTestBase:: |
protected | function | Stops test execution. | |
KernelTestBase:: |
public | function | @after | |
KernelTestBase:: |
protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |
KernelTestBase:: |
public | function | BC: Automatically resolve former KernelTestBase class properties. | |
KernelTestBase:: |
public | function | Prevents serializing any properties. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
RandomGeneratorTrait:: |
protected | property | The random generator. | |
RandomGeneratorTrait:: |
protected | function | Gets the random generator for the utility methods. | |
RandomGeneratorTrait:: |
protected | function | Generates a unique random string containing letters and numbers. | 1 |
RandomGeneratorTrait:: |
public | function | Generates a random PHP object. | |
RandomGeneratorTrait:: |
public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
RandomGeneratorTrait:: |
public | function | Callback for random string validation. | |
StorageCopyTrait:: |
protected static | function | Copy the configuration from one storage to another and remove stale items. | |
TestRequirementsTrait:: |
private | function | Checks missing module requirements. | |
TestRequirementsTrait:: |
protected | function | Check module requirements for the Drupal use case. | 1 |
TestRequirementsTrait:: |
protected static | function | Returns the Drupal root directory. |