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

MtaNameTypeFieldTest::testType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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