ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilAssQuestionSkillAssignmentRegistryTest Class Reference

Class ilAssQuestionSkillAssignmentRegistryTest. 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 Attributes

 $storage = array()
 

Detailed Description

Member Function Documentation

◆ getTestData()

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

Definition at line 106 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References $data, array, and ilAssQuestionSkillAssignment\EVAL_MODE_BY_QUESTION_SOLUTION.

Referenced by serializedData().

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

◆ serializedData()

ilAssQuestionSkillAssignmentRegistryTest::serializedData ( )
Returns
array

Definition at line 149 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References getTestData().

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  }
+ Here is the call graph for this function:

◆ setUp()

ilAssQuestionSkillAssignmentRegistryTest::setUp ( )

Definition at line 21 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References array.

22  {
23  parent::setUp();
24 
25  $this->storage = array();
26  }
Create styles array
The data for the language used.

◆ testInvalidChunkSizeWillRaiseException()

ilAssQuestionSkillAssignmentRegistryTest::testInvalidChunkSizeWillRaiseException ( )

Definition at line 75 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References array.

76  {
77  require_once 'Services/Administration/classes/class.ilSetting.php';
78  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get', 'delete'))->getMock();
79 
80  try
81  {
82  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
83  $registry->setChunkSize("a");
84  $this->fail("Failed asserting that exception of type \"InvalidArgumentException\" is thrown.");
85  }
86  catch(\InvalidArgumentException $e)
87  {
88  }
89 
90  try
91  {
92  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
93  $registry->setChunkSize(-5);
94  $this->fail("Failed asserting that exception of type \"InvalidArgumentException\" is thrown.");
95  }
96  catch(\InvalidArgumentException $e)
97  {
98  }
99  }
Create styles array
The data for the language used.

◆ testSkillAssignmentsCanBetStoredAndFetchedBySerializationStrategy()

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

serializedData

Parameters
$value
$chunkSize
callable$preCallback
callable$postCallback

Definition at line 35 of file ilAssQuestionSkillAssignmentRegistryTest.php.

References array.

36  {
37  require_once 'Services/Administration/classes/class.ilSetting.php';
38  $settingsMock = $this->getMockBuilder('ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get', 'delete'))->getMock();
39 
40  $settingsMock->expects($this->any())->method('set')->will(
41  $this->returnCallback(function($key, $value) {
42  $this->storage[$key] = $value;
43  })
44  );
45 
46  $settingsMock->expects($this->any())->method('get')->will(
47  $this->returnCallback(function($key, $value) {
48  return isset($this->storage[$key]) ? $this->storage[$key] : $value;
49  })
50  );
51 
52  $settingsMock->expects($this->any())->method('delete')->will(
53  $this->returnCallback(function($key, $value) {
54  if(isset($this->storage[$key]))
55  {
56  unset($this->storage[$key]);
57  }
58  })
59  );
60 
61  $valueToTest = $preCallback($value);
62 
63  $registry = new \ilAssQuestionSkillAssignmentRegistry($settingsMock);
64  $registry->setChunkSize($chunkSize);
65  $registry->setStringifiedImports(self::TEST_KEY, $valueToTest);
66  $actual = $registry->getStringifiedImports(self::TEST_KEY);
67 
68  $this->assertEquals($valueToTest, $actual);
69  $this->assertEquals($value, $postCallback($actual));
70  }
Create styles array
The data for the language used.

Field Documentation

◆ $storage

ilAssQuestionSkillAssignmentRegistryTest::$storage = array()
protected

Definition at line 16 of file ilAssQuestionSkillAssignmentRegistryTest.php.

◆ TEST_KEY

const ilAssQuestionSkillAssignmentRegistryTest::TEST_KEY = 'phpunit_tst'

Definition at line 11 of file ilAssQuestionSkillAssignmentRegistryTest.php.


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