UnknownTypeTest::testWire()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
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\UnknownType;
17
use PHPUnit\Framework\TestCase;
18
19
class UnknownTypeTest extends TestCase
20
{
21
    public function testToText(): void
22
    {
23
        $expectation = '\# 32 9aa065581e1a247d5e884a44adfa7cb4a849c7b90ade83c8fb9eae5984ea7fba';
24
        $uk = new UnknownType();
25
        $uk->setTypeCode(1234);
26
        $uk->setData(hex2bin('9aa065581e1a247d5e884a44adfa7cb4a849c7b90ade83c8fb9eae5984ea7fba'));
27
28
        $this->assertEquals($expectation, $uk->toText());
29
    }
30
31
    public function testFromText(): void
32
    {
33
        $uk = new UnknownType();
34
        $uk->fromText('\# 32 9aa065581e1a247d5e884a44adfa7cb4a849c7b90ade83c8fb9eae5984ea7fba');
35
        $this->assertEquals(hex2bin('9aa065581e1a247d5e884a44adfa7cb4a849c7b90ade83c8fb9eae5984ea7fba'), $uk->getData());
36
    }
37
38 View Code Duplication
    public function testWire(): void
0 ignored issues
show
Duplication introduced by
This method 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...
39
    {
40
        $expectation = '\# 32 9aa065581e1a247d5e884a44adfa7cb4a849c7b90ade83c8fb9eae5984ea7fba';
41
        $wireFormat = hex2bin('9aa065581e1a247d5e884a44adfa7cb4a849c7b90ade83c8fb9eae5984ea7fba');
42
        $uk = new UnknownType();
43
        $uk->fromWire($wireFormat);
44
45
        $this->assertEquals($expectation, $uk->toText());
46
        $this->assertEquals($wireFormat, $uk->toWire());
47
    }
48
}
49