Version 1
[yaffs-website] / web / core / modules / system / src / Tests / System / DefaultMobileMetaTagsTest.php
1 <?php
2
3 namespace Drupal\system\Tests\System;
4
5 use Drupal\Component\Utility\SafeMarkup;
6 use Drupal\simpletest\WebTestBase;
7
8 /**
9  * Confirm that the default mobile meta tags appear as expected.
10  *
11  * @group system
12  */
13 class DefaultMobileMetaTagsTest extends WebTestBase {
14   /**
15    * Array of default meta tags to insert into the page.
16    *
17    * @var array
18    */
19   protected $defaultMetaTags;
20
21   protected function setUp() {
22     parent::setUp();
23     $this->defaultMetaTags = [
24       'viewport' => '<meta name="viewport" content="width=device-width, initial-scale=1.0" />',
25     ];
26   }
27
28   /**
29    * Verifies that the default mobile meta tags are added.
30    */
31   public function testDefaultMetaTagsExist() {
32     $this->drupalGet('');
33     foreach ($this->defaultMetaTags as $name => $metatag) {
34       $this->assertRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" displayed properly.', ['@name' => $name]), 'System');
35     }
36   }
37
38   /**
39    * Verifies that the default mobile meta tags can be removed.
40    */
41   public function testRemovingDefaultMetaTags() {
42     \Drupal::service('module_installer')->install(['system_module_test']);
43     $this->drupalGet('');
44     foreach ($this->defaultMetaTags as $name => $metatag) {
45       $this->assertNoRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" removed properly.', ['@name' => $name]), 'System');
46     }
47   }
48
49 }