DiagnosticTypeFieldTest::testType()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
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 DiagnosticTypeFieldTest extends TestCase
11
{
12
    public function testType(): void
13
    {
14
        $type = 'smtp';
15
16
        $diagnosticTypeField = new DiagnosticTypeField('name', 'value', $type, null);
17
18
        $this->assertSame($type, $diagnosticTypeField->getType());
19
    }
20
21
    /**
22
     * @dataProvider validTypeProvider
23
     */
24
    public function testWithValidType(string $type): void
25
    {
26
        $diagnosticTypeField = new DiagnosticTypeField('name', 'value', $type, null);
27
28
        $this->assertSame($type, $diagnosticTypeField->getType());
29
    }
30
31
    /**
32
     * @dataProvider invalidTypeProvider
33
     */
34
    public function testInvalidType(string $type): void
35
    {
36
        $this->expectException(InvalidArgumentException::class);
37
38
        new DiagnosticTypeField('name', 'value', $type, null);
39
    }
40
41
    public function validTypeProvider(): array
42
    {
43
        return [
44
            ['smtp'],
45
        ];
46
    }
47
48
    public function invalidTypeProvider(): array
49
    {
50
        return [
51
            ['something'],
52
            ['else'],
53
        ];
54
    }
55
}
56