Completed
Push — master ( 298f36...c6c82d )
by Mihail
06:19 queued 10s
created

RandomAlphaNumericFunctionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4
1
<?php
2
3
namespace Koded\Stdlib;
4
5
use PHPUnit\Framework\TestCase;
6
7
class RandomAlphaNumericFunctionTest extends TestCase
8
{
9
10
    public function test_random_alpha_numeric_with_default_number()
11
    {
12
        $random = randomstring();
13
        $this->assertSame(16, strlen($random));
14
        $this->assertRegExp('~[a-z0-9]~i', $random);
15
    }
16
17
    public function test_random_alpha_numeric_with_prefix()
18
    {
19
        $random = randomstring(64, 'ABC');
20
        $this->assertSame(67, strlen($random));
21
        $this->assertSame('ABC', substr($random, 0, 3));
22
    }
23
24
    public function test_random_alpha_numeric_with_suffix()
25
    {
26
        $random = randomstring(128, '', 'ABC');
27
        $this->assertSame(131, strlen($random));
28
        $this->assertSame('ABC', substr($random, -3));
29
    }
30
31
    public function test_random_alpha_numeric_with_prefix_and_suffix()
32
    {
33
        $random = randomstring(4, 'ABC-', '-XYZ');
34
        $this->assertSame(12, strlen($random));
35
        $this->assertRegExp('~ABC\-[a-z0-9]{4}\-XYZ~i', $random);
36
    }
37
}
38