From 55b84d7c20a9f3458214fadac0bc06dd486fb1ed Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Fri, 27 Nov 2020 12:39:54 +0100 Subject: [PATCH] Fix tests with PHPUnit --- tests/ClickatellHandlerTest.php | 11 +++++------ tests/PlivoHandlerTest.php | 11 +++++------ tests/TestCase.php | 3 ++- tests/TwilioHandlerTest.php | 11 +++++------ 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/tests/ClickatellHandlerTest.php b/tests/ClickatellHandlerTest.php index a3b48fd..503c383 100644 --- a/tests/ClickatellHandlerTest.php +++ b/tests/ClickatellHandlerTest.php @@ -14,7 +14,7 @@ class ClickatellHandlerTest extends TestCase /** @var ClickatellHandler */ private $handler; - + public function testCanBeInstantiatedAndProvidesDefaultFormatter() { $handler = new ClickatellHandler('token', '+15555555555', '+16666666666'); @@ -97,11 +97,10 @@ private function createHandler($authToken = 'token', $fromNumber = '+15555555555 { $constructorArgs = array($authToken, $fromNumber, $toNumber, Logger::DEBUG, true, true, $host, $version); $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Tylercd100\Monolog\Handler\ClickatellHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); + $this->handler = $this->getMockBuilder(ClickatellHandler::class) + ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) + ->setConstructorArgs($constructorArgs) + ->getMock(); $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); diff --git a/tests/PlivoHandlerTest.php b/tests/PlivoHandlerTest.php index 15dc22c..453809e 100644 --- a/tests/PlivoHandlerTest.php +++ b/tests/PlivoHandlerTest.php @@ -13,7 +13,7 @@ class PlivoHandlerTest extends TestCase private $res; /** @var PlivoHandler */ private $handler; - + public function testCanBeInstantiatedAndProvidesDefaultFormatter() { $handler = new PlivoHandler('token', 'auth_id', '+15555555555', '+16666666666'); @@ -97,11 +97,10 @@ private function createHandler($authToken = 'token', $authId = 'auth_id', $fromN { $constructorArgs = array($authToken, $authId, $fromNumber, $toNumber, Logger::DEBUG, true, true, $host, $version); $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Tylercd100\Monolog\Handler\PlivoHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); + $this->handler = $this->getMockBuilder(PlivoHandler::class) + ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) + ->setConstructorArgs($constructorArgs) + ->getMock(); $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true); diff --git a/tests/TestCase.php b/tests/TestCase.php index b0cff75..c6a071f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -12,6 +12,7 @@ namespace Tylercd100\Monolog\Tests; use Monolog\Logger; +use Monolog\Formatter\FormatterInterface; class TestCase extends \PHPUnit_Framework_TestCase { @@ -50,7 +51,7 @@ protected function getMultipleRecords() */ protected function getIdentityFormatter() { - $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $formatter = $this->getMockBuilder(FormatterInterface::class)->getMock(); $formatter->expects($this->any()) ->method('format') ->will($this->returnCallback(function ($record) { return $record['message']; })); diff --git a/tests/TwilioHandlerTest.php b/tests/TwilioHandlerTest.php index 24cd88f..613f623 100644 --- a/tests/TwilioHandlerTest.php +++ b/tests/TwilioHandlerTest.php @@ -13,7 +13,7 @@ class TwilioHandlerTest extends TestCase private $res; /** @var TwilioHandler */ private $handler; - + public function testCanBeInstantiatedAndProvidesDefaultFormatter() { $handler = new TwilioHandler('token', 'auth_id', '+15555555555', '+16666666666'); @@ -97,11 +97,10 @@ private function createHandler($authToken = 'token', $authId = 'auth_id', $fromN { $constructorArgs = array($authToken, $authId, $fromNumber, $toNumber, Logger::DEBUG, true, true, $host, $version); $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Tylercd100\Monolog\Handler\TwilioHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); + $this->handler = $this->getMockBuilder(TwilioHandler::class) + ->setMethods(['fsockopen', 'streamSetTimeout', 'closeSocket']) + ->setConstructorArgs($constructorArgs) + ->getMock(); $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); $reflectionProperty->setAccessible(true);