diff --git a/tests/AppTest.php b/tests/AppTest.php index 70032658d..79d453037 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -26,7 +26,7 @@ use Slim\Http\Response; use Slim\Http\Uri; use Slim\Router; -use Slim\HeaderStackTestAsset; +use Slim\Tests\Assets\HeaderStack; use Slim\Tests\Mocks\MockAction; /** @@ -43,12 +43,12 @@ class AppTest extends \PHPUnit_Framework_TestCase { public function setUp() { - HeaderStackTestAsset::reset(); + HeaderStack::reset(); } public function tearDown() { - HeaderStackTestAsset::reset(); + HeaderStack::reset(); } public static function setupBeforeClass() @@ -1797,7 +1797,7 @@ public function testResponseReplacesPreviouslySetHeaders() ['header' => 'HTTP/1.1 200 OK', 'replace' => true, 'status_code' => 200], ]; - $this->assertSame($expectedStack, HeaderStackTestAsset::stack()); + $this->assertSame($expectedStack, HeaderStack::stack()); } public function testResponseDoesNotReplacePreviouslySetSetCookieHeaders() @@ -1834,7 +1834,7 @@ public function testResponseDoesNotReplacePreviouslySetSetCookieHeaders() ['header' => 'HTTP/1.1 200 OK', 'replace' => true, 'status_code' => 200], ]; - $this->assertSame($expectedStack, HeaderStackTestAsset::stack()); + $this->assertSame($expectedStack, HeaderStack::stack()); } public function testExceptionErrorHandlerDoesNotDisplayErrorDetails() diff --git a/tests/Assets/HeaderFunctions.php b/tests/Assets/HeaderFunctions.php index 99e9218bd..e7327d042 100644 --- a/tests/Assets/HeaderFunctions.php +++ b/tests/Assets/HeaderFunctions.php @@ -8,6 +8,8 @@ */ namespace Slim; +use Slim\Tests\Assets\HeaderStack; + /** * Zend Framework (http://framework.zend.com/) * @@ -28,63 +30,6 @@ * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License */ -/** - * Store output artifacts - */ -class HeaderStackTestAsset -{ - /** - * @var string[][] - */ - private static $data = []; - - /** - * Reset state - */ - public static function reset() - { - self::$data = []; - } - - /** - * Push a header on the stack - * - * @param string[] $header - */ - public static function push(array $header) - { - self::$data[] = $header; - } - - /** - * Return the current header stack - * - * @return string[][] - */ - public static function stack() - { - return self::$data; - } - - /** - * Verify if there's a header line on the stack - * - * @param string $header - * - * @return bool - */ - public static function has($header) - { - foreach (self::$data as $item) { - if ($item['header'] === $header) { - return true; - } - } - - return false; - } -} - /** * Have headers been sent? * @@ -104,7 +49,7 @@ function headers_sent() */ function header($string, $replace = true, $statusCode = null) { - HeaderStackTestAsset::push( + HeaderStack::push( [ 'header' => $string, 'replace' => $replace, diff --git a/tests/Assets/HeaderStack.php b/tests/Assets/HeaderStack.php new file mode 100644 index 000000000..188e278a8 --- /dev/null +++ b/tests/Assets/HeaderStack.php @@ -0,0 +1,84 @@ +