From 2dd4a0fa3db177508b6a4ade3a5e6fea7bf06a47 Mon Sep 17 00:00:00 2001 From: Shawn Iwinski Date: Sun, 6 Nov 2016 11:11:41 -0500 Subject: [PATCH] Fix tests for sentry/sentry >= 0.16.0 (and < 1.0) From composer.json: `"sentry/sentry": "^0.13"` Latest 0.x `sentry/sentry`: 0.22.0 sentry/sentry 0.16.0 changed the function signature of Raven_Client::capture(): 0.16.0: `public function capture($data, $stack = null, $vars = null)` 0.15.0: `public function capture($data, $stack, $vars = null)` While the test suite silently passes with PHP < 7.1, running the test suite with PHP 7.1 fails with the following error: `Declaration of Monolog\Handler\MockRavenClient::capture($data, $stack, $vars = NULL) should be compatible with Raven_Client::capture($data, $stack = NULL, $vars = NULL)` --- .../Handler/MockRavenClient-gte-0-16-0.php | 27 +++++++++++++++++++ tests/Monolog/Handler/RavenHandlerTest.php | 9 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/Monolog/Handler/MockRavenClient-gte-0-16-0.php diff --git a/tests/Monolog/Handler/MockRavenClient-gte-0-16-0.php b/tests/Monolog/Handler/MockRavenClient-gte-0-16-0.php new file mode 100644 index 00000000..07434e49 --- /dev/null +++ b/tests/Monolog/Handler/MockRavenClient-gte-0-16-0.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Raven_Client; + +class MockRavenClient extends Raven_Client +{ + public function capture($data, $stack = null, $vars = null) + { + $data = array_merge($this->get_user_data(), $data); + $this->lastData = $data; + $this->lastStack = $stack; + } + + public $lastData; + public $lastStack; +} diff --git a/tests/Monolog/Handler/RavenHandlerTest.php b/tests/Monolog/Handler/RavenHandlerTest.php index a7b3eca5..221c1de8 100644 --- a/tests/Monolog/Handler/RavenHandlerTest.php +++ b/tests/Monolog/Handler/RavenHandlerTest.php @@ -14,16 +14,21 @@ namespace Monolog\Handler; use Monolog\Test\TestCase; use Monolog\Logger; use Monolog\Formatter\LineFormatter; +use Raven_Client; class RavenHandlerTest extends TestCase { public function setUp() { if (!class_exists('Raven_Client')) { - $this->markTestSkipped('raven/raven not installed'); + $this->markTestSkipped('sentry/sentry not installed'); } - require_once __DIR__ . '/MockRavenClient.php'; + if (version_compare(Raven_Client::VERSION, '0.16.0', '>=')) { + require_once __DIR__ . '/MockRavenClient-gte-0-16-0.php'; + } else { + require_once __DIR__ . '/MockRavenClient.php'; + } } /**