15 $configCrit1 = $this->getMockBuilder(\ilTermsOfServiceCriterionConfig::class)->getMock();
18 ->expects($this->any())
19 ->method(
'jsonSerialize')
21 'usr_language' =>
'de' 24 $configCrit2 = $this->getMockBuilder(\ilTermsOfServiceCriterionConfig::class)->getMock();
27 ->expects($this->any())
28 ->method(
'jsonSerialize')
30 'usr_global_role' => 4
33 $criterion1 = $this->getMockBuilder(\ilTermsOfServiceEvaluableCriterion::class)->getMock();
36 ->expects($this->any())
37 ->method(
'getCriterionId')
38 ->willReturn(
'crit1');
41 ->expects($this->any())
42 ->method(
'getCriterionValue')
43 ->willReturn($configCrit1);
45 $criterion2 = $this->getMockBuilder(\ilTermsOfServiceEvaluableCriterion::class)->getMock();
48 ->expects($this->any())
49 ->method(
'getCriterionId')
50 ->willReturn(
'crit2');
53 ->expects($this->any())
54 ->method(
'getCriterionValue')
55 ->willReturn($configCrit2);
58 $criterion1, $criterion2
61 $bag = new \ilTermsOfServiceAcceptanceHistoryCriteriaBag(
$data);
63 $this->assertCount(count(
$data), $bag);
64 $this->assertArrayHasKey(0, $bag);
65 $this->assertArrayHasKey(1, $bag);
66 $this->assertArrayHasKey(
'id', $bag[0]);
67 $this->assertArrayHasKey(
'value', $bag[0]);
68 $this->assertArrayHasKey(
'id', $bag[1]);
69 $this->assertArrayHasKey(
'value', $bag[1]);
71 '[{"id":"crit1","value":{"usr_language":"de"}},{"id":"crit2","value":{"usr_global_role":4}}]',
81 $configCrit1 = $this->getMockBuilder(\ilTermsOfServiceCriterionConfig::class)->getMock();
83 $criterion1 = $this->getMockBuilder(\ilTermsOfServiceEvaluableCriterion::class)->getMock();
86 ->expects($this->any())
87 ->method(
'getCriterionId')
88 ->willReturn(
'crit1');
91 ->expects($this->any())
92 ->method(
'getCriterionValue')
93 ->willReturn($configCrit1);
95 $this->
assertException(\ilTermsOfServiceUnexpectedCriteriaBagContentException::class);
97 new \ilTermsOfServiceAcceptanceHistoryCriteriaBag([
107 $configCrit1 = $this->getMockBuilder(\ilTermsOfServiceCriterionConfig::class)->getMock();
109 $criterion1 = $this->getMockBuilder(\ilTermsOfServiceEvaluableCriterion::class)->getMock();
112 ->expects($this->any())
113 ->method(
'getCriterionId')
114 ->willReturn(
'crit1');
117 ->expects($this->any())
118 ->method(
'getCriterionValue')
119 ->willReturn($configCrit1);
121 $this->
assertException(\ilTermsOfServiceUnexpectedCriteriaBagContentException::class);
123 $bag = new \ilTermsOfServiceAcceptanceHistoryCriteriaBag();
132 $configCrit1 = $this->getMockBuilder(\ilTermsOfServiceCriterionConfig::class)->getMock();
134 $criterion1 = $this->getMockBuilder(\ilTermsOfServiceEvaluableCriterion::class)->getMock();
137 ->expects($this->any())
138 ->method(
'getCriterionId')
139 ->willReturn(
'crit1');
142 ->expects($this->any())
143 ->method(
'getCriterionValue')
144 ->willReturn($configCrit1);
146 $this->
assertException(\ilTermsOfServiceUnexpectedCriteriaBagContentException::class);
148 $bag = new \ilTermsOfServiceAcceptanceHistoryCriteriaBag();
149 $bag->fromJson(
'[{"invalid":"crit1","value":{"usr_language":"de"}},{"id":"crit2","value":{"usr_global_role":4}}]');
157 $bag = new \ilTermsOfServiceAcceptanceHistoryCriteriaBag();
158 $bag->fromJson(
'[{"id":"crit1","value":{"usr_language":"de"}},{"id":"crit2","value":{"usr_global_role":4}}]');
160 $this->assertCount(count($bag), $bag);
161 $this->assertArrayHasKey(0, $bag);
162 $this->assertArrayHasKey(1, $bag);
163 $this->assertArrayHasKey(
'id', $bag[0]);
164 $this->assertArrayHasKey(
'value', $bag[0]);
165 $this->assertArrayHasKey(
'id', $bag[1]);
166 $this->assertArrayHasKey(
'value', $bag[1]);
168 '[{"id":"crit1","value":{"usr_language":"de"}},{"id":"crit2","value":{"usr_global_role":4}}]',
assertException(string $exceptionClass)
testExceptionIsRaisedWhenAtLeastOneNonCriterionIsPassedInArrayOnCreation()
Class ilTermsOfServiceBaseTest.
testCriteriaCanBePassedAsArray()
testCriteriaImportFromJsonStringWorksAsExpected()
testExceptionIsRaisedWhenInvalidJsonDataIsPassedOnImport()
Class ilTermsOfServiceAcceptanceHistoryCriteriaBagTest.
testExceptionIsRaisedWhenAtLeastOneInvalidElementIsPassedOnJsonStringImport()