You are here

function FaqAskBlockTestClass::testQuestionForm in FAQ_Ask 6.2

File

./faq_ask.test, line 256
Test FAQ functionality Base test class. All tests inherits this one. Hugely based on code from the test file block.test by boombatower

Class

FaqAskBlockTestClass

Code

function testQuestionForm() {

  // Entering this test with Taxonomy Tags set, user tagging and
  // Turn question block on
  $this
    ->drupalLogin($this->admin_user);

  // Set visibility to only listed pages?
  $this
    ->drupalPost('admin/build/block/configure/faq_ask/1', array(
    'visibility' => '1',
    'pages' => '<front>',
  ), t('Save block'));
  $this
    ->drupalPost('admin/build/block', array(
    'faq_ask_1[region]' => 'right',
  ), t('Save blocks'));
  $this
    ->drupalGet('admin/build/block/configure/faq_ask/1');
  $this
    ->drupalLogout();
  $this
    ->drupalGet('');
  $this
    ->assertNoText(t('Ask a Question'), t('The Ask a Question block is not visible for anonymous users'));
  $this
    ->drupalLogin($this->faq_asker);
  $this
    ->drupalGet('');
  $this
    ->assertText(t('Ask a Question'), t('Ask a Question page is available for anonymous users.'));

  // Verify the taxonomy field is visible
  $this
    ->assertText($this->taxonomy['name'], 'Taxonomy field visible');

  // Check unanswered block is empty
  $this
    ->turnUnansQestBlockOn();
  $this
    ->drupalLogin($this->faq_asker);
  $this
    ->assertNoText('You may edit your own questions until they are answered.', 'Unanswered list is not available yet');
  $this->faq1 = array();
  $this->faq1['title'] = $this
    ->randomName(8);
  $this->faq1['taxonomy[tags][1]'] = $this->term1['name'];

  // Add existing term
  $this->faq1['detailed_question'] = $this
    ->randomName(16);
  $this->faq1['faq_notify'] = TRUE;
  $this
    ->drupalPost('', $this->faq1, t('Save'));

  // Save question
  // Verify that we got the question saved
  $this
    ->assertText(t('FAQ @title has been created.', array(
    '@title' => $this->faq1['title'],
  )));

  // Verify unanswered block visible
  $this
    ->assertText('You may edit your own questions until they are answered.', 'Unanswered list is not available yet');

  // Make sure the unanswered question is still available on the unanswered block
  $this
    ->drupalGet('');
  $this
    ->assertText($this->faq1['title'], 'Own question still visible in block.');
}