BrowsersyncTest.php in Browsersync 8        
                          
                  
                        
  
  
  
  
File
  src/Tests/BrowsersyncTest.php
  
    View source  
  <?php
namespace Drupal\browsersync\Tests;
use Drupal\simpletest\WebTestBase;
class BrowsersyncTest extends WebTestBase {
  
  public static $modules = [
    'browsersync',
  ];
  
  protected function setUp() {
    parent::setUp();
    
    $dev_user = $this
      ->drupalCreateUser([
      'use browsersync',
    ]);
    $this
      ->drupalLogin($dev_user);
    
    \Drupal::configFactory()
      ->getEditable('system.theme.global')
      ->set('third_party_settings.browsersync.enabled', TRUE)
      ->save();
  }
  
  public function testSnippet() {
    $this
      ->drupalGet('<front>');
    $elements = $this
      ->xpath('//script[@id=:id]', [
      ':id' => '__bs_script__',
    ]);
    $this
      ->assertTrue(!empty($elements), 'Page contains the Browsersync snippet.');
    
    $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.');
  }
}