1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of Ekino New Relic bundle. |
7
|
|
|
* |
8
|
|
|
* (c) Ekino - Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Ekino\NewRelicBundle\Tests\Listener; |
15
|
|
|
|
16
|
|
|
use Ekino\NewRelicBundle\Listener\ExceptionListener; |
17
|
|
|
use Ekino\NewRelicBundle\NewRelic\NewRelicInteractorInterface; |
18
|
|
|
use PHPUnit\Framework\TestCase; |
|
|
|
|
19
|
|
|
use Symfony\Component\HttpFoundation\Request; |
20
|
|
|
use Symfony\Component\HttpKernel\Event\ExceptionEvent; |
21
|
|
|
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; |
|
|
|
|
22
|
|
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
23
|
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface; |
24
|
|
|
|
25
|
|
|
class ExceptionListenerTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
public function testOnKernelException() |
28
|
|
|
{ |
29
|
|
|
$exception = new \Exception('Boom'); |
30
|
|
|
|
31
|
|
|
$interactor = $this->getMockBuilder(NewRelicInteractorInterface::class)->getMock(); |
32
|
|
|
$interactor->expects($this->once())->method('noticeThrowable')->with($exception); |
33
|
|
|
|
34
|
|
|
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); |
35
|
|
|
$request = new Request(); |
36
|
|
|
|
37
|
|
|
$eventClass = \class_exists(ExceptionEvent::class) ? ExceptionEvent::class : GetResponseForExceptionEvent::class; |
38
|
|
|
$event = new $eventClass($kernel, $request, HttpKernelInterface::SUB_REQUEST, $exception); |
39
|
|
|
|
40
|
|
|
$listener = new ExceptionListener($interactor); |
41
|
|
|
$listener->onKernelException($event); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testOnKernelExceptionWithHttp() |
45
|
|
|
{ |
46
|
|
|
$exception = new BadRequestHttpException('Boom'); |
47
|
|
|
|
48
|
|
|
$interactor = $this->getMockBuilder(NewRelicInteractorInterface::class)->getMock(); |
49
|
|
|
$interactor->expects($this->never())->method('noticeThrowable'); |
50
|
|
|
|
51
|
|
|
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock(); |
52
|
|
|
$request = new Request(); |
53
|
|
|
|
54
|
|
|
$eventClass = \class_exists(ExceptionEvent::class) ? ExceptionEvent::class : GetResponseForExceptionEvent::class; |
55
|
|
|
$event = new $eventClass($kernel, $request, HttpKernelInterface::SUB_REQUEST, $exception); |
56
|
|
|
|
57
|
|
|
$listener = new ExceptionListener($interactor); |
58
|
|
|
$listener->onKernelException($event); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths