LiftCustomFieldTest.php in Mautic Integration 8
File
tests/src/Functional/LiftCustomFieldTest.php
View source
<?php
namespace Drupal\Tests\mautic\Functional;
use Drupal\Core\Config\Config;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class LiftCustomFieldTest extends BrowserTestBase {
private $config;
protected $defaultTheme = 'stable';
public function setUp() {
$this
->checkRequirements();
parent::setUp();
$this->config = \Drupal::configFactory()
->getEditable('mautic.settings');
$this->config
->set('mautic_enable', true);
$user = $this
->drupalCreateUser(array(
'administer site configuration',
'administer content types',
));
$this
->drupalLogin($user);
}
public static $modules = [
'mautic',
'node',
'user',
'acquia_lift',
];
public function testPathWithLiftSnippet() {
$page = Url::fromRoute('entity.node_type.collection');
$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('lift_enable', true)
->save();
$session = $this
->assertSession();
$this
->drupalGet($page);
$session
->statusCodeEquals(200);
$currentPage = $this
->getSession()
->getPage();
$this
->assertStringContainsString('mautic.customFields.js', $currentPage
->getHtml());
}
public function testPathWithoutLiftSnippet() {
$page = Url::fromRoute('entity.node_type.collection');
$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('lift_enable', false)
->save();
$session = $this
->assertSession();
$this
->drupalGet($page);
$session
->statusCodeEquals(200);
$currentPage = $this
->getSession()
->getPage();
$this
->assertStringNotContainsString('mautic.customFields.js', $currentPage
->getHtml());
}
}