You are here

public function CompleteRegistrationTest::testUserCreationWhenEnabled in Simple Facebook Pixel 8

Tests CompleteRegistration when enabled.

File

tests/src/Functional/CompleteRegistrationTest.php, line 47

Class

CompleteRegistrationTest
Tests CompleteRegistration event.

Namespace

Drupal\Tests\simple_facebook_pixel\Functional

Code

public function testUserCreationWhenEnabled() {
  $this->configFactory
    ->getEditable('simple_facebook_pixel.settings')
    ->set('pixel_enabled', TRUE)
    ->set('pixel_id', '1234567890')
    ->set('complete_registration_enabled', TRUE)
    ->save();
  $edit['name'] = $this
    ->randomMachineName();
  $edit['mail'] = $edit['name'] . '@example.com';
  $this
    ->drupalPostForm('user/register', $edit, 'Create new account');
  $this
    ->assertText('A welcome message with further instructions has been sent to your email address.');

  /** @var \Drupal\simple_facebook_pixel\PixelBuilderServiceInterface $pixel_builder */
  $pixel_builder = \Drupal::service('simple_facebook_pixel.pixel_builder');
  $this
    ->assertSession()
    ->responseContains($pixel_builder
    ->getPixelScriptCode());
  $this
    ->assertSession()
    ->responseContains('CompleteRegistration');
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseNotContains('CompleteRegistration');
}