/**
  * Ensures that a metatag can be removed.
  */
 public function testMetatagRemovability()
 {
     $page = new HtmlPage();
     $page->addMetaElement(new MetaElement('', array('name' => 'example')));
     $page->addMetaElement(new MetaElement('', array('name' => 'example2')));
     $metatags =& $page->getMetaElements();
     foreach ($metatags as $key => $tag) {
         if ($tag->getName() == 'example') {
             unset($metatags[$key]);
         }
     }
     $metatags = $page->getMetaElements();
     reset($metatags);
     $this->assertCount(1, $metatags);
     $this->assertEquals('example2', current($metatags)->getName());
 }
 /**
  * Apply the default meta tags to the page object.
  *
  * @param \Drupal\Core\Page\HtmlPage $page
  *   The html page.
  */
 protected function setDefaultMetaTags(HtmlPage $page)
 {
     // Add default elements. Make sure the Content-Type comes first because the
     // IE browser may be vulnerable to XSS via encoding attacks from any content
     // that comes before this META tag, such as a TITLE tag.
     $page->addMetaElement(new MetaElement(NULL, array('name' => 'charset', 'charset' => 'utf-8')));
     // Show Drupal and the major version number in the META GENERATOR tag.
     // Get the major version.
     list($version) = explode('.', \Drupal::VERSION, 2);
     $page->addMetaElement(new MetaElement('Drupal ' . $version . ' (http://drupal.org)', array('name' => 'Generator')));
     // Display the html.html.twig's default mobile metatags for responsive design.
     $page->addMetaElement(new MetaElement(NULL, array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0')));
 }