Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 43 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,62 @@ php:
- 7.2
- 7.3
- 7.4
- 8.0

env:
matrix:
# All versions below should be test on PHP ^7.1 (Sentry SDK requirement)
- LARAVEL=5.1.* TESTBENCH=3.1.* PHPUNIT=5.7.* SENTRY=^3.0
- LARAVEL=5.2.* TESTBENCH=3.2.* PHPUNIT=5.7.* SENTRY=^3.0
- LARAVEL=5.3.* TESTBENCH=3.3.* PHPUNIT=5.7.* SENTRY=^3.0
- LARAVEL=5.4.* TESTBENCH=3.4.* PHPUNIT=5.7.* SENTRY=^3.0
- LARAVEL=5.5.* TESTBENCH=3.5.* PHPUNIT=6.5.* SENTRY=^3.0
- LARAVEL=5.6.* TESTBENCH=3.6.* PHPUNIT=7.5.* SENTRY=^3.0
- LARAVEL=5.7.* TESTBENCH=3.7.* PHPUNIT=7.5.* SENTRY=^3.0
- LARAVEL=5.8.* TESTBENCH=3.8.* PHPUNIT=7.5.* SENTRY=^3.0
- LARAVEL=5.1.* TESTBENCH=3.1.* PHPUNIT=5.7.*
- LARAVEL=5.2.* TESTBENCH=3.2.* PHPUNIT=5.7.*
- LARAVEL=5.3.* TESTBENCH=3.3.* PHPUNIT=5.7.*
- LARAVEL=5.4.* TESTBENCH=3.4.* PHPUNIT=5.7.*
- LARAVEL=5.5.* TESTBENCH=3.5.* PHPUNIT=6.5.*
- LARAVEL=5.6.* TESTBENCH=3.6.* PHPUNIT=7.5.*
- LARAVEL=5.7.* TESTBENCH=3.7.* PHPUNIT=7.5.*
- LARAVEL=5.8.* TESTBENCH=3.8.* PHPUNIT=7.5.*
- LARAVEL=^6.0 TESTBENCH=4.7.* PHPUNIT=8.4.*
- LARAVEL=^7.0 TESTBENCH=5.1.* PHPUNIT=8.4.*

# All versions below only support PHP ^7.2 (Laravel requirement)
- LARAVEL=^6.0 TESTBENCH=4.7.* PHPUNIT=8.4.* SENTRY=^3.0
- LARAVEL=^7.0 TESTBENCH=5.1.* PHPUNIT=8.4.* SENTRY=^3.0
# All versions below only support PHP ^7.3 (Laravel requirement)
- LARAVEL=^8.0 TESTBENCH=^6.0 PHPUNIT=9.3.*

# We add one more test using the next version of Laravel which only support PHP ^7.3 (Laravel requirement)
- LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=8.4.* SENTRY=^3.0 COMPOSER_STABILITY=dev
# We add one more test using the bleeding edge version of Laravel
- LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=9.3.* COMPOSER_STABILITY=dev

matrix:
fast_finish: true
allow_failures:
- php: 7.3
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=8.4.* SENTRY=^3.0 COMPOSER_STABILITY=dev
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=9.3.* COMPOSER_STABILITY=dev
- php: 7.4
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=8.4.* SENTRY=^3.0 COMPOSER_STABILITY=dev
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=9.3.* COMPOSER_STABILITY=dev
- php: 8.0
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=9.3.* COMPOSER_STABILITY=dev
exclude:
- php: 7.2
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=8.4.* SENTRY=^3.0 COMPOSER_STABILITY=dev
env: LARAVEL=^8.0 TESTBENCH=^6.0 PHPUNIT=9.3.*
- php: 7.2
env: LARAVEL=8.x-dev@dev TESTBENCH=^6.0 PHPUNIT=9.3.* COMPOSER_STABILITY=dev
- php: 8.0
env: LARAVEL=5.1.* TESTBENCH=3.1.* PHPUNIT=5.7.*
- php: 8.0
env: LARAVEL=5.2.* TESTBENCH=3.2.* PHPUNIT=5.7.*
- php: 8.0
env: LARAVEL=5.3.* TESTBENCH=3.3.* PHPUNIT=5.7.*
- php: 8.0
env: LARAVEL=5.4.* TESTBENCH=3.4.* PHPUNIT=5.7.*
- php: 8.0
env: LARAVEL=5.5.* TESTBENCH=3.5.* PHPUNIT=6.5.*
- php: 8.0
env: LARAVEL=5.6.* TESTBENCH=3.6.* PHPUNIT=7.5.*
- php: 8.0
env: LARAVEL=5.7.* TESTBENCH=3.7.* PHPUNIT=7.5.*
- php: 8.0
env: LARAVEL=5.8.* TESTBENCH=3.8.* PHPUNIT=7.5.*
- php: 8.0
env: LARAVEL=^6.0 TESTBENCH=4.7.* PHPUNIT=8.4.*
- php: 8.0
env: LARAVEL=^7.0 TESTBENCH=5.1.* PHPUNIT=8.4.*

