function DateTimeFunctionalTest::testDateFormatConfiguration
7.x system.test | DateTimeFunctionalTest::testDateFormatConfiguration() |
Test date format configuration.
File
- drupal-7.x/
modules/ system/ system.test, line 1201 - Tests for system.module.
Class
- DateTimeFunctionalTest
- Tests generic date and time handling capabilities of Drupal.
Code
function testDateFormatConfiguration() {
// Confirm 'no custom date formats available' message appears.
$this->drupalGet('admin/config/regional/date-time/formats');
$this->assertText(t('No custom date formats available.'), 'No custom date formats message appears.');
// Add custom date format.
$this->clickLink(t('Add format'));
$edit = array(
'date_format' => 'Y',
);
$this->drupalPost('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/date-time/formats', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertNoText(t('No custom date formats available.'), 'No custom date formats message does not appear.');
$this->assertText(t('Custom date format added.'), 'Custom date format added.');
// Ensure custom date format appears in date type configuration options.
$this->drupalGet('admin/config/regional/date-time');
$this->assertRaw('<option value="Y">', 'Custom date format appears in options.');
// Edit custom date format.
$this->drupalGet('admin/config/regional/date-time/formats');
$this->clickLink(t('edit'));
$edit = array(
'date_format' => 'Y m',
);
$this->drupalPost($this->getUrl(), $edit, t('Save format'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/date-time/formats', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertText(t('Custom date format updated.'), 'Custom date format successfully updated.');
// Delete custom date format.
$this->clickLink(t('delete'));
$this->drupalPost($this->getUrl(), array(), t('Remove'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/date-time/formats', array('absolute' => TRUE)), 'Correct page redirection.');
$this->assertText(t('Removed date format'), 'Custom date format removed successfully.');
}