MtaNameTypeFieldTest::invalidTypeProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
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 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