AddressTypeFieldTest::validTypeProvider()   A
last analyzed

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