ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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)
 
 testInvalidChunkSizeWillRaiseException ()
 

Static Public Member Functions

static serializedData ()
 

Data Fields

const TEST_KEY = 'phpunit_tst'
 

Static Protected Member Functions

static getTestData (callable $pre, callable $post)
 

Protected Attributes

array $storage = []
 
- Protected Attributes inherited from assBaseTestCase
Container $dic = null
 

Additional Inherited Members

- Protected Member Functions inherited from assBaseTestCase
 setUp ()
 
 tearDown ()
 
 getIRSSMock ()
 

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()

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

Definition at line 107 of file ilAssQuestionSkillAssignmentRegistryTest.php.

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

107  : array
108  {
109  $data = [];
110 
111  $assignmentList = new ilAssQuestionSkillAssignmentImportList();
112 
113  for ($i = 0; $i < 5; $i++) {
114  $assignment = new ilAssQuestionSkillAssignmentImport();
116  $assignment->setImportSkillTitle('phpunit' . $i);
117  $assignment->setImportSkillPath('phpunit' . $i);
118  $random = new \Random\Randomizer();
119  $assignment->setSkillPoints($random->getInt(0, PHP_INT_MAX));
120  $assignment->setImportQuestionId($random->getInt(0, PHP_INT_MAX));
121  $assignment->setImportSkillBaseId($random->getInt(0, PHP_INT_MAX));
122  $assignment->setImportSkillTrefId($random->getInt(0, PHP_INT_MAX));
123 
124  $assignmentList->addAssignment($assignment);
125  }
126 
127  $rawData = [
128  ['This is a Test', 2],
129  [['üäöÖÜÄÖß'], 2],
130  ['This is a Test with a huge chunk size', 10000],
131  [$assignmentList, 7],
132  ];
133 
134  foreach ($rawData as $rawItem) {
135  $data[] = [$rawItem[0], $rawItem[1], $pre, $post];
136  }
137 
138  return $data;
139  }
$post
Definition: ltitoken.php:46

◆ serializedData()

static ilAssQuestionSkillAssignmentRegistryTest::serializedData ( )
static
Returns
array

Definition at line 144 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $post.

144  : array
145  {
146  $pre = function ($value) {
147  return serialize($value);
148  };
149 
150  $post = function ($value) {
151  return unserialize($value);
152  };
153 
154  return self::getTestData($pre, $post);
155  }
$post
Definition: ltitoken.php:46

◆ setUp()

ilAssQuestionSkillAssignmentRegistryTest::setUp ( )

Definition at line 31 of file ilAssQuestionSkillAssignmentRegistryTest.php.

31  : void
32  {
33  parent::setUp();
34 
35  $this->storage = [];
36  }

◆ testInvalidChunkSizeWillRaiseException()

ilAssQuestionSkillAssignmentRegistryTest::testInvalidChunkSizeWillRaiseException ( )

Definition at line 83 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References Vendor\Package\$e.

83  : void
84  {
85  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->onlyMethods(['set', 'get', 'delete'])->getMock();
86 
87  try {
88  $registry = new ilAssQuestionSkillAssignmentRegistry($settingsMock);
89  $registry->setChunkSize('a');
90  $this->fail('Failed asserting that exception of type "InvalidArgumentException" is thrown.');
91  } catch (InvalidArgumentException $e) {
92  }
93 
94  try {
95  $registry = new ilAssQuestionSkillAssignmentRegistry($settingsMock);
96  $registry->setChunkSize(-5);
97  $this->fail('Failed asserting that exception of type "InvalidArgumentException" is thrown.');
98  } catch (InvalidArgumentException $e) {
99  }
100  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testSkillAssignmentsCanBetStoredAndFetchedBySerializationStrategy()

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

Definition at line 45 of file ilAssQuestionSkillAssignmentRegistryTest.php.

45  : void
46  {
47  $this->markTestSkipped('Data Provider needs to be revisited.');
48 
49  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->onlyMethods(['set', 'get', 'delete'])->getMock();
50 
51  $settingsMock->expects($this->any())->method('set')->willReturnCallback(
52  function ($key, $value) {
53  $this->storage[$key] = $value;
54  }
55  );
56 
57  $settingsMock->expects($this->any())->method('get')->willReturnCallback(
58  function ($key, $value) {
59  return $this->storage[$key] ?? $value;
60  }
61  );
62 
63  $settingsMock->expects($this->any())->method('delete')->willReturnCallback(
64  function ($key) {
65  if (isset($this->storage[$key])) {
66  unset($this->storage[$key]);
67  }
68  }
69  );
70 
71  $valueToTest = $preCallback($value);
72 
73  $registry = new ilAssQuestionSkillAssignmentRegistry($settingsMock);
74  $registry->setChunkSize($chunkSize);
75  $registry->setStringifiedImports(self::TEST_KEY, $valueToTest);
76  $actual = $registry->getStringifiedImports(self::TEST_KEY);
77 
78  $this->assertEquals($valueToTest, $actual);
79  $this->assertEquals($value, $postCallback($actual));
80  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $storage

array ilAssQuestionSkillAssignmentRegistryTest::$storage = []
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: