function UserpointsAPITestCase::testDefaultExpireDate in User Points 7
Same name and namespace in other branches
- 7.2 userpoints.test \UserpointsAPITestCase::testDefaultExpireDate()
Changes the default expiration date in the administrative settings and then checks to ensure that it is saved/returned correctly.
File
- tests/
userpoints_api.test, line 409 - Contains test classes for userpoints module.
Class
- UserpointsAPITestCase
- API Tests.
Code
function testDefaultExpireDate() {
// Login as an admin.
$this
->drupalLogin($this->admin_user);
// Use a date in the future.
$date = REQUEST_TIME + 100000;
$date_array = array(
'month' => date('n', $date),
'day' => date('d', $date),
'year' => date('Y', $date),
);
// save settings.
$edit = array(
'userpoints_expireon_date[month]' => $date_array['month'],
'userpoints_expireon_date[day]' => $date_array['day'],
'userpoints_expireon_date[year]' => $date_array['year'],
);
$this
->drupalPost('admin/config/people/userpoints/settings', $edit, 'Save configuration');
// Check database.
$database_date = variable_get('userpoints_expireon_date', FALSE);
$this
->assertEqual($database_date['day'], $date_array['day']);
$this
->assertEqual($database_date['month'], $date_array['month']);
$this
->assertEqual($database_date['year'], $date_array['year']);
// Check API.
$expiry_date = userpoints_get_default_expiry_date();
$this
->assertEqual($expiry_date, userpoints_date_to_timestamp($date_array));
}