Version 1
[yaffs-website] / web / modules / contrib / metatag / metatag_twitter_cards / src / Tests / MetatagTwitterCardsTagsTest.php
diff --git a/web/modules/contrib/metatag/metatag_twitter_cards/src/Tests/MetatagTwitterCardsTagsTest.php b/web/modules/contrib/metatag/metatag_twitter_cards/src/Tests/MetatagTwitterCardsTagsTest.php
new file mode 100644 (file)
index 0000000..602ac11
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+
+namespace Drupal\metatag_twitter_cards\Tests;
+
+use Drupal\simpletest\WebTestBase;
+use Drupal\metatag\Tests\MetatagTagsTestBase;
+
+/**
+ * Tests that each of the Metatag Twitter Cards tags work correctly.
+ *
+ * @group metatag
+ */
+class MetatagTwitterCardsTagsTest extends MetatagTagsTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public $tags = [
+    'twitter_cards_app_id_googleplay',
+    'twitter_cards_app_id_ipad',
+    'twitter_cards_app_id_iphone',
+    'twitter_cards_app_name_googleplay',
+    'twitter_cards_app_name_ipad',
+    'twitter_cards_app_name_iphone',
+    'twitter_cards_app_store_country',
+    'twitter_cards_app_url_googleplay',
+    'twitter_cards_app_url_ipad',
+    'twitter_cards_app_url_iphone',
+    'twitter_cards_creator',
+    'twitter_cards_creator_id',
+    'twitter_cards_data1',
+    'twitter_cards_data2',
+    'twitter_cards_description',
+    'twitter_cards_gallery_image0',
+    'twitter_cards_gallery_image1',
+    'twitter_cards_gallery_image2',
+    'twitter_cards_gallery_image3',
+    'twitter_cards_image',
+    'twitter_cards_image_alt',
+    'twitter_cards_image_height',
+    'twitter_cards_image_width',
+    'twitter_cards_label1',
+    'twitter_cards_label2',
+    'twitter_cards_page_url',
+    'twitter_cards_player',
+    'twitter_cards_player_height',
+    'twitter_cards_player_stream',
+    'twitter_cards_player_stream_content_type',
+    'twitter_cards_player_width',
+    'twitter_cards_site',
+    'twitter_cards_site_id',
+    'twitter_cards_title',
+    'twitter_cards_type',
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::$modules[] = 'metatag_twitter_cards';
+    parent::setUp();
+  }
+
+  /**
+   * Twitter meta tags (almost) all have colons instead of underlines, and they
+   * don't have "cards" in their name.
+   */
+  public function getTestTagName($tag_name) {
+    $tag_name = str_replace('twitter_cards', 'twitter', $tag_name);
+    $tag_name = str_replace('_', ':', $tag_name);
+
+    if ($tag_name == 'twitter:app:store:country') {
+      $tag_name = 'twitter:app:country';
+    }
+    elseif ($tag_name == 'twitter:page:url') {
+      $tag_name = 'twitter:url';
+    }
+    elseif ($tag_name == 'twitter:player:stream:content:type') {
+      $tag_name = 'twitter:player:stream:content_type';
+    }
+    elseif ($tag_name == 'twitter:type') {
+      $tag_name = 'twitter:card';
+    }
+    elseif ($tag_name == '') {
+      $tag_name = '';
+    }
+
+    return $tag_name;
+  }
+
+  /**
+   * Implements {meta_tag_name}_test_field_xpath() for 'twitter_cards_type'.
+   */
+  public function twitter_cards_type_test_field_xpath() {
+    return "//select[@name='twitter_cards_type']";
+  }
+
+  /**
+   * Implements {meta_tag_name}_test_value() for 'twitter_cards_type'.
+   */
+  public function twitter_cards_type_test_value() {
+    return 'summary_large_image';
+  }
+
+}