Completed
Push — master ( 6fa888...1dfddd )
by Patrick
02:15
created

ActionFieldTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 20
dl 0
loc 49
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A invalidActionProvider() 0 5 1
A testInvalidAction() 0 5 1
A testAction() 0 10 1
A testValidAction() 0 4 1
A validActionProvider() 0 8 1
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