You are here

function FaqAskCRUDTestClass::testUnpublishedQuestion in FAQ_Ask 6.2

Testing that the published state of the new question is honoring the content type default

Feature request in issue #879150 by escoles: Change behavior regarding 'published' status to honor content type default

File

./faq_ask.test, line 632
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 testUnpublishedQuestion() {

  // Update node type to default not published
  $this
    ->drupalLogin($this->admin_user);
  $options = array(
    'node_options[status]' => FALSE,
  );
  $this
    ->drupalPost('admin/content/node-type/faq/edit', $options, t('Save content type'));

  // Switch off unanswered block
  $this
    ->turnUnansQestBlockOff();

  // Post questions
  $this
    ->faqAskPostUnansweredQuestions();

  // Answer question by clicking link on unanswered page
  $this
    ->drupalLogin($this->faq_expert);
  $this
    ->drupalGet('faq_ask/unanswered');
  $this
    ->clickLink($this->faq1['title']);

  // Post an answer to the quextion
  $this
    ->drupalPost(NULL, array(
    'body' => $this
      ->randomName(100),
  ), 'Save');

  // Verify that the question is not visible on the faq page
  $this
    ->drupalLogin($this->faq_user);
  $this
    ->drupalGet('faq');
  $this
    ->assertNoText($this->faq1['title']);

  // Verify that the question is published manually
  $this
    ->drupalLogin($this->faq_expert);
  $this
    ->drupalGet('faq_ask/unanswered');
  $this
    ->clickLink($this->faq1['title']);
  $this
    ->drupalPost(NULL, array(), t('Save'));

  // Save the node again
  // Verify that the warning message appears
  $this
    ->assertText('This question is by default NOT published', 'Warning text appears');
  $this
    ->clickLink('click this link');

  // Verify that the question is now visible on the faq page
  $this
    ->drupalLogin($this->faq_user);
  $this
    ->drupalGet('faq');
  $this
    ->assertText($this->faq1['title']);
}