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

SymmetricKeyTest::testGeneration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
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