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

DynamoDbSecondaryIndexProcessorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 0 3 1
B testProcessor() 0 25 1
A testProcessorNoOverwrite() 0 21 1
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