ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 

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

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

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

◆ serializedData()

static ilAssQuestionSkillAssignmentRegistryTest::serializedData ( )
static
Returns
array

Definition at line 146 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $post.

146  : array
147  {
148  $pre = function ($value) {
149  return serialize($value);
150  };
151 
152  $post = function ($value) {
153  return unserialize($value);
154  };
155 
156  return self::getTestData($pre, $post);
157  }
$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 85 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References Vendor\Package\$e.

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

serializedData

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')->will(
52  $this->returnCallback(function ($key, $value) {
53  $this->storage[$key] = $value;
54  })
55  );
56 
57  $settingsMock->expects($this->any())->method('get')->will(
58  $this->returnCallback(function ($key, $value) {
59  return $this->storage[$key] ?? $value;
60  })
61  );
62 
63  $settingsMock->expects($this->any())->method('delete')->will(
64  $this->returnCallback(function ($key, $value) {
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: