Skip to content
Browse files

Fixed header output in tests

Signed-off-by: Darren Hill <dchill42@gmail.com>
  • Loading branch information...
1 parent 4f7b682 commit 1033c568e63a88443b61545153b8e82b20a51a32 @dchill42 dchill42 committed Feb 4, 2014
Showing with 33 additions and 2 deletions.
  1. +18 −2 system/core/Xylophone.php
  2. +15 −0 tests/Mocks/core/Xylophone.php
View
20 system/core/Xylophone.php
@@ -155,7 +155,7 @@ public static function instance($init = null)
// Check namespaces after application
if (!$app && !$ns) {
// Fail out
- header('HTTP/1.1 503 Service Unavailable.', true, 503);
+ static::header('HTTP/1.1 503 Service Unavailable.', true, 503);
$msg = 'The global namespace is reserved for application classes. '.
'Please specify a namespace for your additional path in the following file: '.
basename($_SERVER['PHP_SELF']);
@@ -176,7 +176,7 @@ public static function instance($init = null)
}
if (!$resolved) {
// Fail out
- header('HTTP/1.1 503 Service Unavailable.', true, 503);
+ static::header('HTTP/1.1 503 Service Unavailable.', true, 503);
$msg = ($app ? 'Your application folder path does not appear to be set correctly.' :
'The "'.$ns.'" namespace path does not appear to be set correctly.').
' Please fix it in the following file: '.basename($_SERVER['PHP_SELF']);
@@ -912,5 +912,21 @@ protected function realpath($path)
// Normally, we just call realpath()
return realpath($path);
}
+
+ /**
+ * Send a raw HTTP header
+ *
+ * This abstraction of the header call allows overriding for unit testing
+ *
+ * @param string $string Header string
+ * @param bool $replace Whether to replace matching header
+ * @param int $code HTTP response code
+ * @return void
+ */
+ protected static function header($string, $replace, $code)
+ {
+ // Normally, we just call header()
+ header($string, $replace, $code);
+ }
}
View
15 tests/Mocks/core/Xylophone.php
@@ -86,5 +86,20 @@ protected function realpath($path)
// Just trim trailing slash since realpath() fails on VFS urls
return rtrim($path, '\/');
}
+
+ /**
+ * Send a raw HTTP header
+ *
+ * This abstraction of the header call allows overriding for unit testing
+ *
+ * @param string $string Header string
+ * @param bool $replace Whether to replace matching header
+ * @param int $code HTTP response code
+ * @return void
+ */
+ protected static function header($string, $replace, $code)
+ {
+ // Nothing to do here since headers cause errors in test
+ }
}

0 comments on commit 1033c56

Please sign in to comment.
Something went wrong with that request. Please try again.