diff --git a/tests/Monolog/Handler/DynamoDbHandlerTest.php b/tests/Monolog/Handler/DynamoDbHandlerTest.php index 2d8f9f6d..b6df9bae 100644 --- a/tests/Monolog/Handler/DynamoDbHandlerTest.php +++ b/tests/Monolog/Handler/DynamoDbHandlerTest.php @@ -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));