Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PHP 8 #72

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/vendor/
/var/
!/var/.gitkeep
.phpunit.result.cache

composer.lock
clover.xml
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- 8.1

env:
- SYMFONY_VERSION=5.0.*
Expand All @@ -23,6 +26,12 @@ matrix:
env: SYMFONY_VERSION=5.0.*
- php: 7.3
env: SYMFONY_VERSION=5.0.*
- php: 7.4
env: SYMFONY_VERSION=5.0.*
- php: 8.0
env: SYMFONY_VERSION=5.0.*
- php: 8.1
env: SYMFONY_VERSION=5.4.*

before_install:
- composer self-update
Expand Down
2 changes: 1 addition & 1 deletion Factories/RollbarHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Rollbar\Symfony\RollbarBundle\Factories;

use Psr\Log\LogLevel;
use Rollbar\Monolog\Handler\RollbarHandler;
use Monolog\Handler\RollbarHandler;
use Rollbar\Rollbar;
use Rollbar\Symfony\RollbarBundle\DependencyInjection\RollbarExtension;
use Symfony\Component\DependencyInjection\ContainerInterface;
Expand Down
32 changes: 4 additions & 28 deletions Tests/DependencyInjection/RollbarExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,15 @@ protected function getContainerExtensions(): array
}

/**
* Test config enabled vars.
* Test config vars.
*
* @dataProvider generatorConfigVars
*
* @param string $var
* @param array $expected
*/
public function testConfigEnabledVars(string $var, array $expected): void
public function testConfigVars(string $var, array $expected, array $loadParameters = []): void
{
$this->load();
$this->load($loadParameters);

$param = $this->container->getParameter($var);

foreach ($expected as $key => $value) {
$this->assertEquals($param[$key], $value);
}
Expand All @@ -54,30 +50,10 @@ public function generatorConfigVars(): array
{
return [
['rollbar.config', ['enabled' => true]],
['rollbar.config', ['enabled' => false], ['enabled' => false]],
];
}

/**
* Test config disabled vars.
*
* @dataProvider generatorConfigVars
*
* @expectedException \PHPUnit_Framework_ExpectationFailedException
*
* @param string $var
* @param array $expected
*/
public function testConfigDisabledVars(string $var, array $expected): void
{
$this->load(['enabled' => false]);

$param = $this->container->getParameter($var);

foreach ($expected as $key => $value) {
$this->assertEquals($param[$key], $value);
}
}

/**
* Test alias.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Tests\Fixtures\App;

use Rollbar\Symfony\RollbarBundle\RollbarBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\MonologBundle\MonologBundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ parameters:
locale: ~

framework:
test: true
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: "%kernel.project_dir%/config/routing.yml"
strict_requirements: ~
2 changes: 1 addition & 1 deletion Tests/Payload/ErrorItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testInvoke(int $code, string $message, string $file, int $line,

$exception = $data['exception'];
$this->assertEquals($mapped, $exception['class']);
$this->assertContains($message, $exception['message']);
$this->assertStringContainsString($message, $exception['message']);

$this->assertCount(1, $data['frames']);

Expand Down
16 changes: 7 additions & 9 deletions Tests/Payload/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ public function setUp(): void
{
parent::setUp();

static::bootKernel();
self::bootKernel();
}

/**
* Test getContainer.
*/
public function testGetContainer(): void
{
$container = $this->getContainer();
$generator = $this->getGenerator();

$result = $generator->getContainer();

$this->assertEquals($container, $result);
$this->assertInstanceOf(ContainerInterface::class, $result);
}


/**
* Test getKernel.
*/
Expand Down Expand Up @@ -97,10 +97,9 @@ public function testGetServerInfo(): void
*/
public function testGetRequestInfo(): void
{
$container = $this->getContainer();
$generator = $this->getGenerator();

$request = $container->get('request_stack')->getCurrentRequest();
$request = $this->getContainerInstance()->get('request_stack')->getCurrentRequest();
if (empty($request)) {
$request = new Request();
}
Expand Down Expand Up @@ -185,7 +184,7 @@ public function testGetExceptionPayload(): void

list($message, $payload) = $generator->getExceptionPayload($exception);

$this->assertContains($msg, $message);
$this->assertStringContainsString($msg, $message);

$this->assertArrayHasKey('body', $payload);
$this->assertArrayHasKey('request', $payload);
Expand Down Expand Up @@ -238,13 +237,12 @@ public function generatorStrangeData(): array
[new ErrorItem()],
];
}

/**
* Get container.
*
* @return ContainerInterface
*/
private function getContainer(): ContainerInterface
private function getContainerInstance(): ContainerInterface
{
return static::$container ?? static::$kernel->getContainer();
}
Expand All @@ -256,6 +254,6 @@ private function getContainer(): ContainerInterface
*/
private function getGenerator()
{
return $this->getContainer()->get('test.' . Generator::class);
return $this->getContainerInstance()->get('test.' . Generator::class);
}
}
2 changes: 1 addition & 1 deletion Tests/Payload/TraceItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testInvoke(): void

$exception = $data['exception'];
$this->assertEquals(get_class($ex), $exception['class']);
$this->assertContains($msg, $exception['message']);
$this->assertStringContainsString($msg, $exception['message']);

$this->assertGreaterThan(1, count($data['frames']));

Expand Down
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,25 @@
]
},
"autoload-dev": {
"files": [
"Tests/Fixtures/app/AppKernel.php",
"Tests/Fixtures/ErrorHandler.php"
],
"psr-4": { "Tests\\": "tests/"}
},
"require": {
"php": ">=7.1",
"rollbar/rollbar": "^2",
"php": "^8.0",
"rollbar/rollbar": "^3",
"symfony/dependency-injection": "^5.0",
"symfony/config": "^5.0",
"symfony/http-kernel": "^5.0",
"symfony/monolog-bundle": "*",
"symfony/serializer": "*",
"ext-json": "*"
"symfony/http-foundation": "^5.0",
"symfony/monolog-bundle": "^3.0",
"symfony/serializer": "^5.0",
"ext-json": "*",
"symfony/error-handler": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
"phpunit/phpunit": "^9",
"symfony/framework-bundle": "^5.0",
"squizlabs/php_codesniffer": "^2.7",
"matthiasnoback/symfony-dependency-injection-test": "^1.1"
"squizlabs/php_codesniffer": "^3.6",
"matthiasnoback/symfony-dependency-injection-test": "^4.3"
},
"scripts": {
"test": [
Expand Down
19 changes: 7 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,25 @@

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="false"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="Tests/Fixtures/app" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="APP_ENV" value="test" force="true"/>
<server name="KERNEL_DIR" value="Tests/Fixtures/App" />
<server name="KERNEL_CLASS" value="Tests\Fixtures\App\AppKernel" />
<server name="SHELL_VERBOSITY" value="-1"/>
<env name="BOOTSTRAP_CLEAR_CACHE_ENV" value="test"/>
<env name="ROLLBAR_TEST_TOKEN" value="ad865e76e7fb496fab096ac07b1dbabb" />
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./</directory>
</whitelist>
</filter>
<php>
<env name="ROLLBAR_TEST_TOKEN" value="ad865e76e7fb496fab096ac07b1dbabb" />
</php>
</phpunit>