You are here

function RegistrationStandardTestCase::testHostEntitySettingsForm in Entity Registration 8.2

Same name in this branch
  1. 8.2 tests/registration.test \RegistrationStandardTestCase::testHostEntitySettingsForm()
  2. 8.2 src/RegistrationStandardTestCase.php \Drupal\registration\RegistrationStandardTestCase::testHostEntitySettingsForm()
Same name and namespace in other branches
  1. 7.2 tests/registration.test \RegistrationStandardTestCase::testHostEntitySettingsForm()
  2. 7 tests/registration.test \RegistrationStandardTestCase::testHostEntitySettingsForm()

File

tests/registration.test, line 210
Tests for the Registration module

Class

RegistrationStandardTestCase
Creates a registration type Create node entity type ensure registration type exists

Code

function testHostEntitySettingsForm() {
  $permissions = array(
    'administer ' . $this->registration_type_name . ' registration',
  );
  $this
    ->checkPermissions($permissions, TRUE);
  $user = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($user);

  // Display form.
  $this
    ->drupalGet($this->host_entity_path . '/registrations/settings');
  $this
    ->assertResponse(200, t('User can access host entity registration settings page.'), 'Registration');
  $this
    ->assertFieldByName('status');

  // Submit form.
  $test_date1 = '2011-06-04 09:42:33';
  $test_date2 = '2012-06-30 12:34:56';
  $edit = array(
    'status' => TRUE,
    'scheduling[open]' => $test_date1,
    'scheduling[close]' => $test_date2,
  );
  $this
    ->drupalPost($this->host_entity_path . '/registrations/settings', $edit, t('Save Settings'));
  $this
    ->assertText(t('Registration settings have been saved.'), t('Host entity registration settings form saved.'), 'Registration');

  // Verify settings saved to database.
  $settings = registration_entity_settings($this->host_entity_type, $this->host_entity_id);
  $this
    ->assertTrue($settings['status'], t('Host entity settings: status saved.'), 'Registration');
  $this
    ->assertTrue($settings['open'] == $test_date1, t('Host entity settings: open date saved.'), 'Registration');
  $this
    ->assertTrue($settings['close'] == $test_date2, t('Host entity settings: close date saved.'), 'Registration');
}