Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gorghoa committed Apr 3, 2018
1 parent bd7f829 commit 2d89ecf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/EventListener/DeserializeListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ public function testDoNotCallWhenRequestMethodIsSafe()
$listener->onKernelRequest($eventProphecy->reveal());
}

public function testDoNotCallWhenPutAndEmptyRequestContent()
/**
* @dataProvider allowedEmptyRequestMethodsProvider
*/
public function testDoNotCallWhenSendingAndEmptyRequestContent($method)
{
$eventProphecy = $this->prophesize(GetResponseEvent::class);

$request = new Request([], [], ['data' => new \stdClass(), '_api_resource_class' => 'Foo', '_api_item_operation_name' => 'put'], [], [], [], '');
$request->setMethod('PUT');
$request->setMethod($method);
$request->headers->set('Content-Type', 'application/json');
$eventProphecy->getRequest()->willReturn($request)->shouldBeCalled();

Expand All @@ -66,6 +69,11 @@ public function testDoNotCallWhenPutAndEmptyRequestContent()
$listener->onKernelRequest($eventProphecy->reveal());
}

public function allowedEmptyRequestMethodsProvider()
{
return [['PUT'], ['POST']];
}

public function testDoNotCallWhenRequestNotManaged()
{
$eventProphecy = $this->prophesize(GetResponseEvent::class);
Expand Down

0 comments on commit 2d89ecf

Please sign in to comment.