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\HINFO; |
18
|
|
|
use PHPUnit\Framework\TestCase; |
19
|
|
|
|
20
|
|
|
class HinfoTest extends TestCase |
21
|
|
|
{ |
22
|
|
View Code Duplication |
public function testToText(): void |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
$cpu = '2.7GHz'; |
25
|
|
|
$os = 'Ubuntu 12.04'; |
26
|
|
|
$expectation = '"2.7GHz" "Ubuntu 12.04"'; |
27
|
|
|
$hinfo = new HINFO(); |
28
|
|
|
$hinfo->setCpu($cpu); |
29
|
|
|
$hinfo->setOs($os); |
30
|
|
|
|
31
|
|
|
$this->assertEquals($expectation, $hinfo->toText()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
View Code Duplication |
public function testGetters(): void |
|
|
|
|
35
|
|
|
{ |
36
|
|
|
$cpu = '2.7GHz'; |
37
|
|
|
$os = 'Ubuntu 12.04'; |
38
|
|
|
$hinfo = new HINFO(); |
39
|
|
|
$hinfo->setCpu($cpu); |
40
|
|
|
$hinfo->setOs($os); |
41
|
|
|
|
42
|
|
|
$this->assertEquals($cpu, $hinfo->getCpu()); |
43
|
|
|
$this->assertEquals($os, $hinfo->getOs()); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testGetType(): void |
47
|
|
|
{ |
48
|
|
|
$hinfo = new HINFO(); |
49
|
|
|
$this->assertEquals('HINFO', $hinfo->getType()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testGetTypeCode(): void |
53
|
|
|
{ |
54
|
|
|
$hinfo = new HINFO(); |
55
|
|
|
$this->assertEquals(13, $hinfo->getTypeCode()); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
View Code Duplication |
public function testFromWire(): void |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
$hinfo = new HINFO(); |
61
|
|
|
$hinfo->fromWire('"2.7GHz" "Ubuntu 12.04"'); |
62
|
|
|
$this->assertEquals('2.7GHz', $hinfo->getCpu()); |
63
|
|
|
$this->assertEquals('Ubuntu 12.04', $hinfo->getOs()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
View Code Duplication |
public function testFromText(): void |
|
|
|
|
67
|
|
|
{ |
68
|
|
|
$hinfo = new HINFO(); |
69
|
|
|
$hinfo->fromText('2.7GHz "Ubuntu 12.04"'); |
70
|
|
|
$this->assertEquals('2.7GHz', $hinfo->getCpu()); |
71
|
|
|
$this->assertEquals('Ubuntu 12.04', $hinfo->getOs()); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
View Code Duplication |
public function testToWire(): void |
|
|
|
|
75
|
|
|
{ |
76
|
|
|
$cpu = '2.7GHz'; |
77
|
|
|
$os = 'Ubuntu 12.04'; |
78
|
|
|
$expectation = '"2.7GHz" "Ubuntu 12.04"'; |
79
|
|
|
$hinfo = new HINFO(); |
80
|
|
|
$hinfo->setCpu($cpu); |
81
|
|
|
$hinfo->setOs($os); |
82
|
|
|
|
83
|
|
|
$this->assertEquals($expectation, $hinfo->toWire()); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function testFactory(): void |
87
|
|
|
{ |
88
|
|
|
$hinfo = Factory::HINFO('SGI-IRIS-INDY', 'IRIX'); |
89
|
|
|
$this->assertEquals('SGI-IRIS-INDY', $hinfo->getCpu()); |
90
|
|
|
$this->assertEquals('IRIX', $hinfo->getOs()); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.