You are here

function RegistrationAPITestCase::testHookStatus in Entity Registration 8.2

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

Test hook_registration_status().

File

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

Class

RegistrationAPITestCase

Code

function testHookStatus() {

  // Testing host status, no hook.
  $this
    ->setHostEntitySettings(array(
    'status' => 1,
  ));
  $this
    ->assertTrue(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is open.'), 'Registration');

  // Host main status is opened, hook closes.
  \Drupal::configFactory()
    ->getEditable('registration.settings')
    ->set('registration_test_api_registration_status_alter', FALSE)
    ->save();
  $this
    ->assertFalse(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is open, hook overrides'), 'Registration');

  // Hook should still be invoked if main status is closed.
  $this
    ->setHostEntitySettings(array(
    'status' => 0,
  ));
  \Drupal::configFactory()
    ->getEditable('registration.settings')
    ->set('registration_test_api_registration_status_alter', TRUE)
    ->save();
  $this
    ->assertTrue(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is closed, hook overrides.'), 'Registration');
}