Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleh Hutnikau committed Sep 7, 2015
1 parent 4335581 commit c94c107
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/qtism/runtime/tests/AssessmentItemSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,42 @@ public function testSimultaneousSubmissionOnlyOneAttempt() {
$this->assertEquals(AssessmentItemSessionException::STATE_VIOLATION, $e->getCode());
}
}

public function testRunCallback() {
$itemSession = self::instantiateBasicAssessmentItemSession();
$itemSession->beginItemSession();

$itemSession->registerCallback('beginAttempt', function ($item, $itemSessionTest, $itemSession) {
$itemSessionTest->assertEquals($item, $itemSession);
$itemSessionTest->assertEquals($item->getState(), AssessmentItemSessionState::INTERACTING);
},
array($this, $itemSession)
);

$itemSession->registerCallback('suspend', function ($item, $itemSessionTest, $itemSession) {
$itemSessionTest->assertEquals($item, $itemSession);
$itemSessionTest->assertEquals($item->getState(), AssessmentItemSessionState::SUSPENDED);
},
array($this, $itemSession)
);

$itemSession->registerCallback('interact', function ($item, $itemSessionTest, $itemSession) {
$itemSessionTest->assertEquals($item, $itemSession);
$itemSessionTest->assertEquals($item->getState(), AssessmentItemSessionState::INTERACTING);
},
array($this, $itemSession)
);

$itemSession->registerCallback('endAttempt', function ($item, $itemSessionTest, $itemSession) {
$itemSessionTest->assertEquals($item, $itemSession);
$itemSessionTest->assertEquals($item->getState(), AssessmentItemSessionState::CLOSED);
},
array($this, $itemSession)
);

$itemSession->beginAttempt();
$itemSession->suspend();
$itemSession->interact();
$itemSession->endAttempt();
}
}

0 comments on commit c94c107

Please sign in to comment.