You are here

public function CompleteRegistrationTest::testUserCreationWhenDisabled in Simple Facebook Pixel 8

Tests CompleteRegistration when disabled.

File

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

Class

CompleteRegistrationTest
Tests CompleteRegistration event.

Namespace

Drupal\Tests\simple_facebook_pixel\Functional

Code

public function testUserCreationWhenDisabled() {
  $this->configFactory
    ->getEditable('simple_facebook_pixel.settings')
    ->set('pixel_enabled', TRUE)
    ->set('pixel_id', '1234567890')
    ->set('complete_registration_enabled', FALSE)
    ->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()
    ->responseNotContains('CompleteRegistration');
}