You are here

public function RngEventSettingsTest::testEventSettings in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 src/Tests/RngEventSettingsTest.php \Drupal\rng\Tests\RngEventSettingsTest::testEventSettings()
  2. 3.x src/Tests/RngEventSettingsTest.php \Drupal\rng\Tests\RngEventSettingsTest::testEventSettings()

Tests changing event settings reveals the 'Register' tab.

File

src/Tests/RngEventSettingsTest.php, line 104

Class

RngEventSettingsTest
Tests event settings page.

Namespace

Drupal\rng\Tests

Code

public function testEventSettings() {
  $bundle = $this->event_bundle
    ->id();
  $account = $this
    ->drupalCreateUser([
    'access content',
    'edit own ' . $bundle . ' content',
    'rng register self',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->createEntity($this->event_bundle, [
    'uid' => \Drupal::currentUser()
      ->id(),
  ]);

  // Event.
  $base_url = 'node/1';
  $this
    ->drupalGet($base_url . '');
  $this
    ->assertResponse(200);
  $this
    ->drupalGet($base_url . '/event');
  $this
    ->assertResponse(200);
  $this
    ->assertNoLinkByHref($base_url . '/register');
  $this
    ->drupalGet($base_url . '/register');
  $this
    ->assertResponse(403);

  // Settings.
  $edit = [
    'rng_status[value]' => TRUE,
    'rng_registration_type[' . $this->registration_type
      ->id() . ']' => TRUE,
  ];
  $this
    ->drupalPostForm($base_url . '/event', $edit, t('Save'));
  $this
    ->assertRaw(t('Event settings updated.'));

  // Register tab appears.
  $this
    ->assertLinkByHref($base_url . '/register');
}