diff --git a/tests/Middleware/Stratigility/MiddlewareTest.php b/tests/Middleware/Stratigility/MiddlewareTest.php new file mode 100644 index 00000000..baf428bc --- /dev/null +++ b/tests/Middleware/Stratigility/MiddlewareTest.php @@ -0,0 +1,47 @@ + + */ +class MiddlewareTest extends PHPUnit_Framework_TestCase +{ + /** + * Tests __invoke() method + * + * @return void + */ + public function testInvokeMethod() + { + if (! class_exists('Zend\Stratigility\MiddlewarePipe')) { + $this->markTestSkipped('Zend Stratigility is not installed.'); + } + + $queue = [ + 'Rougin\Slytherin\Test\Fixture\Middlewares\FirstMiddleware', + 'Rougin\Slytherin\Test\Fixture\Middlewares\SecondMiddleware', + 'Rougin\Slytherin\Test\Fixture\Middlewares\LastMiddleware', + ]; + + $middleware = new Middleware(new MiddlewarePipe); + $request = new ServerRequest('1.1', [], null, '/', 'GET', new Uri); + $response = new Response; + + $response = $middleware($request, $response, $queue); + + $this->assertEquals('First! Second! Last!', $response->getBody()); + } +}