Passed
Push — master ( 83c445...092c55 )
by Kirill
05:01
created

ConfigTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 18
c 1
b 0
f 0
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCsrf() 0 24 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Csrf;
13
14
use PHPUnit\Framework\TestCase;
15
use Spiral\Csrf\Config\CsrfConfig;
16
17
class ConfigTest extends TestCase
18
{
19
    public function testCsrf(): void
20
    {
21
        $c = new CsrfConfig([
22
            'cookie'   => 'csrf-token',
23
            'length'   => 16,
24
            'lifetime' => 86400,
25
            'sameSite' => 'Lax'
26
        ]);
27
28
        self::assertSame('csrf-token', $c->getCookie());
29
        self::assertSame(16, $c->getTokenLength());
30
        self::assertSame(86400, $c->getCookieLifetime());
31
        self::assertFalse($c->isCookieSecure());
32
        self::assertSame('Lax', $c->getSameSite());
33
34
        $c = new CsrfConfig([
35
            'cookie' => 'csrf-token',
36
            'length' => 16,
37
            'secure' => true
38
        ]);
39
40
        self::assertNull($c->getCookieLifetime());
41
        self::assertTrue($c->isCookieSecure());
42
        self::assertNull($c->getSameSite());
43
    }
44
}
45