123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- <?php
- class TestAnswer extends UnitTestCase {
- public $aAnswer;
-
- public function TestAnswer() {
- $this->UnitTestCase('');
- }
-
- public function setUp() {
-
- $this->aAnswer = new Answer(2);
-
-
- }
-
- public function tearDown() {
- $this->aAnswer = null;
- }
-
-
-
-
-
-
-
-
-
- function testcreateAnswer() {
- $answer = 'test';
- $correct = 1;
- $comment ='test';
- $weighting = 2;
- $position = 1;
- $res = $this->aAnswer->createAnswer($answer,$correct,$comment,$weighting,$position,$new_hotspot_coordinates = 1, $new_hotspot_type = 1,$destination='');
- $this->assertTrue(is_null($res));
-
- }
-
-
-
- function testduplicate() {
- $newQuestionId = 1;
- $res = $this->aAnswer->duplicate($newQuestionId);
- $this->assertTrue(is_null($res));
-
- }
-
-
-
- function testgetAnswersList() {
- $res = $this->aAnswer->getAnswersList();
- $this->assertTrue(is_array($res));
-
- }
-
-
-
- function testgetGradesList() {
- $res = $this->aAnswer->getGradesList();
- $this->assertTrue(is_array($res));
-
- }
-
-
-
- function testgetQuestionType() {
- $res = $this->aAnswer->getQuestionType();
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
-
- }
-
-
-
- function testisCorrect() {
- $id = 1;
- $res = $this->aAnswer->isCorrect($id);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
-
- }
-
-
-
- function testread() {
- $res = $this->aAnswer->read();
- $this->assertTrue(is_null($res));
-
- }
-
-
-
- function testreadOrderedBy() {
- global $_course;
- $field = 'position';
- $res = $this->aAnswer->readOrderedBy($field,$order=ASC);
- $this->assertTrue(is_null($res));
-
- }
-
-
-
- function testsave() {
- $res = $this->aAnswer->save();
- $this->assertTrue(is_null($res));
-
- }
-
-
-
- function testselectAnswer() {
- $id = 1;
- $res = $this->aAnswer->selectAnswer($id);
- if(!is_null($res)){
- $this->assertTrue(is_string($res));
- }
-
- }
-
-
- function testselectAnswerByAutoId() {
- $auto_id = 1;
- $res = $this->aAnswer->selectAnswerByAutoId($auto_id);
- if(!is_null($res)){
- $this->assertTrue(is_array($res));
- } else {
- $this->assertTrue(is_bool($res));
- }
-
- }
-
-
-
- function testselectAnswerIdByPosition() {
- $pos = 1;
- $res = $this->aAnswer->selectAnswerIdByPosition($pos);
- if(!is_null($res)){
- $this->assertTrue(is_bool($res));
- }
-
- }
-
-
-
- function testselectAutoId() {
- $id = 1;
- $res = $this->aAnswer->selectAutoId($id);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
-
- }
-
-
-
- function testselectComment() {
- $id = 1;
- $res = $this->aAnswer->selectComment($id);
- if(!is_null($res)){
- $this->assertTrue(is_string($res));
- }
-
- }
-
-
-
- function testselectDestination() {
- $id = 1;
- $res = $this->aAnswer->selectDestination($id);
- if(!is_null($res)){
- $this->assertTrue(is_string($res));
- }
-
- }
-
-
-
- function testselectHotspotCoordinates() {
- $id = 1;
- $res = $this->aAnswer->selectHotspotCoordinates($id);
- if(!is_null($res)){
- $this->assertTrue(is_string($res));
- }
- }
-
-
-
- function testselectHotspotType() {
- $id = 1;
- $res = $this->aAnswer->selectHotspotType($id);
- if(!is_null($res)){
- $this->assertTrue(is_string($res));
- }
- }
-
-
-
- function testselectNbrAnswers() {
- $res = $this->aAnswer->selectNbrAnswers();
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- }
-
-
-
- function testselectPosition() {
- $id = 1;
- $res = $this->aAnswer->selectPosition($id);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- }
-
-
-
- function testselectQuestionId() {
- $res = $this->aAnswer->selectQuestionId();
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- }
-
-
-
- function testselectWeighting() {
- $id = 1;
- $res = $this->aAnswer->selectWeighting($id);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- }
-
-
-
- function testupdateAnswers() {
- $answer = '';
- $comment = '';
- $weighting=2;
- $position=1;
- $destination='0@@0@@0@@0';
- $res = $this->aAnswer->updateAnswers($answer,$comment,$weighting,$position,$destination);
- if(!is_null($res)){
- $this->assertTrue(is_numeric($res));
- }
- }
-
-
-
- function testcancel() {
- $res = $this->aAnswer->cancel();
- $this->assertTrue(is_null($res));
-
- }
- }
- ?>
|