You are here

public function TrueFalseUnitTest::createTrueFalseQuestion in Quiz 7

Same name and namespace in other branches
  1. 6.6 question_types/truefalse/truefalse.test \TrueFalseUnitTest::createTrueFalseQuestion()
  2. 6.4 question_types/truefalse/truefalse.test \TrueFalseUnitTest::createTrueFalseQuestion()
  3. 7.4 question_types/truefalse/truefalse.test \TrueFalseUnitTest::createTrueFalseQuestion()
2 calls to TrueFalseUnitTest::createTrueFalseQuestion()
TrueFalseUnitTest::testTrueFalseNodeOperations in question_types/truefalse/truefalse.test
Run a bundle of Node API tests.
TrueFalseUnitTest::unitTestCreateTrueFalseQuestionNode in question_types/truefalse/truefalse.test
Create and then update a node.

File

question_types/truefalse/truefalse.test, line 90

Class

TrueFalseUnitTest

Code

public function createTrueFalseQuestion() {
  $this->title = $this
    ->randomName($this
    ->getRandSize());
  $this->body = $this
    ->randomName($this
    ->getRandSize());
  $this->correct_answer = array_rand(array(
    0,
    1,
  ));

  // array containing drupal node attributes
  $settings = array(
    'type' => $this->question_node_type,
    'title' => $this->title,
    'body' => $this->body,
    'correct_answer' => $this->correct_answer,
    'revisions' => TRUE,
  );

  // create a test drupal node
  return $this
    ->drupalCreateNode($settings);
}