Skip to content

Commit

Permalink
Add tests for unknown type scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 26, 2018
1 parent fb507ee commit 125389e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/TestCase/Http/Middleware/BodyParserMiddlewareTest.php
Expand Up @@ -139,6 +139,31 @@ public function testAddParserOverwrite()

$this->assertAttributeEquals(['application/json' => 'strpos'], 'parsers', $parser);
}

/**
* test skipping parsing on unknown type
*
* @dataProvider httpMethodProvider
* @return void
*/
public function testInvokeMismatchedType($method)
{
$parser = new BodyParserMiddleware();

$request = new ServerRequest([
'environment' => [
'REQUEST_METHOD' => $method,
'CONTENT_TYPE' => 'text/csv',
],
'input' => 'a,b,c'
]);
$response = new Response();
$next = function ($req, $res) {
$this->assertEquals([], $req->getParsedBody());
};
$parser($request, $response, $next);
}

/**
* test parsing on valid http method
*
Expand Down

0 comments on commit 125389e

Please sign in to comment.