Passed
Push — master ( ddd97a...25aa58 )
by Harry
06:46
created

testProcessor()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nc 1
nop 0
dl 0
loc 25
rs 8.8571
c 0
b 0
f 0
1
<?php
2
namespace Graze\Monolog\Processor;
3
4
use Monolog\TestCase;
5
6
class DynamoDbSecondaryIndexProcessorTest extends TestCase
7
{
8
    public function testConstruct()
9
    {
10
        $this->assertInstanceOf('Graze\Monolog\Processor\DynamoDbSecondaryIndexProcessor', new DynamoDbSecondaryIndexProcessor(array("foo", "bar")));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
11
    }
12
13
    public function testProcessor()
14
    {
15
        $processor = new DynamoDbSecondaryIndexProcessor(array("foo", "bar"));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
16
        $datetime = new \Datetime('@400');
17
        $record = array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
18
            'eventIdentifier' => "foodle",
19
            'timestamp' => new \Datetime('@33'),
20
            'data' => array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
21
                'shoe' => array(),
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
22
                'schuh' => 'german',
23
                'bananas' => array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
24
                    'Bar' => 'a town in Montenegro',
25
                    'bar' => 'sandy',
26
                ),
27
            ),
28
            'metadata' => array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
29
                'foo' => $datetime,
30
            ),
31
        );
32
        $record = $processor($record);
33
34
        $this->assertArrayHasKey('foo', $record);
35
        $this->assertEquals($datetime, $record['foo']);
36
        $this->assertArrayHasKey('bar', $record);
37
        $this->assertEquals('sandy', $record['bar']);
38
    }
39
40
    public function testProcessorNoOverwrite()
41
    {
42
        $processor = new DynamoDbSecondaryIndexProcessor(array("timestamp", "eventIdentifier"));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
43
        $timestamp = new \Datetime('@33');
44
        $identifier = "This should appear";
45
        $record = array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
46
            'eventIdentifier' => $identifier,
47
            'timestamp' => $timestamp,
48
            'data' => array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
49
                'bananas' => array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
50
                    'eventIdentifier' => 'This should not appear',
51
                ),
52
            ),
53
            'metadata' => array(
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
54
                'timestamp' => 'Also should not appear',
55
            ),
56
        );
57
        $record = $processor($record);
58
59
        $this->assertEquals($timestamp, $record['timestamp']);
60
        $this->assertEquals($identifier, $record['eventIdentifier']);
61
    }
62
}
63