19declare(strict_types=1);
22use PHPUnit\Framework\Attributes\DataProvider;
23use PHPUnit\Framework\TestCase;
33 'list' => [
'quiz;video', [
'quiz',
'video']],
34 'spaces and empty entries' => [
' quiz ; ;video;', [
'quiz',
'video']],
39 #[DataProvider('keywordProvider')]
48 'pairs' => [
'color=blue;size=10', [
'color' =>
'blue',
'size' =>
'10']],
49 'space after the separator' => [
'color=blue; size=10', [
'color' =>
'blue',
'size' =>
'10']],
50 'equals sign in the value' => [
'filter=a=b', [
'filter' =>
'a=b']],
51 'name without value' => [
'debug', [
'debug' =>
'']],
56 #[DataProvider('customParamsProvider')]
66 $this->assertSame(0, $tool->getId());
69 $this->assertSame(0.8, $tool->getMasteryScore());
70 $this->assertTrue($tool->isKeyCustomizable());
71 $this->assertSame([], $tool->getCustomParamsArray());
72 $this->assertFalse($tool->isSelectableBy(0));
78 'title' =>
'Video tool',
80 'keywords' =>
'video;media',
81 'provider_url' =>
'https://tool.example.org/launch',
82 'custom_params' =>
'color=blue',
83 'mastery_score' =>
'0.5',
84 'provider_key' =>
'key1',
85 'provider_secret' =>
'secret1',
86 'provider_key_customizable' =>
'0',
87 'xapi_launch_url' =>
'https://lrs.example.org/data/xAPI',
90 $this->assertSame(7, $tool->getId());
91 $this->assertSame(
'Video tool', $tool->getTitle());
92 $this->assertTrue($tool->isOwnedBy(6));
93 $this->assertSame([
'video',
'media'], $tool->getKeywords());
94 $this->assertSame(
'https://tool.example.org/launch', $tool->getUrl());
95 $this->assertSame([
'color' =>
'blue'], $tool->getCustomParamsArray());
96 $this->assertSame(0.5, $tool->getMasteryScore());
97 $this->assertSame(
'key1', $tool->getKey());
98 $this->assertSame(
'secret1', $tool->getSecret());
99 $this->assertFalse($tool->isKeyCustomizable());
100 $this->assertSame(
'https://lrs.example.org/api/statements/aggregate', $tool->getXapiAggregateEndpoint());
106 'redirection_uris' =>
'https://tool.example.org/launch, https://tool.example.org/deep,',
110 [
'https://tool.example.org/launch',
'https://tool.example.org/deep'],
111 $tool->getRedirectionUris()
120 'no key type with a key set' => [
'',
'',
'https://tool.example.org/jwks'],
121 'no key type with a PEM key' => [
'',
'PEM',
''],
125 #[DataProvider('keyTypeProvider')]
129 'key_type' => $key_type,
130 'public_key' =>
'PEM',
131 'public_keyset' => $public_keyset ===
'' ?
'' :
'https://tool.example.org/jwks',
134 $this->assertSame($public_key, $tool->getPublicKey());
135 $this->assertSame($public_keyset, $tool->getPublicKeysetUrl());
148 #[DataProvider('deepLinkingProvider')]
152 'lti_version' => $version,
153 'content_item' => $content_item ?
'1' :
'0',
154 'content_item_url' => $url,
157 $this->assertSame($expected, $tool->offersDeepLinking());
171 #[DataProvider('selectableProvider')]
175 'availability' => (
string) $availability,
176 'global' => $global ?
'1' :
'0',
180 $this->assertSame($expected, $tool->isSelectableBy(
$user_id));
185 $statement = $this->createStub(ilDBStatement::class);
186 $db = $this->createMock(ilDBInterface::class);
187 $db->expects($this->once())
191 $db->expects($this->once())
194 ->willReturn($statement);
195 $db->expects($this->once())
196 ->method(
'fetchAssoc')
198 ->willReturn([
'id' =>
'7'] + $row);
Customizing of pimple-DIC for ILIAS.