cache:
directories:
Expand All @@ -54,7 +80,7 @@ jobs:
before_install:
- if [ "$USE_COMPOSER_JSON" != "1" ]; then composer remove friendsofphp/php-cs-fixer --dev --no-update; fi;
- if [ "$USE_COMPOSER_JSON" != "1" ]; then composer config minimum-stability ${COMPOSER_STABILITY:=stable}; fi;
- if [ "$USE_COMPOSER_JSON" != "1" ]; then composer require laravel/framework:$LARAVEL illuminate/support:$LARAVEL orchestra/testbench:$TESTBENCH phpunit/phpunit:$PHPUNIT sentry/sentry:$SENTRY --no-update --no-interaction --dev; fi;
- if [ "$USE_COMPOSER_JSON" != "1" ]; then composer require laravel/framework:$LARAVEL illuminate/support:$LARAVEL orchestra/testbench:$TESTBENCH phpunit/phpunit:$PHPUNIT --no-update --no-interaction --dev; fi;

install:
- travis_retry composer install --no-suggest --no-interaction --prefer-dist --no-progress
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

- PHP 8 Support (#431)
- Bump Sentry SDK to `3.2.*` (#431)

## 2.3.0

- Bump Sentry SDK to `3.1.*` (#420)
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.2 | ^8.0",
"illuminate/support": "5.0 - 5.8 | ^6.0 | ^7.0 | ^8.0",
"sentry/sentry": "3.1.*",
"sentry/sdk": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"laravel/framework": "^7.0",
"orchestra/testbench": "^5.0",
"phpunit/phpunit": "^9.3",
"laravel/framework": "^8.0",
"orchestra/testbench": "^6.0",
"friendsofphp/php-cs-fixer": "2.16.*",
"mockery/mockery": "1.3.*"
},
Expand All @@ -48,10 +48,10 @@
"vendor/bin/phpunit --verbose"
],
"tests-travis": [
"vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-clover test/clover.xml"
"XDEBUG_MODE=coverage vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-clover test/clover.xml"
],
"tests-report": [
"vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-html test/html-report"
"XDEBUG_MODE=coverage vendor/bin/phpunit --verbose --configuration phpunit.xml --coverage-html test/html-report"
],
"phpcs": [
"vendor/bin/php-cs-fixer fix --config=.php_cs --verbose --diff --dry-run"
Expand Down
8 changes: 5 additions & 3 deletions test/Sentry/EventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
namespace Sentry\Laravel\Tests;

use ReflectionClass;
use RuntimeException;
use Sentry\Laravel\EventHandler;
use Orchestra\Testbench\TestCase;

class EventHandlerTest extends TestCase
{
/**
* @expectedException \RuntimeException
*/
use ExpectsException;

public function test_missing_event_handler_throws_exception()
{
$this->safeExpectException(RuntimeException::class);

$handler = new EventHandler($this->app->events, []);

$handler->thisIsNotAHandlerAndShouldThrowAnException();
Expand Down
25 changes: 25 additions & 0 deletions test/Sentry/ExpectsException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Sentry\Laravel\Tests;

use RuntimeException;

trait ExpectsException
{
protected function safeExpectException(string $class): void
{
if (method_exists($this, 'expectException')) {
$this->expectException($class);

return;
}

if (method_exists($this, 'setExpectedException')) {
$this->setExpectedException($class);

return;
}

throw new RuntimeException('Could not expect an exception.');
}
}
13 changes: 8 additions & 5 deletions test/Sentry/IntegrationsOptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

namespace Sentry\Laravel\Tests;

use Exception;
use RuntimeException;
use Sentry\Integration\IntegrationInterface;
use Sentry\Integration\ErrorListenerIntegration;
use Sentry\Integration\ExceptionListenerIntegration;
use Sentry\Integration\FatalErrorListenerIntegration;

class IntegrationsOptionTest extends SentryLaravelTestCase
{
use ExpectsException;

protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);
Expand Down Expand Up @@ -53,23 +57,22 @@ public function testCustomIntegrationByInstance()

/**
* Throws \ReflectionException in <=5.8 and \Illuminate\Contracts\Container\BindingResolutionException since 6.0
*
* @expectedException \Exception
*/
public function testCustomIntegrationThrowsExceptionIfNotResolvable()
{
$this->safeExpectException(Exception::class);

$this->resetApplicationWithConfig([
'sentry.integrations' => [
'this-will-not-resolve',
],
]);
}

/**
* @expectedException \RuntimeException
*/
public function testIncorrectIntegrationEntryThrowsException()
{
$this->safeExpectException(RuntimeException::class);

$this->resetApplicationWithConfig([
'sentry.integrations' => [
static function () {
Expand Down
9 changes: 6 additions & 3 deletions test/Sentry/Tracing/EventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
use Mockery;
use ReflectionClass;
use Orchestra\Testbench\TestCase;
use RuntimeException;
use Sentry\Laravel\Tests\ExpectsException;
use Sentry\Laravel\Tracing\EventHandler;
use Sentry\SentrySdk;
use Sentry\Tracing\TransactionContext;

class EventHandlerTest extends TestCase
{
/**
* @expectedException \RuntimeException
*/
use ExpectsException;

public function test_missing_event_handler_throws_exception()
{
$this->safeExpectException(RuntimeException::class);

$handler = new EventHandler($this->app->events);

$handler->thisIsNotAHandlerAndShouldThrowAnException();
Expand Down