Passed
Branch master (c86cc6)
by Tim
11:28
created

SymmetricKeyTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGeneration() 0 7 1
A testCreation() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\XMLSecurity\Test\Key;
6
7
use PHPUnit\Framework\TestCase;
8
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
9
10
/**
11
 * Class to test SimpleSAML\XMLSecurity\Key\SymmetricKey
12
 *
13
 * @package SimpleSAML\XMLSecurity\Key
14
 */
15
final class SymmetricKeyTest extends TestCase
16
{
17
    /**
18
     * Cover basic creation, retrieval and length computation.
19
     */
20
    public function testCreation(): void
21
    {
22
        $k = new SymmetricKey('secret_key_material');
23
        $this->assertEquals('secret_key_material', $k->getMaterial());
24
        $this->assertEquals(19, $k->getLength());
25
    }
26
27
28
    /**
29
     * Cover random generation of secrets.
30
     */
31
    public function testGeneration(): void
32
    {
33
        $k1 = SymmetricKey::generate(24, true);
34
        $k2 = SymmetricKey::generate(24, true);
35
        $this->assertEquals(24, $k1->getLength());
36
        $this->assertEquals(24, $k2->getLength());
37
        $this->assertNotEquals($k1->getMaterial(), $k2->getMaterial());
38
    }
39
}
40