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

AddressTypeFieldTest::validTypeProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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