function FaqAskCRUDTestClass::testVerifyExpertAccess in FAQ_Ask 6.2
File
- ./faq_ask.test, line 526
- Test FAQ functionality Base test class. All tests inherits this one.
Hugely based on code from the test file block.test by boombatower
Class
- FaqAskCRUDTestClass
Code
function testVerifyExpertAccess() {
$new_expert = $this
->drupalCreateUser(array(
'view faq page',
'edit faq',
'access content',
'answer question',
));
$this
->drupalLogin($new_expert);
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('user/' . $new_expert->uid . '/edit');
$edit = array(
'roles[' . $this->expert_role . ']' => $this->expert_role,
'pass[pass1]' => 'password',
'pass[pass2]' => 'password',
);
$this
->drupalPost('user/' . $new_expert->uid . '/edit', $edit, t('Save'));
$this
->drupalGet('user/' . $new_expert->uid . '/edit');
$this
->drupalGet('admin/settings/faq/ask');
$edit = array(
'faq_ask_notify' => TRUE,
'faq_ask_asker_notify' => TRUE,
'faq_expert_role[]' => array(
$this->faq_expert->uid,
$new_expert->uid,
),
);
$this
->drupalPost('admin/settings/faq/ask', $edit, 'Save configuration');
$edit['expert_' . $new_expert->uid . '_2'] = TRUE;
$edit['expert_1_2'] = '0';
$this
->drupalPost('admin/settings/faq/ask', $edit, 'Save configuration');
$this
->drupalLogin($this->faq_asker);
$this->faq = array();
$this->faq['title'] = $this
->randomName(8);
$this->faq['taxonomy[tags][1]'] = $this->term2['name'];
$this->faq['detailed_question'] = $this
->randomName(16);
$this
->drupalPost('faq_ask', $this->faq, t('Save'));
$this
->assertText(t('FAQ @title has been created.', array(
'@title' => $this->faq['title'],
)));
$this
->drupalLogin($new_expert);
$this
->drupalGet('faq_ask/unanswered');
$this
->assertLink($this->faq['title'], $index = 0, t('Link to question @q found when logged in as user @u assigned to term @t', array(
'@u' => $new_expert->name,
'@q' => $this->faq['title'],
'@t' => $this->term2['name'],
)));
$mails = $this
->drupalGetMails();
foreach ($mails as $mail) {
$this
->pass('<pre>' . print_r($mail, TRUE) . '</pre>');
}
$mail = $mails['0'];
$this
->assertEqual($mail['subject'], 'You have a question waiting on Drupal', 'Notification e-mail found.');
$this
->assertMail("subject", "You have a question waiting on Drupal", 'The last message subject was "You have a question waiting on Drupal"');
$this
->assertMail('to', $new_expert->mail, 'The last message was sent to the correct expert.');
}