function CRUDFaqTestCase::testFaqCreate in Frequently Asked Questions 6
Test creating a FAQ node
File
- ./
faq.test, line 182 - 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 testFaqCreate() {
// Log in user with create FAQ permissions
$this
->drupalLogin($this->faq_user);
// Fill in the Create FAQ node 1 form and post it
$this->faq1 = array();
$this->faq1['title'] = $this
->randomName(8);
$this->faq1['taxonomy[tags][1]'] = $this->term['name'];
// Add existing term
$this->faq1['detailed_question'] = $this
->randomName(16);
$this->faq1['body'] = $this
->randomName(16);
$this
->drupalPost('node/add/faq', $this->faq1, t('Save'));
// Check that new FAQ node has actually been created
$this
->assertText(t('FAQ @title has been created.', array(
'@title' => $this->faq1['title'],
)));
// Fill in the Create FAQ node 2 form and post it
$this->faq2 = array();
$this->faq2['title'] = $this
->randomName(8);
$this->faq2['taxonomy[tags][1]'] = $this
->randomName(8);
// Add new term
$this->faq2['detailed_question'] = $this
->randomName(16);
$this->faq2['body'] = $this
->randomName(16);
$this
->drupalPost('node/add/faq', $this->faq2, t('Save'));
// Check that new FAQ node has actually been created
$this
->assertText(t('FAQ @title has been created.', array(
'@title' => $this->faq2['title'],
)));
$this
->drupalLogout();
// Check that the FAQ page is available and that the correct term is listed as grouping for the new FAQ node
$this
->drupalLogin($this->view_faq_user);
$this
->drupalGet('faq');
$this
->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
$this
->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.'));
$this
->assertText($this->faq1['taxonomy[tags][1]'], t('Term for node 1 available on FAQ page.'));
$this
->assertText($this->faq2['title'], t('Created FAQ node 2 available on FAQ page.'));
$this
->assertText($this->faq2['taxonomy[tags][1]'], t('Term for node 2 available on FAQ page.'));
// Navigate to FAQ node created on FAQ page
$this
->clickLink(t($this->faq1['title']));
$this
->assertText(t($this->faq1['body']));
// Log in user with administer FAQ settings.
$this
->drupalLogin($this->admin_user);
// Enable categorisation of FAQ nodes
// faq_use_categories
$conf = array();
$conf['faq_use_categories'] = '1';
// Enable categorised FAQs
$this
->drupalPost('admin/settings/faq/categories', $conf, t('Save configuration'));
$this
->drupalLogout();
$this
->drupalLogin($this->view_faq_user);
$this
->drupalGet('faq');
$this
->assertText(t('Frequently Asked Questions'), t('FAQ page is available for view faq page permissions.'));
$this
->assertText($this->faq1['title'], t('Created FAQ node 1 available on FAQ page.'));
$this
->assertText($this->faq1['taxonomy[tags][1]'], t('Term for node 1 not available on FAQ page.'));
$this
->assertText($this->faq2['title'], t('Created FAQ node 2 available on FAQ page.'));
$this
->assertText($this->faq2['taxonomy[tags][1]'], t('Term for node 2 not available on FAQ page.'));
}