Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Added test to ensure that callable middleware is not decorated if no …
Browse files Browse the repository at this point in the history
…response prototype is present

I suspected at one point that callable middleware was being decorated
as interop middleware, which would cause problems with manipulated
responses. It was not, but this test proves it.
  • Loading branch information
weierophinney committed Nov 11, 2016
1 parent f3c90f6 commit 3360255
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/MiddlewarePipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,27 @@ public function testWillDecorateCallableMiddlewareAsInteropMiddlewareIfResponseP
$this->assertAttributeSame($this->response, 'responsePrototype', $test);
}

/**
* @group http-interop
*/
public function testWillNotDecorateCallableMiddlewareAsInteropMiddlewareIfResponsePrototypeIsNotPresent()
{
$pipeline = new MiddlewarePipe();

$middleware = function () {
};
$pipeline->pipe($middleware);

$r = new ReflectionProperty($pipeline, 'pipeline');
$r->setAccessible(true);
$queue = $r->getValue($pipeline);

$route = $queue->dequeue();
$test = $route->handler;
$this->assertNotInstanceOf(CallableMiddlewareWrapper::class, $test);
$this->assertInternalType('callable', $test);
}

/**
* @todo Remove with 2.0.0
*/
Expand Down

0 comments on commit 3360255

Please sign in to comment.