Skip to content
Permalink
Browse files

tests: Refactored BodySubscriberTest to use `RequestEvent` instead of…

… `GetResponseEvent`.
  • Loading branch information...
tarlepp committed Aug 7, 2019
1 parent 24a8d7e commit a1e6fc1ac3a2b5e0aefd3f68f1c64005ea662f2d
Showing with 10 additions and 10 deletions.
  1. +10 −10 tests/Integration/EventSubscriber/BodySubscriberTest.php
@@ -15,7 +15,7 @@
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
@@ -32,7 +32,7 @@ public function testThatEmptyBodyWorksLikeExpected(): void
$request = new Request();
$event = new GetResponseEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$event = new RequestEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$subscriber = new BodySubscriber();
$subscriber->onKernelRequest($event);
@@ -58,7 +58,7 @@ public function testThatNonJsonContentTypeWorksLikeExpected(): void
$request = new Request($inputQuery, $inputRequest, [], [], [], [], 'Some content');
$request->headers->set('Content-Type', 'text/xml');
$event = new GetResponseEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$event = new RequestEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$subscriber = new BodySubscriber();
$subscriber->onKernelRequest($event);
@@ -84,7 +84,7 @@ public function testThatJsonContentReplaceParametersAsExpected(
$request = new Request([], ['foobar' => 'foobar'], [], [], [], [], $content);
$request->headers->set('Content-Type', $contentType);
$event = new GetResponseEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$event = new RequestEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$subscriber = new BodySubscriber();
$subscriber->onKernelRequest($event);
@@ -100,7 +100,7 @@ public function testThatInvalidJsonContentThrowsAnException(): void
$request = new Request([], [], [], [], [], [], '{"Some": "not", "valid" JSON}');
$event = new GetResponseEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$event = new RequestEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$subscriber = new BodySubscriber();
$subscriber->onKernelRequest($event);
@@ -112,23 +112,23 @@ public function testThatWithNullBodyReplaceIsNotCalled(): void
/**
* @var MockObject|Request $request
* @var MockObject|ParameterBag $paramegerBag
* @var MockObject|ParameterBag $parameterBag
*/
$request = $this->getMockBuilder(Request::class)->getMock();
$paramegerBag = $this->getMockBuilder(ParameterBag::class)->getMock();
$parameterBag = $this->getMockBuilder(ParameterBag::class)->getMock();
$request->request = $paramegerBag;
$request->request = $parameterBag;
$request
->expects(static::exactly(2))
->method('getContent')
->willReturn(null);
$paramegerBag
$parameterBag
->expects(static::never())
->method('replace');
$event = new GetResponseEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$event = new RequestEvent(static::$kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$subscriber = new BodySubscriber();
$subscriber->onKernelRequest($event);

0 comments on commit a1e6fc1

Please sign in to comment.
You can’t perform that action at this time.