ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\DynamoDbHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\DynamoDbHandlerTest:
+ Collaboration diagram for Monolog\Handler\DynamoDbHandlerTest:

Public Member Functions

 setUp ()
 
 testConstruct ()
 
 testInterface ()
 
 testGetFormatter ()
 
 testHandle ()
 

Private Attributes

 $client
 

Additional Inherited Members

- Protected Member Functions inherited from Monolog\TestCase
 getRecord ($level=Logger::WARNING, $message='test', $context=array())
 
 getMultipleRecords ()
 
 getIdentityFormatter ()
 

Detailed Description

Definition at line 16 of file DynamoDbHandlerTest.php.

Member Function Documentation

◆ setUp()

Monolog\Handler\DynamoDbHandlerTest::setUp ( )

Definition at line 20 of file DynamoDbHandlerTest.php.

21  {
22  if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
23  $this->markTestSkipped('aws/aws-sdk-php not installed');
24  }
25 
26  $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
27  ->setMethods(array('formatAttributes', '__call'))
28  ->disableOriginalConstructor()->getMock();
29  }

◆ testConstruct()

Monolog\Handler\DynamoDbHandlerTest::testConstruct ( )

Definition at line 31 of file DynamoDbHandlerTest.php.

32  {
33  $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo'));
34  }

◆ testGetFormatter()

Monolog\Handler\DynamoDbHandlerTest::testGetFormatter ( )

Definition at line 41 of file DynamoDbHandlerTest.php.

References $handler.

42  {
43  $handler = new DynamoDbHandler($this->client, 'foo');
44  $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter());
45  }
$handler

◆ testHandle()

Monolog\Handler\DynamoDbHandlerTest::testHandle ( )

Definition at line 47 of file DynamoDbHandlerTest.php.

References $handler, Monolog\TestCase\getRecord(), and Sabre\Event\once().

48  {
49  $record = $this->getRecord();
50  $formatter = $this->getMock('Monolog\Formatter\FormatterInterface');
51  $formatted = array('foo' => 1, 'bar' => 2);
52  $handler = new DynamoDbHandler($this->client, 'foo');
53  $handler->setFormatter($formatter);
54 
55  $isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
56  if ($isV3) {
57  $expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
58  } else {
59  $expFormatted = $formatted;
60  }
61 
62  $formatter
63  ->expects($this->once())
64  ->method('format')
65  ->with($record)
66  ->will($this->returnValue($formatted));
67  $this->client
68  ->expects($isV3 ? $this->never() : $this->once())
69  ->method('formatAttributes')
70  ->with($this->isType('array'))
71  ->will($this->returnValue($formatted));
72  $this->client
73  ->expects($this->once())
74  ->method('__call')
75  ->with('putItem', array(array(
76  'TableName' => 'foo',
77  'Item' => $expFormatted,
78  )));
79 
80  $handler->handle($record);
81  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$handler
+ Here is the call graph for this function:

◆ testInterface()

Monolog\Handler\DynamoDbHandlerTest::testInterface ( )

Definition at line 36 of file DynamoDbHandlerTest.php.

37  {
38  $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo'));
39  }

Field Documentation

◆ $client

Monolog\Handler\DynamoDbHandlerTest::$client
private

Definition at line 18 of file DynamoDbHandlerTest.php.


The documentation for this class was generated from the following file: