You are here

protected function OpignoAssessmentTestCase::_takeQuiz in Opigno 7.0

Take the quiz. Specify the different steps by setting the form fields.

Parameters

array $steps: An array of steps. Each is an edit array for a form submission

1 call to OpignoAssessmentTestCase::_takeQuiz()
OpignoAssessmentTestCase::testAssessmentSingleQuiz in modules/opigno_assessment/tests/opigno_assessment.test
Test taking a single quiz. Assessment should work for both "all" and "single" quiz options in the OG node.

File

modules/opigno_assessment/tests/opigno_assessment.test, line 174
Defines a Unit test for quiz assessments and module settings.

Class

OpignoAssessmentTestCase
@file Defines a Unit test for quiz assessments and module settings.

Code

protected function _takeQuiz($nid, $steps) {

  // Go to quiz and take it
  $this
    ->drupalGet("node/{$nid}");
  $this
    ->drupalPost($this->getURL, array(), 'Start quiz');

  // Keep track of steps
  $max = count($steps) - 1;
  $steps = array_values($steps);
  foreach ($steps as $i => $edit) {
    if ($i < $max) {
      $button = 'Next';
    }
    else {
      $button = 'Finish';
    }
    $this
      ->drupalPost($this
      ->getURL(), $edit, $button);
  }
}