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
- FaqAskAccessTestClass
Code
function testFaqAskAccess() {
$this
->faqAskVerifyNoAccess('faq_ask');
$this
->faqAskVerifyNoAccess('faq_ask/unanswered');
$normal_user = $this
->drupalCreateUser();
$this
->drupalLogin($normal_user);
$this
->faqAskVerifyNoAccess('faq_ask/unanswered');
$this
->faqAskVerifyNoAccess('faq_ask');
$this
->drupalLogout();
$this
->drupalLogin($this->view_faq_user);
$this
->faqAskVerifyNoAccess('faq_ask');
$this
->faqAskVerifyNoAccess('faq_ask/unanswered');
$this
->drupalGet('faq');
$this
->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
$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');
$this
->drupalLogout();
$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);
$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_expert);
$this
->drupalGet('faq_ask/unanswered');
$this
->assertText(t('All Unanswered Questions'), t('Expert has access to empty list of unanswered questions'));
$this
->drupalLogout();
$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');
$this
->clickLink($this->faq2['title']);
$this
->assertResponse('200', 'Access to second question OK');
$this
->assertText($this->faq2['title'], 'Second question title found');
$this
->assertFieldByName('body', 'Not answered yet.', 'Answer field is visible and contains default text.');
}