You are here

public function RngSettingsFormTest::testSettingsForm in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/Tests/RngSettingsFormTest.php \Drupal\rng\Tests\RngSettingsFormTest::testSettingsForm()
  2. 8 src/Tests/RngSettingsFormTest.php \Drupal\rng\Tests\RngSettingsFormTest::testSettingsForm()

Test settings form.

File

src/Tests/RngSettingsFormTest.php, line 28

Class

RngSettingsFormTest
Tests RNG settings form.

Namespace

Drupal\rng\Tests

Code

public function testSettingsForm() {
  $web_user = $this
    ->drupalCreateUser([
    'administer rng',
  ]);
  $this
    ->drupalLogin($web_user);
  $this
    ->drupalGet(Url::fromRoute('rng.config.settings'));
  $this
    ->assertRaw('Enable people types who can register for events.', 'Registration settings form is rendered.');
  $this
    ->assertTrue(in_array('user', $this
    ->config('rng.settings')
    ->get('identity_types')), 'Registrant types install config contains user registrant pre-enabled.');
  $this
    ->assertFieldChecked('edit-contactables-user', 'User registrant checkbox is pre-checked');
  $edit = [
    'contactables[user]' => FALSE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save configuration'));
  $this
    ->assertRaw('RNG settings updated.', 'Settings form saved.');
  $this
    ->assertNoFieldChecked('edit-contactables-user', 'User registrant checkbox is now unchecked');
  $this
    ->assertIdentical(0, count($this
    ->config('rng.settings')
    ->get('identity_types')), 'All identity types disabled and saved to config.');
}