function FaqAskAccessTestClass::testFaqAskAccess in FAQ_Ask 6.2
File
- ./
faq_ask.test, line 315 - Test FAQ functionality Base test class. All tests inherits this one. Hugely based on code from the test file block.test by boombatower
Class
Code
function testFaqAskAccess() {
// Verify that anonymous user has no access to the faq page
$this
->faqAskVerifyNoAccess('faq_ask');
// Verify that user without asker or expert permission does not have access to the list of unanswered questions
$this
->faqAskVerifyNoAccess('faq_ask/unanswered');
// Returns 403 as it should
// Create and login user
$normal_user = $this
->drupalCreateUser();
$this
->drupalLogin($normal_user);
// Verify that user without asker or expert permission does not have access to the list of unanswered questions
$this
->faqAskVerifyNoAccess('faq_ask/unanswered');
// Returns 403 as it should
// Verify that logged in user has no access to the faq page
$this
->faqAskVerifyNoAccess('faq_ask');
$this
->drupalLogout();
// Verify that view rights does not allow for asking questions
$this
->drupalLogin($this->view_faq_user);
$this
->faqAskVerifyNoAccess('faq_ask');
// Verify that user without asker or expert permission does not have access to the list of unanswered questions
$this
->faqAskVerifyNoAccess('faq_ask/unanswered');
// Returns 403 as it should
// Verify that the faq page is visible and available but empty
$this
->drupalGet('faq');
$this
->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
// Change rights for anonymous user - Enable asking a question
$this
->drupalLogin($this->admin_user);
$edit = array(
'1[create faq]' => TRUE,
'1[ask question]' => TRUE,
);
$this
->drupalPost('admin/user/permissions', $edit, 'Save permissions');
$this
->drupalGet('admin/user/permissions');
// Verify that the Answer field is not available for asker without permission
$this
->drupalLogout();
// Anonymous user
// Issue #1052772 by bk262: Removing "?ask=TRUE" from url let's user enter complete FAQ entry
$this
->drupalGet('node/add/faq');
$this
->assertNoFieldByName('body', '', 'Answer field is not visible and contains default text.');
$this
->drupalGet('faq_ask');
$this
->assertText(t('Ask a Question'), t('Ask a Question page is available for users with asker permission.'));
$this
->drupalLogin($this->faq_asker);
// Verify that the Answer field is not available for asker without permission
// Issue #1052772 by bk262: Removing "?ask=TRUE" from url let's user enter complete FAQ entry
$this
->drupalGet('node/add/faq');
$this
->assertNoFieldByName('body', '', 'Answer field is not visible and contains default text.');
$this
->drupalGet('faq_ask');
$this
->assertText(t('Ask a Question'), t('Ask a Question page is available for users with asker permission.'));
// Verify expert access
$this
->drupalLogin($this->faq_expert);
$this
->drupalGet('faq_ask/unanswered');
$this
->assertText(t('All Unanswered Questions'), t('Expert has access to empty list of unanswered questions'));
$this
->drupalLogout();
// Load with a couple of questions
$this
->faqAskPostUnansweredQuestions();
$this
->drupalLogin($this->faq_expert);
$this
->drupalGet('faq_ask/unanswered');
$this
->assertLink($this->faq1['title'], $index = 0, 'Link to question 1 found');
$this
->assertLink($this->faq2['title'], $index = 0, 'Link to question 2 found');
// Verify access to the nodes by clicking on the titles
$this
->clickLink($this->faq2['title']);
$this
->assertResponse('200', 'Access to second question OK');
$this
->assertText($this->faq2['title'], 'Second question title found');
// Verify that the Answer field is available and contains the default text
$this
->assertFieldByName('body', 'Not answered yet.', 'Answer field is visible and contains default text.');
}