NsTest::testWire()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\NS;
17
use PHPUnit\Framework\TestCase;
18
19 View Code Duplication
class NsTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
20
{
21
    public function testSetNsdname(): void
22
    {
23
        $target = 'foo.example.com.';
24
        $ns = new NS();
25
        $ns->setTarget($target);
26
27
        $this->assertEquals($target, $ns->getTarget());
28
    }
29
30
    public function testOutput(): void
31
    {
32
        $target = 'foo.example.com.';
33
        $ns = new NS();
34
        $ns->setTarget($target);
35
36
        $this->assertEquals($target, $ns->toText());
37
        $this->assertEquals($target, $ns->toText());
38
    }
39
40
    public function testFromText(): void
41
    {
42
        $text = 'host.example.com.';
43
        /** @var NS $cname */
44
        $cname = new NS();
45
        $cname->fromText($text);
46
47
        $this->assertEquals($text, $cname->getTarget());
48
    }
49
50
    public function testWire(): void
51
    {
52
        $host = 'host.example.com.';
53
        $expectation = chr(4).'host'.chr(7).'example'.chr(3).'com'.chr(0);
54
55
        /** @var NS $ns */
56
        $ns = new NS();
57
        $ns->fromWire($expectation);
58
59
        $this->assertEquals($expectation, $ns->toWire());
60
        $this->assertEquals($host, $ns->getTarget());
61
    }
62
}
63