public function SiteStatusMessageTestCase::testSiteStatusMessageAdminPage in Site Status Message 7
Tests for the Site Status Message admin page.
File
- tests/
site_status_message.test, line 70 - Tests for Site Status Message module.
Class
- SiteStatusMessageTestCase
- Class SiteStatusMessageTestCase.
Code
public function testSiteStatusMessageAdminPage() {
// Create an Admin user.
$this
->adminLogin();
// Check the admin page can be accessed by our new user.
$this
->drupalGet($this->siteStatusMessageAdminPage);
$this
->assertResponse(200, 'Ensure a 200 code is returned.');
$this
->assertText(t('Site Status Message'), 'Check the admin page title is set to Site Status Message for Admin user.');
// Check the Message field is on the page.
$this
->assertFieldById('edit-site-status-message-message', '', 'Check the message field is on the admin page.');
// Check the Show Link field is on the page.
$this
->assertFieldById('edit-site-status-message-showlink', '', 'Check the show link field is on the admin page.');
// Check the Link field is on the page.
$this
->assertFieldById('edit-site-status-message-link', '', 'Check the link field is on the admin page.');
// Check the Read More field is on the page.
$this
->assertFieldById('edit-site-status-message-readmore', '', 'Check the Read More field is on the admin page.');
// Check the Display Options fields are on the page.
$this
->assertFieldById('edit-site-status-message-display-options-off', '', 'Check the Display Options "Off" option field is on the admin page.');
$this
->assertFieldById('edit-site-status-message-display-options-public', '', 'Check the Display Options "Public-facing" option field is on the admin page.');
$this
->assertFieldById('edit-site-status-message-display-options-admin', '', 'Check the Display Options "Admin" option field is on the admin page.');
$this
->assertFieldById('edit-site-status-message-display-options-both', '', 'Check the Display Options "Both" option field is on the admin page.');
$options = $this
->xpath('//input[@name="site_status_message_display_options"]');
$this
->assertEqual(count($options), 4, 'There are exactly 4 Display Options on the admin page');
$form_elements = $this
->xpath('//input[@id]');
$this
->assertEqual(count($form_elements), 9, 'There are exactly 9 Form Elements on the admin page');
// Check the page cannot be accessed by anonymous user.
$this
->userLogout();
$this
->drupalGet($this->siteStatusMessageAdminPage);
$this
->assertText(t('Access denied'), 'Check that anonymous user gets an Access Denied message for the admin page.');
$this
->assertResponse(403, 'Ensure a 403 Forbidden error is returned.');
}