You are here

public function JsAssetTest::testPathWithoutSnippet in Mautic Integration 8

Test the path without the js snippet

File

tests/src/Functional/JsAssetTest.php, line 108

Class

JsAssetTest
Functional tests for the Mautic module.

Namespace

Drupal\Tests\mautic\Functional

Code

public function testPathWithoutSnippet() {

  // Page
  $page = Url::fromRoute('entity.node_type.collection');

  // Snippet not allowed in the page
  $this->config
    ->set('visibility.request_path_mode', 0)
    ->set('mautic_base_url', 'https:/mautic.test/mtc.js')
    ->set('visibility.request_path_pages', '/' . $page
    ->getInternalPath())
    ->set('header', false)
    ->save();

  // Start the session.
  $session = $this
    ->assertSession();

  // Navigate to the page
  $this
    ->drupalGet($page);

  // Assure the page was loaded
  $session
    ->statusCodeEquals(200);

  // Check if the snippet is in the code
  $currentPage = $this
    ->getSession()
    ->getPage();
  $this
    ->assertTextNotInPage('mautic.js', $currentPage
    ->getHtml());
}