-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |