ClassesTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsValidClass() 0 11 1
A testGetClassId() 0 6 1
A testGetClassIdThrowsExceptionForUndefinedClass() 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\Classes;
17
18
class ClassesTest extends \PHPUnit\Framework\TestCase
19
{
20
    public function testIsValidClass(): void
21
    {
22
        $this->assertTrue(Classes::isValid('IN'));
23
        $this->assertTrue(Classes::isValid('HS'));
24
        $this->assertTrue(Classes::isValid('CH'));
25
26
        $this->assertFalse(Classes::isValid('INTERNET'));
27
        $this->assertFalse(Classes::isValid('in'));
28
        $this->assertFalse(Classes::isValid('In'));
29
        $this->assertFalse(Classes::isValid('hS'));
30
    }
31
32
    public function testGetClassId(): void
33
    {
34
        $this->assertEquals(1, Classes::getClassId('IN'));
35
        $this->assertEquals(4, Classes::getClassId('HS'));
36
        $this->assertEquals(3, Classes::getClassId('CH'));
37
    }
38
39
    public function testGetClassIdThrowsExceptionForUndefinedClass(): void
40
    {
41
        $this->expectException(\InvalidArgumentException::class);
42
        $this->expectExceptionMessage('Class "XX" is not a valid DNS class.');
43
        Classes::getClassId('XX');
44
    }
45
}
46