function UserpointsTestCase::testDefaultExpireDate in User Points 6
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 328
Class
Code
function testDefaultExpireDate() {
//login as an admin
global $admin_user;
$this
->drupalLogin($admin_user);
// Use a date in the future.
$date = 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/settings/userpoints', $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));
}