You are here

public function PageViewTest::testFacebookPixelEnabledForAllUsers in Simple Facebook Pixel 8

Tests snippet insertion for all users.

File

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

Class

PageViewTest
Tests PageView event.

Namespace

Drupal\Tests\simple_facebook_pixel\Functional

Code

public function testFacebookPixelEnabledForAllUsers() {
  $edit['pixel_enabled'] = TRUE;
  $edit['pixel_id'] = '567123';
  $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
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseContains($pixel_builder
    ->getPixelScriptCode());
  $this
    ->assertSession()
    ->responseContains($pixel_builder
    ->getPixelNoScriptCode());
  $this
    ->drupalLogout();
  $this
    ->assertSession()
    ->responseContains($pixel_builder
    ->getPixelScriptCode());
  $this
    ->assertSession()
    ->responseContains($pixel_builder
    ->getPixelNoScriptCode());
}