Passed
Push — master ( 784e69...f2d35a )
by Alexander
07:36
created

RandomTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 2
b 0
f 0
dl 0
loc 19
rs 10
1
<?php
2
3
namespace Yiisoft\Security\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Yiisoft\Security\Random;
7
8
class RandomTest extends TestCase
9
{
10
    public function testRandomStringRespectsLength(): void
11
    {
12
        $length = 21;
13
        $key = Random::string($length);
14
        $this->assertEquals($length, strlen($key));
15
    }
16
17
    public function testRandomStringValidSymbols(): void
18
    {
19
        $key = Random::string(100);
20
        $this->assertMatchesRegularExpression('/[A-Za-z0-9_-]+/', $key);
21
    }
22
23
    public function testInvalidLength(): void
24
    {
25
        $this->expectException(\InvalidArgumentException::class);
26
        Random::string(0);
27
    }
28
}
29