You are here

public function PageViewTest::testDisablingForAdminRoutes in Simple Facebook Pixel 8

Tests snippet insertion when Facebook Pixel is disabled for admin routes.

File

tests/src/Functional/PageViewTest.php, line 90

Class

PageViewTest
Tests PageView event.

Namespace

Drupal\Tests\simple_facebook_pixel\Functional

Code

public function testDisablingForAdminRoutes() {
  $edit['pixel_enabled'] = TRUE;
  $edit['pixel_id'] = '789012';
  $edit['exclude_admin_pages'] = FALSE;
  $this
    ->drupalPostForm('admin/config/system/simple-facebook-pixel', $edit, 'Save configuration');
  $this
    ->assertSession()
    ->responseContains('The configuration options have been saved.');

  /** @var \Drupal\simple_facebook_pixel\PixelBuilderServiceInterface $pixel_builder */
  $pixel_builder = \Drupal::service('simple_facebook_pixel.pixel_builder');
  $this
    ->assertSession()
    ->responseContains($pixel_builder
    ->getPixelScriptCode());
  $edit['pixel_enabled'] = TRUE;
  $edit['pixel_id'] = '789012';
  $edit['exclude_admin_pages'] = TRUE;
  $this
    ->drupalPostForm('admin/config/system/simple-facebook-pixel', $edit, 'Save configuration');
  $this
    ->assertSession()
    ->responseContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->responseNotContains($pixel_builder
    ->getPixelScriptCode());
}