Code Duplication    Length = 44-44 lines in 2 locations

tests/Rdata/DnameTest.php 1 location

@@ 19-62 (lines=44) @@
16
use Badcow\DNS\Rdata\DNAME;
17
use PHPUnit\Framework\TestCase;
18
19
class DnameTest extends TestCase
20
{
21
    public function testSetTarget(): void
22
    {
23
        $target = 'foo.example.com.';
24
        $dname = new DNAME();
25
        $dname->setTarget($target);
26
27
        $this->assertEquals($target, $dname->getTarget());
28
    }
29
30
    public function testOutput(): void
31
    {
32
        $target = 'foo.example.com.';
33
        $dname = new DNAME();
34
        $dname->setTarget($target);
35
36
        $this->assertEquals($target, $dname->toText());
37
        $this->assertEquals($target, $dname->toText());
38
    }
39
40
    public function testFromText(): void
41
    {
42
        $text = 'host.example.com.';
43
        /** @var DNAME $cname */
44
        $cname = new DNAME();
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 DNAME $dname */
56
        $dname = new DNAME();
57
        $dname->fromWire($expectation);
58
59
        $this->assertEquals($expectation, $dname->toWire());
60
        $this->assertEquals($host, $dname->getTarget());
61
    }
62
}
63

tests/Rdata/NsTest.php 1 location

@@ 19-62 (lines=44) @@
16
use Badcow\DNS\Rdata\NS;
17
use PHPUnit\Framework\TestCase;
18
19
class NsTest extends TestCase
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