From 7f706d27ae16377812bbd8266a941943efece013 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Fri, 27 Nov 2020 12:39:05 +0100 Subject: [PATCH 1/4] Update Travis CI and composer config to use PHP >= 7.2 --- .travis.yml | 13 +++---------- composer.json | 6 +++--- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 928b259..f54f092 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: php php: - - 5.5.9 - - 5.5 - - 5.6 - - 7.0 - - hhvm + - 7.2 + - 7.3 + - 7.4 env: matrix: @@ -18,8 +16,3 @@ before_script: script: - vendor/bin/phpunit - - if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi - -after_script: - - if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [ "$TRAVIS_PHP_VERSION" == "5.5.9" ] || [ "$TRAVIS_PHP_VERSION" == "5.5" ] || [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi diff --git a/composer.json b/composer.json index a3c2218..a4fb0b3 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,11 @@ }, "minimum-stability": "stable", "require": { - "php": "^5.4|^7.0", - "monolog/monolog": "^1.12 || ^2.0" + "php": "^7.0", + "monolog/monolog": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^4.0|^5.0" + "phpunit/phpunit": "^5.0" }, "authors": [ { From 7452983209b0a4824713ae825e75387f446fe9f0 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Fri, 27 Nov 2020 12:39:28 +0100 Subject: [PATCH 2/4] Fix SMSHandler to be compatible with Monolog 2 --- src/Handler/SMSHandler.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Handler/SMSHandler.php b/src/Handler/SMSHandler.php index 29e745c..3d8ce49 100644 --- a/src/Handler/SMSHandler.php +++ b/src/Handler/SMSHandler.php @@ -3,6 +3,7 @@ namespace Tylercd100\Monolog\Handler; use Exception; +use Monolog\Formatter\FormatterInterface; use Monolog\Handler\SocketHandler; use Monolog\Logger; use Tylercd100\Monolog\Formatter\SMSFormatter; @@ -81,7 +82,7 @@ public function __construct($authToken, $authId, $fromNumber, $toNumber, $level * @param array $record * @return string */ - protected function generateDataStream($record) + protected function generateDataStream(array $record) :string { $content = $this->buildContent($record); return $this->buildHeader($content) . $content; @@ -133,7 +134,7 @@ private function buildHeader($content) * * @param array $record */ - protected function write(array $record) + protected function write(array $record) :void { parent::write($record); $this->closeSocket(); @@ -142,7 +143,7 @@ protected function write(array $record) /** * {@inheritdoc} */ - protected function getDefaultFormatter() + protected function getDefaultFormatter(): FormatterInterface { return new SMSFormatter(); } From 55b84d7c20a9f3458214fadac0bc06dd486fb1ed Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Fri, 27 Nov 2020 12:39:54 +0100 Subject: [PATCH 3/4] 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); From 62cdce8fca775754aafd5354e5af5b3aabcaadf1 Mon Sep 17 00:00:00 2001 From: Tortue Torche Date: Mon, 30 Nov 2020 10:39:25 +0100 Subject: [PATCH 4/4] Support PHP 8.0 And update tests to support PHPUnit >= 8.0 --- .travis.yml | 1 + composer.json | 7 +++--- tests/ClickatellHandlerTest.php | 20 ++++++++--------- tests/PlivoHandlerTest.php | 22 +++++++++--------- tests/TestCase.php | 40 +++++++++++++++++++++++++++++++-- tests/TwilioHandlerTest.php | 22 +++++++++--------- 6 files changed, 75 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index f54f092..a58d062 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php: - 7.2 - 7.3 - 7.4 + - 8.0snapshot env: matrix: diff --git a/composer.json b/composer.json index a4fb0b3..912edfd 100644 --- a/composer.json +++ b/composer.json @@ -22,13 +22,14 @@ "Tylercd100\\Monolog\\Tests\\": "tests/" } }, - "minimum-stability": "stable", + "minimum-stability": "dev", + "prefer-stable": true, "require": { - "php": "^7.0", + "php": "^7.2|^8.0", "monolog/monolog": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^8.2.3|^9.0" }, "authors": [ { diff --git a/tests/ClickatellHandlerTest.php b/tests/ClickatellHandlerTest.php index 503c383..4e1b30b 100644 --- a/tests/ClickatellHandlerTest.php +++ b/tests/ClickatellHandlerTest.php @@ -20,14 +20,14 @@ public function testCanBeInstantiatedAndProvidesDefaultFormatter() $handler = new ClickatellHandler('token', '+15555555555', '+16666666666'); $this->assertInstanceOf('Tylercd100\\Monolog\\Formatter\\SMSFormatter', $handler->getFormatter()); - $this->assertAttributeEquals('token', 'authToken', $handler); - $this->assertAttributeEquals('+15555555555', 'fromNumber', $handler); - $this->assertAttributeEquals('+16666666666', 'toNumber', $handler); + $this->assertEquals('token', $this->accessProtected($handler, 'authToken')); + $this->assertEquals('+15555555555', $this->accessProtected($handler, 'fromNumber')); + $this->assertEquals('+16666666666', $this->accessProtected($handler, 'toNumber')); } public function testItThrowsExceptionWhenUsingDifferentVersionOtherThanV1() { - $this->setExpectedException(Exception::class); + $this->expectException(Exception::class); $handler = new ClickatellHandler('token', 'auth_id', '+15555555555', '+16666666666', Logger::CRITICAL, true, true, 'twilio.foo.bar', 'v2'); } @@ -38,7 +38,7 @@ public function testWriteHeader() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/POST \/messages HTTP\/1.1\\r\\nHost: platform.clickatell.com\\r\\nAuthorization: token\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + $this->assertMatchesRegularExpression('/POST \/messages HTTP\/1.1\\r\\nHost: platform.clickatell.com\\r\\nAuthorization: token\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); return $content; } @@ -50,7 +50,7 @@ public function testWriteCustomHostHeader() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/POST \/messages HTTP\/1.1\\r\\nHost: twilio.foo.bar\\r\\nAuthorization: token\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + $this->assertMatchesRegularExpression('/POST \/messages HTTP\/1.1\\r\\nHost: twilio.foo.bar\\r\\nAuthorization: token\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); return $content; } @@ -60,7 +60,7 @@ public function testWriteCustomHostHeader() */ public function testWriteContent($content) { - $this->assertRegexp('/{"content":"test1","to":\["\+16666666666"\],"from":"\+15555555555"}/', $content); + $this->assertMatchesRegularExpression('/{"content":"test1","to":\["\+16666666666"\],"from":"\+15555555555"}/', $content); } public function testWriteContentV1WithoutToAndFromNumbers() @@ -70,7 +70,7 @@ public function testWriteContentV1WithoutToAndFromNumbers() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/{"content":"test1","to":\[null\]}/', $content); + $this->assertMatchesRegularExpression('/{"content":"test1","to":\[null\]}/', $content); return $content; } @@ -80,7 +80,7 @@ public function testWriteContentV1WithoutToAndFromNumbers() */ public function testWriteContentNotify($content) { - $this->assertRegexp('/{"content":"test1","to":\["\+16666666666"\],"from":"\+15555555555"}/', $content); + $this->assertMatchesRegularExpression('/{"content":"test1","to":\["\+16666666666"\],"from":"\+15555555555"}/', $content); } public function testWriteWithComplexMessage() @@ -90,7 +90,7 @@ public function testWriteWithComplexMessage() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/{"content":"Backup of database example finished in 16 minutes\.","to":\["\+16666666666"\],"from":"\+15555555555"}/', $content); + $this->assertMatchesRegularExpression('/{"content":"Backup of database example finished in 16 minutes\.","to":\["\+16666666666"\],"from":"\+15555555555"}/', $content); } private function createHandler($authToken = 'token', $fromNumber = '+15555555555', $toNumber = '+16666666666', $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'platform.clickatell.com', $version = ClickatellHandler::API_V1) diff --git a/tests/PlivoHandlerTest.php b/tests/PlivoHandlerTest.php index 453809e..2b2c3a0 100644 --- a/tests/PlivoHandlerTest.php +++ b/tests/PlivoHandlerTest.php @@ -19,15 +19,15 @@ public function testCanBeInstantiatedAndProvidesDefaultFormatter() $handler = new PlivoHandler('token', 'auth_id', '+15555555555', '+16666666666'); $this->assertInstanceOf('Tylercd100\\Monolog\\Formatter\\SMSFormatter', $handler->getFormatter()); - $this->assertAttributeEquals('token', 'authToken', $handler); - $this->assertAttributeEquals('auth_id', 'authId', $handler); - $this->assertAttributeEquals('+15555555555', 'fromNumber', $handler); - $this->assertAttributeEquals('+16666666666', 'toNumber', $handler); + $this->assertEquals('token', $this->accessProtected($handler, 'authToken')); + $this->assertEquals('auth_id', $this->accessProtected($handler, 'authId')); + $this->assertEquals('+15555555555', $this->accessProtected($handler, 'fromNumber')); + $this->assertEquals('+16666666666', $this->accessProtected($handler, 'toNumber')); } public function testItThrowsExceptionWhenUsingDifferentVersionOtherThanV1() { - $this->setExpectedException(Exception::class); + $this->expectException(Exception::class); $handler = new PlivoHandler('token', 'auth_id', '+15555555555', '+16666666666', Logger::CRITICAL, true, true, 'plivo.foo.bar', 'v2'); } @@ -38,7 +38,7 @@ public function testWriteHeader() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/POST \/v1\/Account\/auth_id\/Message\/ HTTP\/1.1\\r\\nHost: api.plivo.com\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + $this->assertMatchesRegularExpression('/POST \/v1\/Account\/auth_id\/Message\/ HTTP\/1.1\\r\\nHost: api.plivo.com\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); return $content; } @@ -50,7 +50,7 @@ public function testWriteCustomHostHeader() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/POST \/v1\/Account\/auth_id\/Message\/ HTTP\/1.1\\r\\nHost: plivo.foo.bar\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + $this->assertMatchesRegularExpression('/POST \/v1\/Account\/auth_id\/Message\/ HTTP\/1.1\\r\\nHost: plivo.foo.bar\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); return $content; } @@ -60,7 +60,7 @@ public function testWriteCustomHostHeader() */ public function testWriteContent($content) { - $this->assertRegexp('/{"src":"\+15555555555","dst":"\+16666666666","text":"test1"}/', $content); + $this->assertMatchesRegularExpression('/{"src":"\+15555555555","dst":"\+16666666666","text":"test1"}/', $content); } public function testWriteContentV1WithoutToAndFromNumbers() @@ -70,7 +70,7 @@ public function testWriteContentV1WithoutToAndFromNumbers() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/{"src":false,"dst":null,"text":"test1"}/', $content); + $this->assertMatchesRegularExpression('/{"src":false,"dst":null,"text":"test1"}/', $content); return $content; } @@ -80,7 +80,7 @@ public function testWriteContentV1WithoutToAndFromNumbers() */ public function testWriteContentNotify($content) { - $this->assertRegexp('/{"src":"\+15555555555","dst":"\+16666666666","text":"test1"}/', $content); + $this->assertMatchesRegularExpression('/{"src":"\+15555555555","dst":"\+16666666666","text":"test1"}/', $content); } public function testWriteWithComplexMessage() @@ -90,7 +90,7 @@ public function testWriteWithComplexMessage() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/{"src":"\+15555555555","dst":"\+16666666666","text":"Backup of database example finished in 16 minutes\."}/', $content); + $this->assertMatchesRegularExpression('/{"src":"\+15555555555","dst":"\+16666666666","text":"Backup of database example finished in 16 minutes\."}/', $content); } private function createHandler($authToken = 'token', $authId = 'auth_id', $fromNumber = '+15555555555', $toNumber = '+16666666666', $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.plivo.com', $version = PlivoHandler::API_V1) diff --git a/tests/TestCase.php b/tests/TestCase.php index c6a071f..fcd28f7 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,10 +11,12 @@ namespace Tylercd100\Monolog\Tests; +use ReflectionClass; use Monolog\Logger; use Monolog\Formatter\FormatterInterface; +use PHPUnit\Framework\TestCase as PHPUnitTestCase; -class TestCase extends \PHPUnit_Framework_TestCase +class TestCase extends PHPUnitTestCase { /** * @return array Record @@ -54,8 +56,42 @@ protected function getIdentityFormatter() $formatter = $this->getMockBuilder(FormatterInterface::class)->getMock(); $formatter->expects($this->any()) ->method('format') - ->will($this->returnCallback(function ($record) { return $record['message']; })); + ->will( + $this->returnCallback(function ($record) { + return $record['message']; + }) + ); return $formatter; } + + /** + * Helper to return protected or private property value of an object + * + * @param mixed $object + * @param string $property + * @return mixed + */ + protected function accessProtected($object, $property) + { + $reflection = new ReflectionClass($object); + $propertyReflection = $reflection->getProperty($property); + $propertyReflection->setAccessible(true); + + return $propertyReflection->getValue($object); + } + + /** + * {@inheritdoc} + */ + public static function assertMatchesRegularExpression(string $pattern, string $string, string $message = ''): void + { + if (method_exists(PHPUnitTestCase::class, 'assertMatchesRegularExpression')) { + // For PHPUnit >= 9 + parent::assertMatchesRegularExpression($pattern, $string, $message); + } else { + // For PHPUnit < 9 + static::assertRegExp($pattern, $string, $message); + } + } } diff --git a/tests/TwilioHandlerTest.php b/tests/TwilioHandlerTest.php index 613f623..dd30d2c 100644 --- a/tests/TwilioHandlerTest.php +++ b/tests/TwilioHandlerTest.php @@ -19,15 +19,15 @@ public function testCanBeInstantiatedAndProvidesDefaultFormatter() $handler = new TwilioHandler('token', 'auth_id', '+15555555555', '+16666666666'); $this->assertInstanceOf('Tylercd100\\Monolog\\Formatter\\SMSFormatter', $handler->getFormatter()); - $this->assertAttributeEquals('token', 'authToken', $handler); - $this->assertAttributeEquals('auth_id', 'authId', $handler); - $this->assertAttributeEquals('+15555555555', 'fromNumber', $handler); - $this->assertAttributeEquals('+16666666666', 'toNumber', $handler); + $this->assertEquals('token', $this->accessProtected($handler, 'authToken')); + $this->assertEquals('auth_id', $this->accessProtected($handler, 'authId')); + $this->assertEquals('+15555555555', $this->accessProtected($handler, 'fromNumber')); + $this->assertEquals('+16666666666', $this->accessProtected($handler, 'toNumber')); } public function testItThrowsExceptionWhenUsingDifferentVersionOtherThanV1() { - $this->setExpectedException(Exception::class); + $this->expectException(Exception::class); $handler = new TwilioHandler('token', 'auth_id', '+15555555555', '+16666666666', Logger::CRITICAL, true, true, 'twilio.foo.bar', 'v2'); } @@ -38,7 +38,7 @@ public function testWriteHeader() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/POST \/2010-04-01\/Accounts\/auth_id\/Messages\.json HTTP\/1.1\\r\\nHost: api.twilio.com\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + $this->assertMatchesRegularExpression('/POST \/2010-04-01\/Accounts\/auth_id\/Messages\.json HTTP\/1.1\\r\\nHost: api.twilio.com\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); return $content; } @@ -50,7 +50,7 @@ public function testWriteCustomHostHeader() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/POST \/2010-04-01\/Accounts\/auth_id\/Messages.json HTTP\/1.1\\r\\nHost: twilio.foo.bar\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + $this->assertMatchesRegularExpression('/POST \/2010-04-01\/Accounts\/auth_id\/Messages.json HTTP\/1.1\\r\\nHost: twilio.foo.bar\\r\\nAuthorization: Basic YXV0aF9pZDp0b2tlbg==\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); return $content; } @@ -60,7 +60,7 @@ public function testWriteCustomHostHeader() */ public function testWriteContent($content) { - $this->assertRegexp('/{"From":"\+15555555555","To":"\+16666666666","Body":"test1"}/', $content); + $this->assertMatchesRegularExpression('/{"From":"\+15555555555","To":"\+16666666666","Body":"test1"}/', $content); } public function testWriteContentV1WithoutToAndFromNumbers() @@ -70,7 +70,7 @@ public function testWriteContentV1WithoutToAndFromNumbers() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/{"From":false,"To":null,"Body":"test1"}/', $content); + $this->assertMatchesRegularExpression('/{"From":false,"To":null,"Body":"test1"}/', $content); return $content; } @@ -80,7 +80,7 @@ public function testWriteContentV1WithoutToAndFromNumbers() */ public function testWriteContentNotify($content) { - $this->assertRegexp('/{"From":"\+15555555555","To":"\+16666666666","Body":"test1"}/', $content); + $this->assertMatchesRegularExpression('/{"From":"\+15555555555","To":"\+16666666666","Body":"test1"}/', $content); } public function testWriteWithComplexMessage() @@ -90,7 +90,7 @@ public function testWriteWithComplexMessage() fseek($this->res, 0); $content = fread($this->res, 1024); - $this->assertRegexp('/{"From":"\+15555555555","To":"\+16666666666","Body":"Backup of database example finished in 16 minutes\."}/', $content); + $this->assertMatchesRegularExpression('/{"From":"\+15555555555","To":"\+16666666666","Body":"Backup of database example finished in 16 minutes\."}/', $content); } private function createHandler($authToken = 'token', $authId = 'auth_id', $fromNumber = '+15555555555', $toNumber = '+16666666666', $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $host = 'api.twilio.com', $version = TwilioHandler::API_V1)