public function MetatagTest::testExposeDefaultTagsAndTokenReplace in Entity Share 8.2
Test metatag plugin.
Settings exposed default tags and replace tokens checked.
In the second case, default tags ith tokens had been replaced by the real values. But as for the first case, when a value is only an unreplaced token, Metatag does not save back the value.
So for example, we don't see in the result the [node:summary] token.
File
- modules/
entity_share_client/ tests/ src/ Functional/ MetatagTest.php, line 118
Class
- MetatagTest
- General functional test class for metatag field.
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
public function testExposeDefaultTagsAndTokenReplace() {
$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' => FALSE,
],
],
'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.');
}