Passed
Pull Request — master (#1312)
by Michael
07:24
created

BasicTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testGetVerifying() 0 9 1
A tearDown() 0 2 1
A testCreate() 0 7 1
A testGetSigning() 0 9 1
A testKill() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xmf\Test\Key;
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
use Xmf\Key\ArrayStorage;
10
use Xmf\Key\Basic;
11
use Xmf\Key\StorageInterface;
12
13
class BasicTest extends TestCase
14
{
15
    /**
16
     * @var StorageInterface
17
     */
18
    protected $storage;
19
    /**
20
     * @var Basic
21
     */
22
    protected $object;
23
24
    /**
25
     * Sets up the fixture, for example, opens a network connection.
26
     * This method is called before a test is executed.
27
     */
28
    protected function setUp(): void
29
    {
30
        $this->storage = new ArrayStorage();
31
        $this->object  = new Basic($this->storage, 'test');
32
    }
33
34
    /**
35
     * Tears down the fixture, for example, closes a network connection.
36
     * This method is called after a test is executed.
37
     */
38
    protected function tearDown(): void
39
    {
40
    }
41
42
    public function testGetSigning()
43
    {
44
        $actual = $this->object->getSigning();
45
        $this->assertEmpty($actual);
46
        $actual = $this->object->create();
47
        $this->assertTrue($actual);
48
        $actual = $this->object->getSigning();
49
        $this->assertIsString($actual);
50
        $this->assertMatchesRegularExpression('/^[0-9a-f]{128}$/', $actual);
51
    }
52
53
    public function testGetVerifying()
54
    {
55
        $actual = $this->object->getVerifying();
56
        $this->assertEmpty($actual);
57
        $actual = $this->object->create();
58
        $this->assertTrue($actual);
59
        $actual = $this->object->getVerifying();
60
        $this->assertIsString($actual);
61
        $this->assertMatchesRegularExpression('/^[0-9a-f]{128}$/', $actual);
62
    }
63
64
    public function testCreate()
65
    {
66
        $actual = $this->object->create();
67
        $this->assertTrue($actual);
68
69
        $actual = $this->object->create();
70
        $this->assertFalse($actual);
71
    }
72
73
    public function testKill()
74
    {
75
        $actual = $this->object->create();
76
        $this->assertTrue($actual);
77
78
        $this->assertTrue($this->storage->exists('test'));
79
80
        $actual = $this->object->kill();
81
        $this->assertTrue($actual);
82
83
        $this->assertFalse($this->storage->exists('test'));
84
    }
85
}
86