FactoryTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTestData() 0 10 1
A testNewRdataFromNameAndId() 0 5 1
A testNewRdataFromNameThrowsExceptionForUnknownType() 0 5 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\Rdata;
15
16
use Badcow\DNS\Rdata\Factory;
17
use Badcow\DNS\Rdata\UnsupportedTypeException;
18
use PHPUnit\Framework\TestCase;
19
20
class FactoryTest extends TestCase
21
{
22
    public function getTestData(): array
23
    {
24
        $namespace = '\\Badcow\\DNS\\Rdata\\';
25
26
        return [
27
            ['CNAME', 5, $namespace.'CNAME'],
28
            ['AAAA', 28, $namespace.'AAAA'],
29
            ['RRSIG', 46, $namespace.'RRSIG'],
30
        ];
31
    }
32
33
    /**
34
     * @dataProvider getTestData
35
     *
36
     * @throws UnsupportedTypeException
37
     */
38
    public function testNewRdataFromNameAndId(string $type, int $typeCode, string $classname): void
39
    {
40
        $this->assertInstanceOf($classname, Factory::newRdataFromName($type));
41
        $this->assertInstanceOf($classname, Factory::newRdataFromId($typeCode));
42
    }
43
44
    /**
45
     * @throws UnsupportedTypeException
46
     */
47
    public function testNewRdataFromNameThrowsExceptionForUnknownType(): void
48
    {
49
        $this->expectException(UnsupportedTypeException::class);
50
        Factory::newRdataFromName('rsig');
51
    }
52
}
53