MtaNameTypeFieldTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 17
dl 0
loc 49
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testType() 0 12 1
A testInvalidType() 0 5 1
A validTypeProvider() 0 5 1
A invalidTypeProvider() 0 5 1
A testWithValidType() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Artack\Dsn\Field;
6
7
use Artack\Dsn\Exception\InvalidArgumentException;
8
use PHPUnit\Framework\TestCase;
9
10
class MtaNameTypeFieldTest extends TestCase
11
{
12
    public function testType(): void
13
    {
14
        $typeFirst = 'dns';
15
        $typeSecond = 'x400';
16
17
        $mtaNameTypeField = new MtaNameTypeField('name', 'value', $typeFirst, null);
18
19
        $this->assertSame($typeFirst, $mtaNameTypeField->getType());
20
21
        $mtaNameTypeField->setValue($typeSecond);
22
23
        $this->assertSame($typeSecond, $mtaNameTypeField->getValue());
24
    }
25
26
    /**
27
     * @dataProvider validTypeProvider
28
     */
29
    public function testWithValidType(string $type): void
30
    {
31
        $mtaNameTypeField = new MtaNameTypeField('name', 'value', $type, null);
32
33
        $this->assertSame($type, $mtaNameTypeField->getType());
34
    }
35
36
    /**
37
     * @dataProvider invalidTypeProvider
38
     */
39
    public function testInvalidType(string $type): void
40
    {
41
        $this->expectException(InvalidArgumentException::class);
42
43
        new MtaNameTypeField('name', 'value', $type, null);
44
    }
45
46
    public function validTypeProvider(): array
47
    {
48
        return [
49
            ['dns'],
50
            ['x400'],
51
        ];
52
    }
53
54
    public function invalidTypeProvider(): array
55
    {
56
        return [
57
            ['something'],
58
            ['else'],
59
        ];
60
    }
61
}
62