From af3a62363793a171a5fdf1ecb2cc6750c50a2ddf Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 1 Jun 2018 10:08:56 +0200 Subject: [PATCH] Fix CI after bad cherrypick in 6d57173 --- .../EventListener/ExceptionListener.php | 1 + .../SentryExtensionTest.php | 5 +++-- test/EventListener/ExceptionListenerTest.php | 19 +++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Sentry/SentryBundle/EventListener/ExceptionListener.php b/src/Sentry/SentryBundle/EventListener/ExceptionListener.php index 138965ac..882e98f1 100644 --- a/src/Sentry/SentryBundle/EventListener/ExceptionListener.php +++ b/src/Sentry/SentryBundle/EventListener/ExceptionListener.php @@ -67,6 +67,7 @@ public function __construct( $this->authorizationChecker = $authorizationChecker; $this->eventDispatcher = $dispatcher; $this->client = $client; + $this->requestStack = $requestStack; $this->skipCapture = $skipCapture; } diff --git a/test/DependencyInjection/SentryExtensionTest.php b/test/DependencyInjection/SentryExtensionTest.php index 3262f890..66086e2a 100644 --- a/test/DependencyInjection/SentryExtensionTest.php +++ b/test/DependencyInjection/SentryExtensionTest.php @@ -640,8 +640,9 @@ private function getContainer(array $options = array()) $mockEventDispatcher = $this ->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $mockRequestStack = $this - ->createMock('Symfony\Component\HttpFoundation\RequestStack'); + $mockRequestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack') + ->disableOriginalConstructor() + ->getMock(); $containerBuilder->set('request_stack', $mockRequestStack); $containerBuilder->set('event_dispatcher', $mockEventDispatcher); diff --git a/test/EventListener/ExceptionListenerTest.php b/test/EventListener/ExceptionListenerTest.php index acccba10..77df4654 100644 --- a/test/EventListener/ExceptionListenerTest.php +++ b/test/EventListener/ExceptionListenerTest.php @@ -6,7 +6,7 @@ use Sentry\SentryBundle\SentrySymfonyEvents; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter; @@ -35,6 +35,7 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ private $mockEventDispatcher; + /** @var RequestStack|\PHPUnit_Framework_MockObject_MockObject */ private $mockRequestStack; public function setUp() @@ -59,7 +60,7 @@ public function setUp() ->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface') ; - $this->$mockRequestStack = $this + $this->mockRequestStack = $this ->getMock('Symfony\Component\HttpFoundation\RequestStack') ; @@ -496,7 +497,9 @@ public function test_that_username_is_set_from_user_interface_if_token_present_a public function test_that_ip_is_set_from_request_stack() { - $mockToken = $this->createMock(TokenInterface::class); + $mockToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface') + ->disableOriginalConstructor() + ->getMock(); $mockToken ->method('getUser') @@ -506,9 +509,13 @@ public function test_that_ip_is_set_from_request_stack() ->method('isAuthenticated') ->willReturn(true); - $mockEvent = $this->createMock(GetResponseEvent::class); + $mockEvent = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent') + ->disableOriginalConstructor() + ->getMock(); - $mockRequest = $this->createMock(Request::class); + $mockRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request') + ->disableOriginalConstructor() + ->getMock(); $mockRequest ->method('getClientIp') @@ -535,7 +542,7 @@ public function test_that_ip_is_set_from_request_stack() $this->mockSentryClient ->expects($this->once()) ->method('set_user_data') - ->with($this->identicalTo('some_user'), null, ['ip_address' => '1.2.3.4']); + ->with($this->identicalTo('some_user'), null, array('ip_address' => '1.2.3.4')); $this->containerBuilder->compile(); $listener = $this->containerBuilder->get('sentry.exception_listener');