4 * This file is part of the Monolog package.
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Monolog\Handler;
16 class DynamoDbHandlerTest extends TestCase
20 public function setUp()
22 if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
23 $this->markTestSkipped('aws/aws-sdk-php not installed');
26 $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
27 ->setMethods(array('formatAttributes', '__call'))
28 ->disableOriginalConstructor()->getMock();
31 public function testConstruct()
33 $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo'));
36 public function testInterface()
38 $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo'));
41 public function testGetFormatter()
43 $handler = new DynamoDbHandler($this->client, 'foo');
44 $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter());
47 public function testHandle()
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);
56 ->expects($this->once())
59 ->will($this->returnValue($formatted));
61 ->expects($this->once())
62 ->method('formatAttributes')
63 ->with($this->isType('array'))
64 ->will($this->returnValue($formatted));
66 ->expects($this->once())
68 ->with('putItem', array(array(
73 $handler->handle($record);