You are here

public function BrowsersyncTest::testSnippet in Browsersync 8

Same name and namespace in other branches
  1. 8.2 src/Tests/BrowsersyncTest.php \Drupal\browsersync\Tests\BrowsersyncTest::testSnippet()

Checks for the Browsersync snippet in the markup.

File

src/Tests/BrowsersyncTest.php, line 40

Class

BrowsersyncTest
Tests Browsersync functionality.

Namespace

Drupal\browsersync\Tests

Code

public function testSnippet() {
  $this
    ->drupalGet('<front>');
  $elements = $this
    ->xpath('//script[@id=:id]', [
    ':id' => '__bs_script__',
  ]);
  $this
    ->assertTrue(!empty($elements), 'Page contains the Browsersync snippet.');

  // Log out and check that the snippet is gone.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('<front>');
  $elements = $this
    ->xpath('//script[@id=:id]', [
    ':id' => '__bs_script__',
  ]);
  $this
    ->assertTrue(empty($elements), 'Page does not contain the Browsersync snippet.');
}