Skip to content

Commit 494646f

Browse files
authored
Merge pull request #62 from M6Web/fix/symfony5-compatibility
2 parents 8460c91 + e238d1e commit 494646f

15 files changed

Lines changed: 137 additions & 55 deletions

File tree

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Continuous Integration
2+
on: [push]
3+
4+
jobs:
5+
linter:
6+
name: Code style
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- uses: shivammathur/setup-php@v2
11+
with:
12+
php-version: 7.4
13+
- run: composer install --prefer-dist --no-interaction
14+
- run: bin/php-cs-fixer fix --dry-run --stop-on-violation --diff --ansi
15+
16+
tests:
17+
name: Tests
18+
runs-on: ubuntu-18.04
19+
strategy:
20+
matrix:
21+
version: ['7.1', 7.2', '7.3', '7.4', '8.0']
22+
flags: ['', '--prefer-lowest']
23+
steps:
24+
- uses: actions/checkout@master
25+
- uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.version }}
28+
coverage: xdebug2
29+
- run: composer update --prefer-dist --no-interaction ${{ matrix.flags }}
30+
- run: bin/atoum

.php-cs-fixer.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
$config = new class() extends \PhpCsFixer\Config {
4+
public function __construct()
5+
{
6+
parent::__construct('Bedrock(PHP 7.1)');
7+
}
8+
9+
public function getRules()
10+
{
11+
return (new \M6Web\CS\Config\Php71())->getRules() + ['increment_style' => false];
12+
}
13+
};
14+
15+
$config->getFinder()
16+
->in([
17+
__DIR__.'/src'
18+
])->exclude([
19+
'Tests'
20+
]);
21+
22+
return $config;

.php_cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
"symfony/security-core": "^4.4|^5.0"
1717
},
1818
"require-dev": {
19-
"atoum/atoum-bundle": "~1.0",
19+
"atoum/atoum": "^3.4|^4.0",
20+
"friendsofphp/php-cs-fixer": "^2.19",
2021
"m6web/symfony2-coding-standard": "~1.2",
21-
"m6web/php-cs-fixer-config": "^1.0"
22+
"m6web/php-cs-fixer-config": "^1.0",
23+
"symfony/http-foundation": "^4.4|^5.0"
2224
},
2325
"extra": {
2426
"branch-alias": {

src/M6Web/Bundle/LogBridgeBundle/EventDispatcher/BuilderEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace M6Web\Bundle\LogBridgeBundle\EventDispatcher;
44

55
use M6Web\Bundle\LogBridgeBundle\Matcher\BuilderInterface;
6-
use Symfony\Component\EventDispatcher\Event;
6+
use Symfony\Contracts\EventDispatcher\Event;
77

88
/**
99
* BuilderEvent

src/M6Web/Bundle/LogBridgeBundle/EventDispatcher/LogExceptionListener.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace M6Web\Bundle\LogBridgeBundle\EventDispatcher;
44

5-
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
5+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
66

77
/**
88
* LogExceptionListener overload here to send the entire exception to log bridge.
@@ -23,13 +23,9 @@ public function __construct($requestExceptionAttribute)
2323
/**
2424
* React to an exception to give error message to log bridge
2525
*/
26-
public function onKernelException(GetResponseForExceptionEvent $event)
26+
public function onKernelException(ExceptionEvent $event)
2727
{
28-
if (method_exists($event, 'getThrowable')) {
29-
$exception = $event->getThrowable();
30-
} else {
31-
$exception = $event->getException();
32-
}
28+
$exception = $event->getThrowable();
3329

3430
$request = $event->getRequest();
3531
$request->setRequestFormat('json');
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace M6Web\Bundle\LogBridgeBundle\Tests\Units\EventDispatcher;
6+
7+
use atoum;
8+
use M6Web\Bundle\LogBridgeBundle\EventDispatcher\BuilderEvent as TestedClass;
9+
10+
class BuilderEvent extends atoum
11+
{
12+
public function testBuildEventIsInstanciable()
13+
{
14+
$this
15+
->given($this->mockGenerator->orphanize('__construct'))
16+
->if($this->newTestedInstance(
17+
new \mock\M6Web\Bundle\LogBridgeBundle\Matcher\BuilderInterface,
18+
[]
19+
))
20+
->then
21+
->object($this->testedInstance)
22+
->isInstanceOf(TestedClass::class)
23+
;
24+
}
25+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace M6Web\Bundle\LogBridgeBundle\Tests\Units\EventDispatcher;
6+
7+
use Symfony\Component\HttpFoundation\Request;
8+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
9+
use Symfony\Component\HttpKernel\HttpKernelInterface;
10+
11+
class LogExceptionListener
12+
{
13+
public function testOnKernelExceptionCall()
14+
{
15+
$this
16+
->given(
17+
$request = Request::create('/path'),
18+
$exception = new \Exception()
19+
)
20+
->if($this->newTestedInstance('foo-attribute'))
21+
->when($this->testedInstance->onKernelException(new ExceptionEvent(
22+
new \mock\Symfony\Component\HttpKernel\HttpKernelInterface,
23+
$request,
24+
HttpKernelInterface::MAIN_REQUEST,
25+
$exception
26+
)))
27+
->then
28+
->array($request->attributes->all())
29+
->hasKey('foo-attribute')
30+
->object($request->attributes->get('foo-attribute'))
31+
->isIdenticalTo($exception)
32+
;
33+
}
34+
}

src/M6Web/Bundle/LogBridgeBundle/Tests/Units/Matcher/Status/Type/AbstractType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace M6Web\Bundle\LogBridgeBundle\Tests\Units\Matcher\Status\Type;
44

5-
use atoum\AtoumBundle\Test\Units;
5+
use atoum;
66
use M6Web\Bundle\LogBridgeBundle\Tests\Fixtures\Matcher\Status\Type\Sample1Type as TestedClass;
77

8-
class AbstractType extends Units\Test
8+
class AbstractType extends atoum
99
{
1010
public function getSample1TypeMock()
1111
{
@@ -74,4 +74,4 @@ public function testIsExclude()
7474
->isTrue()
7575
;
7676
}
77-
}
77+
}

0 commit comments

Comments
 (0)