ILIAS  release_8 Revision v8.23
ilAssQuestionSkillAssignmentRegistryTest Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilAssQuestionSkillAssignmentRegistryTest:
+ Collaboration diagram for ilAssQuestionSkillAssignmentRegistryTest:

Public Member Functions

 setUp ()
 
 testSkillAssignmentsCanBetStoredAndFetchedBySerializationStrategy ($value, $chunkSize, callable $preCallback, callable $postCallback)
 serializedData More...
 
 testInvalidChunkSizeWillRaiseException ()
 
 serializedData ()
 

Data Fields

const TEST_KEY = 'phpunit_tst'
 

Protected Member Functions

 getTestData (callable $pre, callable $post)
 
- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, $value)
 
 getGlobalTemplateMock ()
 
 getDatabaseMock ()
 
 getIliasMock ()
 

Protected Attributes

 $storage = array()
 
- Protected Attributes inherited from assBaseTestCase
Container $dic = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilAssQuestionSkillAssignmentRegistryTest

Definition at line 22 of file ilAssQuestionSkillAssignmentRegistryTest.php.

Member Function Documentation

◆ getTestData()

ilAssQuestionSkillAssignmentRegistryTest::getTestData ( callable  $pre,
callable  $post 
)
protected
Parameters
callable$pre
callable$post
Returns
array

Definition at line 112 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $data, $i, and ilAssQuestionSkillAssignment\EVAL_MODE_BY_QUESTION_SOLUTION.

Referenced by serializedData().

112  : array
113  {
114  $data = [];
115 
116  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportList.php';
117  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImport.php';
118  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignment.php';
119  $assignmentList = new \ilAssQuestionSkillAssignmentImportList();
120 
121  for ($i = 0; $i < 5; $i++) {
122  $assignment = new \ilAssQuestionSkillAssignmentImport();
124  $assignment->setImportSkillTitle('phpunit' . $i);
125  $assignment->setImportSkillPath('phpunit' . $i);
126  $random = new \ilRandom();
127  $assignment->setSkillPoints($random->int(0, PHP_INT_MAX));
128  $assignment->setImportQuestionId($random->int(0, PHP_INT_MAX));
129  $assignment->setImportSkillBaseId($random->int(0, PHP_INT_MAX));
130  $assignment->setImportSkillTrefId($random->int(0, PHP_INT_MAX));
131 
132  $assignmentList->addAssignment($assignment);
133  }
134 
135  $rawData = array(
136  array("This is a Test", 2),
137  array(array("üäöÖÜÄÖß"), 2),
138  array("This is a Test with a huge chunk size", 10000),
139  array($assignmentList, 7)
140  );
141 
142  foreach ($rawData as $rawItem) {
143  $data[] = array(
144  $rawItem[0], $rawItem[1], $pre, $post
145  );
146  }
147 
148  return $data;
149  }
$post
Definition: ltitoken.php:49
$i
Definition: metadata.php:41
+ Here is the caller graph for this function:

◆ serializedData()

ilAssQuestionSkillAssignmentRegistryTest::serializedData ( )
Returns
array

Definition at line 154 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $post, and getTestData().

154  : array
155  {
156  $pre = function ($value) {
157  return \serialize($value);
158  };
159 
160  $post = function ($value) {
161  return \unserialize($value);
162  };
163 
164  return $this->getTestData($pre, $post);
165  }
$post
Definition: ltitoken.php:49
+ Here is the call graph for this function:

◆ setUp()

ilAssQuestionSkillAssignmentRegistryTest::setUp ( )

Definition at line 34 of file ilAssQuestionSkillAssignmentRegistryTest.php.

34  : void
35  {
36  parent::setUp();
37 
38  $this->storage = array();
39  }

◆ testInvalidChunkSizeWillRaiseException()

ilAssQuestionSkillAssignmentRegistryTest::testInvalidChunkSizeWillRaiseException ( )

Definition at line 87 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References Vendor\Package\$e.

87  : void
88  {
89  require_once 'Services/Administration/classes/class.ilSetting.php';
90  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->onlyMethods(array('set', 'get', 'delete'))->getMock();
91 
92  try {
93  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
94  $registry->setChunkSize("a");
95  $this->fail("Failed asserting that exception of type \"InvalidArgumentException\" is thrown.");
96  } catch (\InvalidArgumentException $e) {
97  }
98 
99  try {
100  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
101  $registry->setChunkSize(-5);
102  $this->fail("Failed asserting that exception of type \"InvalidArgumentException\" is thrown.");
103  } catch (\InvalidArgumentException $e) {
104  }
105  }

◆ testSkillAssignmentsCanBetStoredAndFetchedBySerializationStrategy()

ilAssQuestionSkillAssignmentRegistryTest::testSkillAssignmentsCanBetStoredAndFetchedBySerializationStrategy (   $value,
  $chunkSize,
callable  $preCallback,
callable  $postCallback 
)

serializedData

Parameters
$value
$chunkSize
callable$preCallback
callable$postCallback

Definition at line 48 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References ILIAS\LTI\ToolProvider\$key.

48  : void
49  {
50  require_once 'Services/Administration/classes/class.ilSetting.php';
51  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->onlyMethods(array('set', 'get', 'delete'))->getMock();
52 
53  $settingsMock->expects($this->any())->method('set')->will(
54  $this->returnCallback(function ($key, $value) {
55  $this->storage[$key] = $value;
56  })
57  );
58 
59  $settingsMock->expects($this->any())->method('get')->will(
60  $this->returnCallback(function ($key, $value) {
61  return $this->storage[$key] ?? $value;
62  })
63  );
64 
65  $settingsMock->expects($this->any())->method('delete')->will(
66  $this->returnCallback(function ($key, $value) {
67  if (isset($this->storage[$key])) {
68  unset($this->storage[$key]);
69  }
70  })
71  );
72 
73  $valueToTest = $preCallback($value);
74 
75  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
76  $registry->setChunkSize($chunkSize);
77  $registry->setStringifiedImports(self::TEST_KEY, $valueToTest);
78  $actual = $registry->getStringifiedImports(self::TEST_KEY);
79 
80  $this->assertEquals($valueToTest, $actual);
81  $this->assertEquals($value, $postCallback($actual));
82  }
string $key
Consumer key/client ID value.
Definition: System.php:193

Field Documentation

◆ $storage

ilAssQuestionSkillAssignmentRegistryTest::$storage = array()
protected

Definition at line 29 of file ilAssQuestionSkillAssignmentRegistryTest.php.

◆ TEST_KEY

const ilAssQuestionSkillAssignmentRegistryTest::TEST_KEY = 'phpunit_tst'

Definition at line 24 of file ilAssQuestionSkillAssignmentRegistryTest.php.


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