You are here

public function ShareMessageSettingsTest::testShareMessageSpecialCharsEncoding in Share Message 8

Test case for special characters encoding.

File

tests/src/Functional/ShareMessageSettingsTest.php, line 276

Class

ShareMessageSettingsTest
Check if default Share Message settings work correctly.

Namespace

Drupal\Tests\sharemessage\Functional

Code

public function testShareMessageSpecialCharsEncoding() {

  // Create Share Message with AddThis as plugin.
  $this
    ->drupalGet('admin/config/services/sharemessage/add');
  $sharemessage = [
    'label' => 'Special characters encoding test',
    'id' => 'sharemessage_test_special_chars',
    'plugin' => 'addthis',
    'title' => 'Inondations sur la Côte d\'Azur: «C’est apocalyptique, c’est Tchernobyl»',
    'message_long' => 'Long description',
    'message_short' => 'Short description',
  ];
  $this
    ->drupalPostForm(NULL, $sharemessage, t('Save'));
  $this
    ->assertText(t('Share Message @label has been added.', [
    '@label' => $sharemessage['label'],
  ]));
  $this
    ->drupalGet('sharemessage-test/sharemessage_test_special_chars');

  // Check for correct encoding in meta tags.
  $this
    ->assertOGTags('og:title', 'Inondations sur la Côte d'Azur: «C’est apocalyptique, c’est Tchernobyl»');
  $this
    ->assertNoOGTags('og:title', 'Inondations sur la Côte d\'Azur: «C’est apocalyptique, c’est Tchernobyl»');
  $this
    ->assertOGTags('og:url', $this
    ->getUrl());
  $this
    ->assertOGTags('og:description', 'Long description');
  $this
    ->assertOGTags('og:type', 'website');
  $this
    ->drupalGet('admin/config/services/sharemessage/add');
  $sharemessage2 = [
    'label' => 'Special characters encoding test 2',
    'id' => 'sharemessage_test_special_chars_2',
    'plugin' => 'addthis',
    'title' => 'This is a second test with quotes "',
    'message_long' => 'Long description 2',
    'message_short' => 'Short description 2',
  ];
  $this
    ->drupalPostForm(NULL, $sharemessage2, t('Save'));
  $this
    ->drupalGet('sharemessage-test/sharemessage_test_special_chars_2');
  $this
    ->assertOGTags('og:title', 'This is a second test with quotes "');
  $this
    ->assertNoOGTags('og:title', 'This is a second test with quotes "');
}