public function MetatagTest::testExposeDefaultTagsAndTokenReplaceAndClearToken in Entity Share 8.2
Test metatag plugin.
All settings checked.
Same as the second case, the difference will be in the JSON output, the [node:summary] token will be exposed but not replaced, so Metatag does not save back the value.
File
- modules/
entity_share_client/ tests/ src/ Functional/ MetatagTest.php, line 170
Class
- MetatagTest
- General functional test class for metatag field.
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
public function testExposeDefaultTagsAndTokenReplaceAndClearToken() {
$this->entityTypeManager
->getStorage('jsonapi_resource_config')
->create([
'id' => 'node--es_test',
'disabled' => FALSE,
'path' => 'node/es_test',
'resourceType' => 'node--es_test',
'resourceFields' => [
'field_es_test_metatag' => [
'fieldName' => 'field_es_test_metatag',
'publicName' => 'field_es_test_metatag',
'enhancer' => [
'id' => 'entity_share_metatag',
'settings' => [
'expose_default_tags' => TRUE,
'replace_tokens' => TRUE,
'clear_tokens' => TRUE,
],
],
'disabled' => FALSE,
],
],
])
->save();
$this
->prepareContent();
$node = $this
->loadEntity('node', 'es_test');
$node_title = $node
->label();
$node_url = $node
->toUrl('canonical')
->setAbsolute()
->toString();
$this
->populateRequestService();
$this
->deleteContent();
$this
->pullEveryChannels();
$node = $this
->loadEntity('node', 'es_test');
$node_metatags = unserialize($node
->get('field_es_test_metatag')
->getValue()[0]['value']);
$expected_metatags = [
'canonical_url' => $node_url,
'title' => $node_title . ' | Drupal',
'abstract' => 'test abstract',
];
$this
->assertEquals($expected_metatags, $node_metatags, 'The node has the expected metatags.');
}