Completed
Push — master ( 72b670...3b819e )
by Sam
05:26 queued 03:37
created

AlgorithmsTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetMnemonic() 0 4 1
A testGetMnemonicThrowsExceptionOnInvalidAlgorithm() 0 6 1
A testGetAlgorithmValueThrowsExceptionOnInvalidMnemonic() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of Badcow DNS Library.
7
 *
8
 * (c) Samuel Williams <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Badcow\DNS\Tests;
15
16
use Badcow\DNS\Algorithms;
17
use PHPUnit\Framework\TestCase;
18
19
class AlgorithmsTest extends TestCase
20
{
21
    public function testGetMnemonic(): void
22
    {
23
        $this->assertEquals('RSASHA1', Algorithms::getMnemonic(5));
24
    }
25
26
    /**
27
     * @throws \InvalidArgumentException
28
     */
29
    public function testGetMnemonicThrowsExceptionOnInvalidAlgorithm(): void
30
    {
31
        $this->expectException(\InvalidArgumentException::class);
32
        $this->expectExceptionMessage('"1337" is not a valid algorithm.');
33
        Algorithms::getMnemonic(1337);
34
    }
35
36
    /**
37
     * @throws \InvalidArgumentException
38
     */
39
    public function testGetAlgorithmValueThrowsExceptionOnInvalidMnemonic(): void
40
    {
41
        $this->expectException(\InvalidArgumentException::class);
42
        $this->expectExceptionMessage('"INVALID_MNEMONIC" is not a valid algorithm mnemonic.');
43
        Algorithms::getAlgorithmValue('INVALID_MNEMONIC');
44
    }
45
}
46