Skip to content

Commit

Permalink
Fix tests with PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
tortuetorche committed Nov 27, 2020
1 parent 7452983 commit 55b84d7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
11 changes: 5 additions & 6 deletions tests/ClickatellHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ClickatellHandlerTest extends TestCase

/** @var ClickatellHandler */
private $handler;

public function testCanBeInstantiatedAndProvidesDefaultFormatter()
{
$handler = new ClickatellHandler('token', '+15555555555', '+16666666666');
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 5 additions & 6 deletions tests/PlivoHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Tylercd100\Monolog\Tests;

use Monolog\Logger;
use Monolog\Formatter\FormatterInterface;

class TestCase extends \PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -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']; }));
Expand Down
11 changes: 5 additions & 6 deletions tests/TwilioHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 55b84d7

Please sign in to comment.