ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ClientIdTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once 'vendor/composer/vendor/autoload.php';
22 
23 use ILIAS\Data;
25 
29 class ClientIdTest extends TestCase
30 {
32  private Data\Factory $f;
33 
37  protected function setUp(): void
38  {
39  $this->f = new Data\Factory();
40  }
41 
45  public static function clientIdProvider(): array
46  {
47  return [
48  'single letter' => ['c'],
49  'multiple letters' => ['client'],
50  'single uppercase letter' => ['C'],
51  'multiple uppercase letters' => ['CLIENT'],
52  'single digit' => ['1'],
53  'multiple digits' => ['12'],
54  'letters + underscores' => ['client_with_underscore'],
55  'letters + underscores + digits' => ['client_with_12345'],
56  'letters + hyphens' => ['client-with-hyphen'],
57  'dots + sharps' => ['.#'] // looks weird, but is considered valid
58  ];
59  }
60 
64  public static function invalidClientIdProvider(): array
65  {
66  return [
67  'path traversal' => ['../../../../some/obscure/path'],
68  'space in between' => ['my client'],
69  'wrapped in spaces' => [' myclient '],
70  'umlaut' => ['clüent'],
71  ];
72  }
73 
78  public function testValidArguments(string $value): void
79  {
80  $clientId = $this->f->clientId($value);
81  $this->assertEquals($value, $clientId->toString());
82  }
83 
88  public function testInvalidArguments(string $value): void
89  {
90  try {
91  $clientId = $this->f->clientId($value);
92  $this->fail('This should not happen');
93  } catch (InvalidArgumentException $e) {
94  $this->assertTrue(true);
95  }
96  }
97 
99  {
100  $this->expectException(InvalidArgumentException::class);
101 
102  $this->f->clientId('');
103  }
104 }
$clientId
Definition: ltiregend.php:25
static clientIdProvider()
testValidArguments(string $value)
Data Factory $f
static invalidClientIdProvider()
testInvalidArguments(string $value)
testClientIdCannotBeCreatedByAnEmptyString()