38 $this->storage = array();
50 $settingsMock = $this->getMockBuilder(
'ilSetting')->disableOriginalConstructor()->onlyMethods(array(
'set',
'get',
'delete'))->getMock();
52 $settingsMock->expects($this->any())->method(
'set')->will(
53 $this->returnCallback(
function (
$key, $value) {
54 $this->storage[
$key] = $value;
58 $settingsMock->expects($this->any())->method(
'get')->will(
59 $this->returnCallback(
function (
$key, $value) {
60 return $this->storage[
$key] ?? $value;
64 $settingsMock->expects($this->any())->method(
'delete')->will(
65 $this->returnCallback(
function (
$key, $value) {
66 if (isset($this->storage[
$key])) {
67 unset($this->storage[$key]);
72 $valueToTest = $preCallback($value);
74 $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
75 $registry->setChunkSize($chunkSize);
76 $registry->setStringifiedImports(self::TEST_KEY, $valueToTest);
77 $actual = $registry->getStringifiedImports(self::TEST_KEY);
79 $this->assertEquals($valueToTest, $actual);
80 $this->assertEquals($value, $postCallback($actual));
88 $settingsMock = $this->getMockBuilder(
'ilSetting')->disableOriginalConstructor()->onlyMethods(array(
'set',
'get',
'delete'))->getMock();
91 $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
92 $registry->setChunkSize(
"a");
93 $this->fail(
"Failed asserting that exception of type \"InvalidArgumentException\" is thrown.");
98 $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
99 $registry->setChunkSize(-5);
100 $this->fail(
"Failed asserting that exception of type \"InvalidArgumentException\" is thrown.");
114 $assignmentList = new \ilAssQuestionSkillAssignmentImportList();
116 for ($i = 0; $i < 5; $i++) {
117 $assignment = new \ilAssQuestionSkillAssignmentImport();
119 $assignment->setImportSkillTitle(
'phpunit' . $i);
120 $assignment->setImportSkillPath(
'phpunit' . $i);
121 $random = new \ilRandom();
122 $assignment->setSkillPoints($random->int(0, PHP_INT_MAX));
123 $assignment->setImportQuestionId($random->int(0, PHP_INT_MAX));
124 $assignment->setImportSkillBaseId($random->int(0, PHP_INT_MAX));
125 $assignment->setImportSkillTrefId($random->int(0, PHP_INT_MAX));
127 $assignmentList->addAssignment($assignment);
131 array(
"This is a Test", 2),
132 array(array(
"üäöÖÜÄÖß"), 2),
133 array(
"This is a Test with a huge chunk size", 10000),
134 array($assignmentList, 7)
137 foreach ($rawData as $rawItem) {
139 $rawItem[0], $rawItem[1], $pre, $post
151 $pre =
function ($value) {
152 return \serialize($value);
155 $post =
function ($value) {
156 return \unserialize($value);
getTestData(callable $pre, callable $post)
testSkillAssignmentsCanBetStoredAndFetchedBySerializationStrategy($value, $chunkSize, callable $preCallback, callable $postCallback)
serializedData
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const EVAL_MODE_BY_QUESTION_SOLUTION
testInvalidChunkSizeWillRaiseException()