ParameterBagTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 61
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testParameterGetter() 0 12 1
A testNonScalarParameterValue() 0 13 1
A testNonExistentParameterGetter() 0 13 1
A testBadParameterName() 0 11 1
1
<?php
2
3
namespace JobQueue\Tests\Domain\Task;
4
5
use JobQueue\Domain\Task\Profile;
6
use JobQueue\Domain\Task\Task;
7
use JobQueue\Tests\Domain\Job;
8
use PHPUnit\Framework\TestCase;
9
10
final class ParameterBagTest extends TestCase
11
{
12
    public function testBadParameterName()
13
    {
14
        $this->expectExceptionMessage('The key must be a string');
15
16
        new Task(
17
            new Profile('test'),
18
            new Job\DummyJob,
19
            [
20
                'foo' => 'bar',
21
                'bar' => 'baz',
22
                2 => 'foo',
23
            ]
24
        );
25
    }
26
27
    public function testNonScalarParameterValue()
28
    {
29
        $this->expectExceptionMessage('The "erroneous" value must be a scalar or null');
30
31
        new Task(
32
            new Profile('test'),
33
            new Job\DummyJob,
34
            [
35
                'int' => 123,
36
                'string' => 'foobar',
37
                'null' => null,
38
                'bool' => true,
39
                'erroneous' => [],
40
            ]
41
        );
42
    }
43
44
    public function testParameterGetter()
45
    {
46
        $task = new Task(
47
            new Profile('test'),
48
            new Job\DummyJob,
49
            [
50
                'foo' => 'bar',
51
                'bar' => 'baz',
52
            ]
53
        );
54
55
        $this->assertTrue($task->hasParameter('foo'));
56
    }
57
58
    public function testNonExistentParameterGetter()
59
    {
60
        $this->expectExceptionMessage('There is no value for "foo" key');
61
62
        $task = new Task(
63
            new Profile('test'),
64
            new Job\DummyJob,
65
            [
66
                'bar' => 'baz',
67
            ]
68
        );
69
70
        $task->getParameter('foo');
71
    }
72
}
73