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(["foo", "bar"])); |
11
|
|
|
} |
12
|
|
|
|
13
|
|
|
public function testProcessor() |
14
|
|
|
{ |
15
|
|
|
$processor = new DynamoDbSecondaryIndexProcessor(["foo", "bar"]); |
16
|
|
|
$datetime = new \Datetime('@400'); |
17
|
|
|
$record = [ |
18
|
|
|
'eventIdentifier' => "foodle", |
19
|
|
|
'timestamp' => new \Datetime('@33'), |
20
|
|
|
'data' => [ |
21
|
|
|
'shoe' => [], |
22
|
|
|
'schuh' => 'german', |
23
|
|
|
'bananas' => [ |
24
|
|
|
'Bar' => 'a town in Montenegro', |
25
|
|
|
'bar' => 'sandy', |
26
|
|
|
], |
27
|
|
|
], |
28
|
|
|
'metadata' => [ |
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(["timestamp", "eventIdentifier"]); |
43
|
|
|
$timestamp = new \Datetime('@33'); |
44
|
|
|
$identifier = "This should appear"; |
45
|
|
|
$record = [ |
46
|
|
|
'eventIdentifier' => $identifier, |
47
|
|
|
'timestamp' => $timestamp, |
48
|
|
|
'data' => [ |
49
|
|
|
'bananas' => [ |
50
|
|
|
'eventIdentifier' => 'This should not appear', |
51
|
|
|
], |
52
|
|
|
], |
53
|
|
|
'metadata' => [ |
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
|
|
|
|