Passed
Pull Request — master (#1312)
by Michael
05:26
created

RandomTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 45
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGenerateKey() 0 9 2
A setUp() 0 2 1
A tearDown() 0 2 1
A testGenerateOneTimeToken() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xmf\Test;
6
7
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
10
use Xmf\Random;
11
12
class RandomTest extends TestCase
13
{
14
    /**
15
     * @var Random
16
     */
17
    protected $object;
18
    protected $myClass = Random::class;
19
20
    /**
21
     * Sets up the fixture, for example, opens a network connection.
22
     * This method is called before a test is executed.
23
     */
24
    protected function setUp(): void
25
    {
26
        // $this->object = new Random();
27
    }
28
29
    /**
30
     * Tears down the fixture, for example, closes a network connection.
31
     * This method is called after a test is executed.
32
     */
33
    protected function tearDown(): void
34
    {
35
    }
36
37
    public function testGenerateOneTimeToken()
38
    {
39
        try {
40
            $result = Random::generateOneTimeToken();
41
        } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
42
        }
43
44
        $this->assertIsString($result);
45
        $this->assertMatchesRegularExpression('/^[0-9a-f]{128}$/', $result);
46
    }
47
48
    public function testGenerateKey()
49
    {
50
        try {
51
            $result = Random::generateKey();
52
        } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
53
        }
54
55
        $this->assertIsString($result);
56
        $this->assertMatchesRegularExpression('/^[0-9a-f]{128}$/', $result);
57
    }
58
}
59