Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / metatag / tests / src / Functional / RemoveCoreMetaTags.php
diff --git a/web/modules/contrib/metatag/tests/src/Functional/RemoveCoreMetaTags.php b/web/modules/contrib/metatag/tests/src/Functional/RemoveCoreMetaTags.php
new file mode 100644 (file)
index 0000000..489b007
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+namespace Drupal\Tests\metatag\Functional;
+
+use Drupal\taxonomy\Entity\Term;
+use Drupal\taxonomy\Entity\Vocabulary;
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Ensures that meta tags output by core are removed if we are overriding them.
+ *
+ * @group metatag
+ */
+class RemoveCoreMetaTags extends BrowserTestBase {
+
+  // Contains helper methods.
+  use MetatagHelperTrait;
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = [
+    'token',
+    'metatag',
+    'taxonomy',
+  ];
+
+  /**
+   * Tests core tags are removed on taxonomy term pages.
+   */
+  public function testTaxonomyPage() {
+    $this->loginUser1();
+
+    // Set up a vocabulary.
+    $vocabulary = Vocabulary::create([
+      'vid' => 'metatag_vocab',
+      'name' => $this->randomString(),
+    ]);
+    $vocabulary->save();
+    $term = Term::create([
+      'vid' => $vocabulary->id(),
+      'name' => $this->randomString(),
+    ]);
+    $term->save();
+
+    // Set up meta tags for taxonomy.
+    $edit = [
+      'canonical_url' => '[current-page:url:unaliased]',
+    ];
+    $this->drupalPostForm('admin/config/search/metatag/taxonomy_term', $edit, 'Save');
+
+    // Ensure there is only 1 canonical metatag.
+    $this->drupalGet('taxonomy/term/' . $term->id());
+    $xpath = $this->xpath("//link[@rel='canonical']");
+    $this->assertEquals(1, count($xpath), 'Exactly one canonical rel meta tag found.');
+  }
+
+}