ViewportTagPrintedOnSelectedPagesTest.php in Viewport 8
File
tests/src/Functional/ViewportTagPrintedOnSelectedPagesTest.php
View source
<?php
namespace Drupal\Tests\viewport\Functional;
use Drupal\Tests\BrowserTestBase;
class ViewportTagPrintedOnSelectedPagesTest extends BrowserTestBase {
public static $modules = [
'viewport',
];
protected $adminUser;
public function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser(array(
'administer viewport',
));
}
public function testViewportTagIsPrintedWithTheRightValues() {
$this
->drupalLogin($this->adminUser);
$edit = array();
$edit['width'] = '980';
$edit['height'] = '1000';
$edit['initial_scale'] = '1.3';
$edit['minimum_scale'] = '0.25';
$edit['maximum_scale'] = '5.0';
$edit['user_scalable'] = TRUE;
$edit['selected_pages'] = "/node/*";
$this
->drupalGet('admin/appearance/settings/viewport');
$this
->submitForm($edit, t('Save configuration'));
$this
->drupalGet('/node/');
$custom_viewport = 'meta name="viewport" content="width=980, height=1000, initial-scale=1.3, minimum-scale=0.25, maximum-scale=5, user-scalable=yes"';
$this
->assertSession()
->responseContains($custom_viewport);
}
public function testViewportTagNotPrintedInPagesNotSelected() {
$this
->drupalLogin($this->adminUser);
$edit = array();
$edit['width'] = '980';
$edit['height'] = '1000';
$edit['initial_scale'] = '1.3';
$edit['minimum_scale'] = '0.25';
$edit['maximum_scale'] = '5.0';
$edit['user_scalable'] = TRUE;
$edit['selected_pages'] = '/node/*';
$this
->drupalGet('admin/appearance/settings/viewport');
$this
->submitForm($edit, t('Save configuration'));
$this
->drupalGet('admin');
$core_viewport = 'meta name="viewport" content="width=device-width, initial-scale=1.0"';
$this
->assertSession()
->responseContains($core_viewport);
$custom_viewport = 'meta name="viewport" content="width=980, height=1000, initial-scale=1.3, minimum-scale=0.25, maximum-scale=5, user-scalable=yes"';
$this
->assertSession()
->responseNotContains($custom_viewport);
}
}