ILIAS  release_8 Revision v8.24
ilCtrlTokenTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6
7use PHPUnit\Framework\TestCase;
8
14class ilCtrlTokenTest extends TestCase
15{
16 public function testTokenRetrieval(): void
17 {
18 $expected_value = 'test_token_1';
19 $token = new ilCtrlToken($expected_value);
20
21 $this->assertEquals(
22 $expected_value,
23 $token->getToken()
24 );
25 }
26
27 public function testTokenVerification(): void
28 {
29 $expected_value = 'test_token_2';
30 $token = new ilCtrlToken($expected_value);
31 $token_value = $token->getToken();
32
33 $this->assertTrue($token->verifyWith($token_value));
34 $this->assertFalse($token->verifyWith(''));
35 $this->assertFalse($token->verifyWith('xyz'));
36 }
37}
Class ilCtrlTokenTest.
Class ilCtrlToken is responsible for generating and storing unique CSRF tokens.
$token
Definition: xapitoken.php:70