Completed
Push — master ( 91b50a...6fa888 )
by Patrick
02:06
created

MtaNameTypeFieldTest   A

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