DataLayerFunctionalTest.php in dataLayer 8
File
tests/src/Functional/DataLayerFunctionalTest.php
View source
<?php
namespace Drupal\Tests\datalayer\Functional;
use Drupal\Tests\BrowserTestBase;
class DataLayerFunctionalTest extends BrowserTestBase {
public $profile = 'testing';
public static $modules = [
'node',
'datalayer',
'taxonomy',
];
protected $defaultTheme = 'stark';
public function setUp() {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'access administration pages',
'administer nodes',
'administer site configuration',
]);
$this
->drupalLogin($admin_user);
}
public function testDataLayerVariableOutputByName() {
$output = $this
->drupalGet('node');
$assert = $this
->assertSession();
$assert
->pageTextContains('window.dataLayer = window.dataLayer || []; window.dataLayer.push({');
}
public function testDataLayerJsLanguageSettings() {
$output = $this
->drupalGet('node');
$assert = $this
->assertSession();
$assert
->pageTextContains('"dataLayer":{"defaultLang"');
}
public function testAdminSettingsForm() {
$assert = $this
->assertSession();
$this
->drupalGet('admin/config/search/datalayer');
$assert
->pageTextContains('Include "data layer helper" library');
$this
->assertNoFieldChecked('lib_helper');
$assert
->pageTextNotContains('Data Layer Helper Library is enabled but the library is not installed at /libraries/data-layer-helper/dist/data-layer-helper.js. See: data-layer-helper on GitHub.');
$this
->drupalPostForm(NULL, [
'lib_helper' => '1',
], 'Save configuration');
$this
->assertFieldChecked('lib_helper');
$assert
->pageTextContains('Data Layer Helper Library is enabled but the library is not installed at /libraries/data-layer-helper/dist/data-layer-helper.js. See: data-layer-helper on GitHub.');
}
}