function RegistrationStandardTestCase::testHostRegistrationStatus in Entity Registration 8.2
Same name in this branch
- 8.2 tests/registration.test \RegistrationStandardTestCase::testHostRegistrationStatus()
- 8.2 src/RegistrationStandardTestCase.php \Drupal\registration\RegistrationStandardTestCase::testHostRegistrationStatus()
Check internal status modifiers.
Capacity, opening, and closing dates.
File
- src/
RegistrationStandardTestCase.php, line 186
Class
- RegistrationStandardTestCase
- Creates a registration type Create node entity type ensure registration type exists
Namespace
Drupal\registrationCode
function testHostRegistrationStatus() {
$user = \Drupal::currentUser();
$permissions = array(
'create ' . $this->registration_type_name . ' registration',
);
$this
->checkPermissions($permissions, TRUE);
$basic_user = $this
->drupalCreateUser($permissions);
$permissions = array(
'administer ' . $this->registration_type_name . ' registration',
);
$this
->checkPermissions($permissions, TRUE);
$admin_user = $this
->drupalCreateUser($permissions);
// Start with the basic user.
$user = $basic_user;
$this
->assertFalse(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Default host entity status is closed.'), 'Registration');
$this
->setHostEntitySettings(array(
'status' => 1,
'capacity' => 10,
));
$this
->assertTrue(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity main status is opened.'), 'Registration');
// Fill capacity.
$registrations = array();
for ($i = 0; $i < 5; $i++) {
$registrations[$i] = $this
->createRegistration(array(
'count' => 2,
));
}
$this
->assertFalse(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is closed, filled with registrations.'), 'Registration');
// Unfill capacity by one registration.
end($registrations)->registration_id
->delete();
$this
->assertTrue(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Deleted a registration, capacity now not at maximum.'), 'Registration');
// Test dates.
$this
->setHostEntitySettings(array(
'status' => 1,
'open' => date('Y-m-d H:i:s', time() + 3600),
'close' => NULL,
));
$this
->assertFalse(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is closed, open time has not passed.'), 'Registration');
$this
->setHostEntitySettings(array(
'status' => 1,
'open' => date('Y-m-d H:i:s', time() - 3600),
'close' => date('Y-m-d H:i:s', time() + 3600),
));
$this
->assertTrue(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is open, in between open and closing times.'), 'Registration');
$this
->setHostEntitySettings(array(
'status' => 1,
'open' => NULL,
'close' => date('Y-m-d H:i:s', time() - 3600),
));
$this
->assertFalse(registration_status($this->host_entity_type, $this->host_entity_id, TRUE), t('Host entity status is closed, closing time has passed.'), 'Registration');
}