You are here

public function JsAssetTest::testPathWithSnippetHeader in Mautic Integration 8

Test the path with the js snippet in the header

File

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

Class

JsAssetTest
Functional tests for the Mautic module.

Namespace

Drupal\Tests\mautic\Functional

Code

public function testPathWithSnippetHeader() {

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

  // Snippet in the header
  $this->config
    ->set('visibility.request_path_mode', 1)
    ->set('mautic_base_url', 'https:/mautic.test/mtc.js')
    ->set('visibility.request_path_pages', '/' . $page
    ->getInternalPath())
    ->set('header', true)
    ->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
    ->assertTextInHeader('mautic.js', $currentPage
    ->getHtml());
}