ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
assClozeSelectGapTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  protected $backupGlobals = FALSE;
14 
15  protected function setUp()
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  }
28 
30  {
31  // Arrange
32  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
33 
34  // Act
35  $instance = new assClozeSelectGap(1); // 1 - select gap
36 
37  $this->assertInstanceOf('assClozeSelectGap', $instance);
38  }
39 
41  {
42  // Arrange
43  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
44  $instance = new assClozeSelectGap(1); // 1 - select gap
45  $expected = true;
46 
47  $actual = $instance->getShuffle();
48 
49  $this->assertEquals($expected, $actual);
50  }
51 
53  {
54  // Arrange
55  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
56  $instance = new assClozeSelectGap(1); // 1 - select gap
57  $expected = false;
58 
59  $instance->setType($expected);
60  $actual = $instance->getShuffle();
61 
62  $this->assertEquals($expected, $actual);
63  }
64 
66  {
67  // Arrange
68  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
69  $instance = new assClozeSelectGap(1); // 1 - select gap
70  $expected = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
71 
72  $actual = $instance->arrayShuffle($expected);
73 
74  $this->assertNotEquals($expected, $actual);
75  }
76 
78  {
79  // Arrange
80  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
81  $instance = new assClozeSelectGap(1); // 1 - select gap
82 
83  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
84  $item1 = new assAnswerCloze('Bert', 1.0, 0);
85  $item2 = new assAnswerCloze('Fred', 2.0, 2);
86  $item3 = new assAnswerCloze('Karl', 4, 1);
87  $item4 = new assAnswerCloze('Esther', 4, 3);
88 
89  $instance->addItem($item1);
90  $instance->addItem($item2);
91  $instance->addItem($item3);
92  $instance->addItem($item4);
93 
94  $instance->setType(true);
95 
96  $expected = array($item1, $item2, $item3, $item4);
97 
98  $actual = $instance->getItems();
99 
100  $this->assertNotEquals($expected, $actual);
101  }
102 
104  {
105  // Arrange
106  require_once './Modules/TestQuestionPool/classes/class.assClozeSelectGap.php';
107  $instance = new assClozeSelectGap(1); // 1 - select gap
108 
109  require_once './Modules/TestQuestionPool/classes/class.assAnswerCloze.php';
110  $item1 = new assAnswerCloze('Bert', 1.0, 0);
111  $item2 = new assAnswerCloze('Fred', 2.0, 1);
112  $item3 = new assAnswerCloze('Karl', 4, 2);
113  $item4 = new assAnswerCloze('Esther', 4, 3);
114 
115  $instance->addItem($item1);
116  $instance->addItem($item2);
117  $instance->addItem($item3);
118  $instance->addItem($item4);
119 
120  $instance->setType(false);
121 
122  $expected = array($item1, $item2, $item3, $item4);
123 
124  $actual = $instance->getItems();
125 
126  $this->assertEquals($expected, $actual);
127  }
128 }