ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
assOrderingQuestionTest Class Reference

Unit tests. More...

+ Inheritance diagram for assOrderingQuestionTest:
+ Collaboration diagram for assOrderingQuestionTest:

Public Member Functions

 test_instantiateObject_shouldReturnInstance ()
 
 testOrderingElementListDefaults ()
 
 testOrderingElementListMutation (ilAssOrderingElementList $list)
 testOrderingElementListDefaults More...
 
 testOrderingElementDefaults ()
 
 testOrderingElementMutation (ilAssOrderingElement $element)
 testOrderingElementDefaults More...
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 setGlobalVariable ($name, $value)
 
 getGlobalTemplateMock ()
 
 getHttpMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

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 assOrderingQuestionTest.php.

Member Function Documentation

◆ setUp()

assOrderingQuestionTest::setUp ( )
protected

Definition at line 15 of file assOrderingQuestionTest.php.

References assBaseTestCase\getDatabaseMock(), assBaseTestCase\getGlobalTemplateMock(), assBaseTestCase\getIliasMock(), and assBaseTestCase\setGlobalVariable().

15  : void
16  {
17  if (defined('ILIAS_PHPUNIT_CONTEXT')) {
18  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
19  ilUnitUtil::performInitialisation();
20  } else {
21  chdir(dirname(__FILE__));
22  chdir('../../../');
23 
24  parent::setUp();
25 
26  require_once './Services/UICore/classes/class.ilCtrl.php';
27  $ilCtrl_mock = $this->createMock('ilCtrl');
28  $ilCtrl_mock->expects($this->any())->method('saveParameter');
29  $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
30  $this->setGlobalVariable('ilCtrl', $ilCtrl_mock);
31 
32  require_once './Services/Language/classes/class.ilLanguage.php';
33  $lng_mock = $this->createMock('ilLanguage', array('txt'), array(), '', false);
34  //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
35  $this->setGlobalVariable('lng', $lng_mock);
36 
37  $this->setGlobalVariable('ilias', $this->getIliasMock());
38  $this->setGlobalVariable('tpl', $this->getGlobalTemplateMock());
39  $this->setGlobalVariable('ilDB', $this->getDatabaseMock());
40  }
41  }
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ test_instantiateObject_shouldReturnInstance()

assOrderingQuestionTest::test_instantiateObject_shouldReturnInstance ( )

Definition at line 43 of file assOrderingQuestionTest.php.

44  {
45  // Arrange
46  require_once './Modules/TestQuestionPool/classes/class.assOrderingQuestion.php';
47 
48  // Act
49  $instance = new assOrderingQuestion();
50 
51  $this->assertInstanceOf('assOrderingQuestion', $instance);
52  }
Class for ordering questions.

◆ testOrderingElementDefaults()

assOrderingQuestionTest::testOrderingElementDefaults ( )

Definition at line 73 of file assOrderingQuestionTest.php.

74  {
75  $element_id = 12;
76  $element = new ilAssOrderingElement($element_id);
77  $this->assertInstanceOf('ilAssOrderingElement', $element);
78  $this->assertEquals($element_id, $element->getId());
79  return $element;
80  }

◆ testOrderingElementListDefaults()

assOrderingQuestionTest::testOrderingElementListDefaults ( )

Definition at line 54 of file assOrderingQuestionTest.php.

55  {
56  $question_id = 7;
57  $list = new ilAssOrderingElementList($question_id);
58  $this->assertInstanceOf('ilAssOrderingElementList', $list);
59  $this->assertEquals($question_id, $list->getQuestionId());
60  $this->assertEquals([], $list->getElements());
61  return $list;
62  }

◆ testOrderingElementListMutation()

assOrderingQuestionTest::testOrderingElementListMutation ( ilAssOrderingElementList  $list)

testOrderingElementListDefaults

Definition at line 67 of file assOrderingQuestionTest.php.

References ilAssOrderingElementList\withElements().

68  {
69  $original = $list;
70  $this->assertNotEquals($original, $list->withElements([]));
71  }
+ Here is the call graph for this function:

◆ testOrderingElementMutation()

assOrderingQuestionTest::testOrderingElementMutation ( ilAssOrderingElement  $element)

testOrderingElementDefaults

Definition at line 85 of file assOrderingQuestionTest.php.

References ilAssOrderingElement\getRandomIdentifier(), ilAssOrderingElement\withRandomIdentifier(), and ilAssOrderingElement\withSolutionIdentifier().

86  {
87  $original = $element;
88  $val = 21;
89 
90  $element = $original->withRandomIdentifier($val);
91  $this->assertNotEquals($original, $element);
92  $this->assertEquals($val, $element->getRandomIdentifier());
93 
94  $element = $original->withSolutionIdentifier($val);
95  $this->assertNotEquals($original, $element);
96  $this->assertEquals($val, $element->getSolutionIdentifier());
97 
98  $element = $original->withPosition($val);
99  $this->assertNotEquals($original, $element);
100  $this->assertEquals($val, $element->getPosition());
101 
102  $element = $original->withIndentation($val);
103  $this->assertNotEquals($original, $element);
104  $this->assertEquals($val, $element->getIndentation());
105 
106  $val = 'some string';
107  $element = $original->withContent($val);
108  $this->assertNotEquals($original, $element);
109  $this->assertEquals($val, $element->getContent());
110  }
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

assOrderingQuestionTest::$backupGlobals = false
protected

Definition at line 13 of file assOrderingQuestionTest.php.


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