Skip to content

Commit

Permalink
Add test for Zend Stratigility
Browse files Browse the repository at this point in the history
  • Loading branch information
rougin committed Aug 30, 2016
1 parent 023615e commit 7c3ce4b
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/Middleware/Stratigility/MiddlewareTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Rougin\Slytherin\Test\Middleware\Auryn;

use Zend\Stratigility\MiddlewarePipe;

use Rougin\Slytherin\Middleware\Stratigility\Middleware;

use PHPUnit_Framework_TestCase;
use Rougin\Slytherin\Test\Fixture\Http\Uri;
use Rougin\Slytherin\Test\Fixture\Http\Response;
use Rougin\Slytherin\Test\Fixture\Http\ServerRequest;

/**
* Stratigility Middleware Test
*
* @package Slytherin
* @author Rougin Royce Gutib <[email protected]>
*/
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());
}
}

0 comments on commit 7c3ce4b

Please sign in to comment.