ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCtrlTokenRepositoryTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6 
8 
14 class ilCtrlTokenRepositoryTest extends TestCase
15 {
16  public function testTokenStorage(): void
17  {
18  $repository = new ilCtrlTokenRepository();
19  $token_one = $repository->getToken();
20  $token_two = $repository->getToken();
21 
22  $this->assertNotEmpty($token_one->getToken());
23  $this->assertNotEmpty($token_two->getToken());
24  $this->assertEquals(
25  $token_one->getToken(),
26  $token_two->getToken()
27  );
28  }
29 
30  public function testTokenGeneration(): void
31  {
32  $repository = new class () extends ilCtrlTokenRepository {
33  public function generate()
34  {
35  return $this->generateToken();
36  }
37  };
38 
39  $token_one = $repository->generate();
40  $token_two = $repository->generate();
41 
42  $this->assertNotEmpty($token_one->getToken());
43  $this->assertNotEmpty($token_two->getToken());
44  $this->assertNotEquals(
45  $token_one->getToken(),
46  $token_two->getToken()
47  );
48  }
49 }
Class ilCtrlTokenRepository.
Class ilCtrlTokenRepositoryTest.