ILIAS  release_8 Revision v8.24
ClientIdTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
6
7require_once 'libs/composer/vendor/autoload.php';
8
9use ILIAS\Data;
10use PHPUnit\Framework\TestCase;
11
15class ClientIdTest extends TestCase
16{
19
23 protected function setUp(): void
24 {
25 $this->f = new Data\Factory();
26 }
27
31 public function clientIdProvider(): array
32 {
33 return [
34 'single letter' => ['c'],
35 'multiple letters' => ['client'],
36 'single uppercase letter' => ['C'],
37 'multiple uppercase letters' => ['CLIENT'],
38 'single digit' => ['1'],
39 'multiple digits' => ['12'],
40 'letters + underscores' => ['client_with_underscore'],
41 'letters + underscores + digits' => ['client_with_12345'],
42 'letters + hyphens' => ['client-with-hyphen'],
43 'dots + sharps' => ['.#'] // looks weird, but is considered valid
44 ];
45 }
46
50 public function invalidClientIdProvider(): array
51 {
52 return [
53 'path traversal' => ['../../some/obscure/path'],
54 'space in between' => ['my client'],
55 'wrapped in spaces' => [' myclient '],
56 'umlaut' => ['clüent'],
57 ];
58 }
59
64 public function testValidArguments(string $value): void
65 {
66 $clientId = $this->f->clientId($value);
67 $this->assertEquals($value, $clientId->toString());
68 }
69
74 public function testInvalidArguments(string $value): void
75 {
76 try {
77 $clientId = $this->f->clientId($value);
78 $this->fail('This should not happen');
79 } catch (InvalidArgumentException $e) {
80 $this->assertTrue(true);
81 }
82 }
83
85 {
86 $this->expectException(InvalidArgumentException::class);
87
88 $this->f->clientId('');
89 }
90}
Data Factory $f
testClientIdCannotBeCreatedByAnEmptyString()
invalidClientIdProvider()
testInvalidArguments(string $value)
testValidArguments(string $value)
Builds data types.
Definition: Factory.php:21
$clientId
Definition: ltiregend.php:27