ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ()
 
 getIRSSMock ()
 
 getFileDeliveryMock ()
 
 getIliasMock ()
 
 addGlobal_uiFactory ()
 
 addGlobal_uiRenderer ()
 

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 110 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $data, and ilAssQuestionSkillAssignment\EVAL_MODE_BY_QUESTION_SOLUTION.

Referenced by serializedData().

110  : array
111  {
112  $data = [];
113 
114  $assignmentList = new \ilAssQuestionSkillAssignmentImportList();
115 
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));
126 
127  $assignmentList->addAssignment($assignment);
128  }
129 
130  $rawData = array(
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)
135  );
136 
137  foreach ($rawData as $rawItem) {
138  $data[] = array(
139  $rawItem[0], $rawItem[1], $pre, $post
140  );
141  }
142 
143  return $data;
144  }
$post
Definition: ltitoken.php:49
+ Here is the caller graph for this function:

◆ serializedData()

ilAssQuestionSkillAssignmentRegistryTest::serializedData ( )
Returns
array

Definition at line 149 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $post, and getTestData().

149  : array
150  {
151  $pre = function ($value) {
152  return \serialize($value);
153  };
154 
155  $post = function ($value) {
156  return \unserialize($value);
157  };
158 
159  return $this->getTestData($pre, $post);
160  }
$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 86 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References Vendor\Package\$e.

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

◆ 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  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->onlyMethods(array('set', 'get', 'delete'))->getMock();
51 
52  $settingsMock->expects($this->any())->method('set')->will(
53  $this->returnCallback(function ($key, $value) {
54  $this->storage[$key] = $value;
55  })
56  );
57 
58  $settingsMock->expects($this->any())->method('get')->will(
59  $this->returnCallback(function ($key, $value) {
60  return $this->storage[$key] ?? $value;
61  })
62  );
63 
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]);
68  }
69  })
70  );
71 
72  $valueToTest = $preCallback($value);
73 
74  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
75  $registry->setChunkSize($chunkSize);
76  $registry->setStringifiedImports(self::TEST_KEY, $valueToTest);
77  $actual = $registry->getStringifiedImports(self::TEST_KEY);
78 
79  $this->assertEquals($valueToTest, $actual);
80  $this->assertEquals($value, $postCallback($actual));
81  }
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: