ILIAS  release_4-4 Revision
assAnswerOrderingTest Class Reference

Unit tests. More...

+ Inheritance diagram for assAnswerOrderingTest:
+ Collaboration diagram for assAnswerOrderingTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 test_setGetRandomId ()
 
 test_setGetAnswerId ()
 
 test_setGetOrdeingDepth ()
 
 test_getAdditionalOrderingFieldsByRandomId ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = FALSE
 

Detailed Description

Unit tests.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

Definition at line 11 of file assAnswerOrderingTest.php.

Member Function Documentation

◆ setUp()

assAnswerOrderingTest::setUp ( )
protected

Definition at line 15 of file assAnswerOrderingTest.php.

16  {
17  if (defined('ILIAS_PHPUNIT_CONTEXT'))
18  {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  ilUnitUtil::performInitialisation();
21  }
22  else
23  {
24  chdir( dirname( __FILE__ ) );
25  chdir('../../../');
26  }
27  }

◆ test_getAdditionalOrderingFieldsByRandomId()

assAnswerOrderingTest::test_getAdditionalOrderingFieldsByRandomId ( )

Definition at line 86 of file assAnswerOrderingTest.php.

87  {
88  // Arrange
89  require_once './Modules/TestQuestionPool/classes/class.assAnswerOrdering.php';
90  $instance = new ASS_AnswerOrdering();
91  $random_id = 13579;
92 
93  //require_once './Services/PEAR/lib/MDB2.php';
94  require_once './Services/Database/classes/class.ilDB.php';
95  $ildb_mock = $this->getMock('ilDBMySQL', array('queryF', 'fetchAssoc'), array(), '', false, false);
96  $ildb_mock->expects( $this->once() )
97  ->method( 'queryF' )
98  ->with( $this->equalTo('SELECT * FROM qpl_a_ordering WHERE random_id = %s'),
99  $this->equalTo(array('integer')),
100  $this->equalTo(array($random_id))
101  )
102  ->will( $this->returnValue('Test') );
103  $ildb_mock->expects( $this->exactly(2) )
104  ->method( 'fetchAssoc' )
105  ->with( $this->equalTo('Test') )
106  ->will( $this->onConsecutiveCalls(array('answer_id' => 123, 'depth' => 456), false ) );
107  global $ilDB;
108  $ilDB = $ildb_mock;
109 
110  // Act
111  $instance->getAdditionalOrderingFieldsByRandomId($random_id);
112 
113  // Assert
114  $this->assertEquals(123, $instance->getAnswerId());
115  $this->assertEquals(456, $instance->getOrderingDepth());
116  }
Class for ordering question answers.

◆ test_instantiateObject_shouldReturnInstance()

assAnswerOrderingTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 29 of file assAnswerOrderingTest.php.

30  {
31  // Arrange
32  require_once './Modules/TestQuestionPool/classes/class.assAnswerOrdering.php';
33 
34  // Act
35  $instance = new ASS_AnswerOrdering();
36 
37  $this->assertInstanceOf('ASS_AnswerOrdering', $instance);
38  }
Class for ordering question answers.

◆ test_setGetAnswerId()

assAnswerOrderingTest::test_setGetAnswerId ( )

Definition at line 55 of file assAnswerOrderingTest.php.

56  {
57  // Arrange
58  require_once './Modules/TestQuestionPool/classes/class.assAnswerOrdering.php';
59  $instance = new ASS_AnswerOrdering();
60  $expected = 13579;
61 
62  // Act
63  $instance->setAnswerId($expected);
64  $actual = $instance->getAnswerId();
65 
66  // Assert
67  $this->assertEquals($expected, $actual);
68  }
Class for ordering question answers.

◆ test_setGetOrdeingDepth()

assAnswerOrderingTest::test_setGetOrdeingDepth ( )

Definition at line 71 of file assAnswerOrderingTest.php.

72  {
73  // Arrange
74  require_once './Modules/TestQuestionPool/classes/class.assAnswerOrdering.php';
75  $instance = new ASS_AnswerOrdering();
76  $expected = 13579;
77 
78  // Act
79  $instance->setOrderingDepth($expected);
80  $actual = $instance->getOrderingDepth();
81 
82  // Assert
83  $this->assertEquals($expected, $actual);
84  }
Class for ordering question answers.

◆ test_setGetRandomId()

assAnswerOrderingTest::test_setGetRandomId ( )

Definition at line 40 of file assAnswerOrderingTest.php.

41  {
42  // Arrange
43  require_once './Modules/TestQuestionPool/classes/class.assAnswerOrdering.php';
44  $instance = new ASS_AnswerOrdering();
45  $expected = 13579;
46 
47  // Act
48  $instance->setRandomID($expected);
49  $actual = $instance->getRandomID();
50 
51  // Assert
52  $this->assertEquals($expected, $actual);
53  }
Class for ordering question answers.

Field Documentation

◆ $backupGlobals

assAnswerOrderingTest::$backupGlobals = FALSE
protected

Definition at line 13 of file assAnswerOrderingTest.php.


The documentation for this class was generated from the following file: