ActionFieldTest::testAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
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 ActionFieldTest extends TestCase
11
{
12
    public function testAction(): void
13
    {
14
        $actionFirst = 'failed';
15
        $actionSecond = 'delivered';
16
17
        $actionField = new ActionField('name', $actionFirst);
18
        $this->assertSame($actionFirst, $actionField->getAction());
19
20
        $actionField->setAction($actionSecond);
21
        $this->assertEquals($actionSecond, $actionField->getAction());
22
    }
23
24
    /**
25
     * @dataProvider validActionProvider
26
     */
27
    public function testValidAction(string $action): void
28
    {
29
        $actionField = new ActionField('name', $action);
30
        $this->assertEquals($action, $actionField->getAction());
31
    }
32
33
    /**
34
     * @dataProvider invalidActionProvider
35
     */
36
    public function testInvalidAction(string $action): void
37
    {
38
        $this->expectException(InvalidArgumentException::class);
39
40
        new ActionField('name', $action);
41
    }
42
43
    public function validActionProvider(): array
44
    {
45
        return [
46
            ['failed'],
47
            ['delayed'],
48
            ['delivered'],
49
            ['relayed'],
50
            ['expanded'],
51
        ];
52
    }
53
54
    public function invalidActionProvider(): array
55
    {
56
        return [
57
            ['something'],
58
            ['else'],
59
        ];
60
    }
61
}
62