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
|
|
|
|