You are here

public function MetatagTest::testExposeDefaultTags in Entity Share 8.2

Test metatag plugin.

Only exposed default tags settings checked.

In the first case even if default metatags are exposed, as the exposed data is only token, it is not saved back into the field.

File

modules/entity_share_client/tests/src/Functional/MetatagTest.php, line 71

Class

MetatagTest
General functional test class for metatag field.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

public function testExposeDefaultTags() {
  $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' => FALSE,
            'clear_tokens' => FALSE,
          ],
        ],
        'disabled' => FALSE,
      ],
    ],
  ])
    ->save();
  $this
    ->prepareContent();
  $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 = [
    'abstract' => 'test abstract',
  ];
  $this
    ->assertEquals($expected_metatags, $node_metatags, 'The node has the expected metatags.');
}