Skip to content

Commit

Permalink
Additional unit tests for string comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Sep 13, 2016
1 parent ac2f96f commit cd626b1
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions test/qtismtest/runtime/tests/AssessmentItemSessionTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace qtismtest\runtime\tests;

use qtism\common\datatypes\QtiFloat;

use qtismtest\QtiSmAssessmentItemTestCase;
use qtism\common\datatypes\QtiIdentifier;
use qtism\common\datatypes\QtiFloat;
use qtism\common\datatypes\QtiString;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\SubmissionMode;
use qtism\common\datatypes\QtiDuration;
Expand Down Expand Up @@ -503,4 +503,35 @@ public function testSuspendWithResponses() {
$this->assertEquals(1., $itemSession['SCORE']->getValue());
$this->assertEquals(1, $itemSession['numAttempts']->getValue());
}

public function testIsRespondedTextEntry() {
$doc = new XmlDocument();
$doc->load(self::samplesDir() . 'ims/items/2_1/text_entry.xml');

$itemSession = new AssessmentItemSession($doc->getDocumentComponent());
$itemSessionControl = $itemSession->getItemSessionControl();
$itemSessionControl->setMaxAttempts(0);
$itemSession->beginItemSession();

// Respond with a null value.
$itemSession->beginAttempt();
$responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::STRING)));
$itemSession->endAttempt($responses);

$this->assertFalse($itemSession->isResponded());

// Respond with an empty string.
$itemSession->beginAttempt();
$responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::STRING, new QtiString(''))));
$itemSession->endAttempt($responses);

$this->assertFalse($itemSession->isResponded());

// Respond with a non-empty string.
$itemSession->beginAttempt();
$responses = new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::STRING, new QtiString('York'))));
$itemSession->endAttempt($responses);

$this->assertTrue($itemSession->isResponded());
}
}

0 comments on commit cd626b1

Please sign in to comment.