mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-02 11:20:31 +02:00
Fix of absent formatAttributes method issue
This commit is contained in:
@@ -17,14 +17,27 @@ class DynamoDbHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
private $client;
|
private $client;
|
||||||
|
|
||||||
|
private $isV3;
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
|
if (!class_exists('Aws\DynamoDb\DynamoDbClient')) {
|
||||||
$this->markTestSkipped('aws/aws-sdk-php not installed');
|
$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')
|
$this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient')
|
||||||
->onlyMethods(['formatAttributes', '__call'])
|
->onlyMethods($implementedMethods)
|
||||||
|
->addMethods($absentMethods)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
}
|
}
|
||||||
@@ -53,8 +66,7 @@ class DynamoDbHandlerTest extends TestCase
|
|||||||
$handler = new DynamoDbHandler($this->client, 'foo');
|
$handler = new DynamoDbHandler($this->client, 'foo');
|
||||||
$handler->setFormatter($formatter);
|
$handler->setFormatter($formatter);
|
||||||
|
|
||||||
$isV3 = defined('Aws\Sdk::VERSION') && version_compare(\Aws\Sdk::VERSION, '3.0', '>=');
|
if ($this->isV3) {
|
||||||
if ($isV3) {
|
|
||||||
$expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
|
$expFormatted = array('foo' => array('N' => 1), 'bar' => array('N' => 2));
|
||||||
} else {
|
} else {
|
||||||
$expFormatted = $formatted;
|
$expFormatted = $formatted;
|
||||||
@@ -66,7 +78,7 @@ class DynamoDbHandlerTest extends TestCase
|
|||||||
->with($record)
|
->with($record)
|
||||||
->will($this->returnValue($formatted));
|
->will($this->returnValue($formatted));
|
||||||
$this->client
|
$this->client
|
||||||
->expects($isV3 ? $this->never() : $this->once())
|
->expects($this->isV3 ? $this->never() : $this->once())
|
||||||
->method('formatAttributes')
|
->method('formatAttributes')
|
||||||
->with($this->isType('array'))
|
->with($this->isType('array'))
|
||||||
->will($this->returnValue($formatted));
|
->will($this->returnValue($formatted));
|
||||||
|
Reference in New Issue
Block a user