1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-01 02:40:24 +02:00

Fix of absent formatAttributes method issue

This commit is contained in:
Victor Pryazhnikov
2021-02-27 15:01:34 +03:00
parent cdba0c5693
commit 227343f20b

View File

@@ -17,14 +17,27 @@ class DynamoDbHandlerTest extends TestCase
{
private $client;
private $isV3;
public function setUp(): void
{
if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
$this->markTestSkipped('aws/aws-sdk-php not installed');
}
$this->isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
$implementedMethods = ['__call'];
$absentMethods = [];
if ($this->isV3) {
$absentMethods[] = 'formatAttributes';
} else {
$implementedMethods[] = 'formatAttributes';
}
$this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
->onlyMethods(['formatAttributes', '__call'])
->onlyMethods($implementedMethods)
->addMethods($absentMethods)
->disableOriginalConstructor()
->getMock();
}
@@ -53,8 +66,7 @@ class DynamoDbHandlerTest extends TestCase
$handler = new DynamoDbHandler($this->client, 'foo');
$handler->setFormatter($formatter);
$isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
if ($isV3) {
if ($this->isV3) {
$expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
} else {
$expFormatted = $formatted;
@@ -66,7 +78,7 @@ class DynamoDbHandlerTest extends TestCase
->with($record)
->will($this->returnValue($formatted));
$this->client
->expects($isV3 ? $this->never() : $this->once())
->expects($this->isV3 ? $this->never() : $this->once())
->method('formatAttributes')
->with($this->isType('array'))
->will($this->returnValue($formatted));