Skip to content
Permalink
Browse files

use constant PHP_SAPI

  • Loading branch information...
dereuromark committed Jul 26, 2015
1 parent de4b44a commit a239324a0d6370de86c998bcc1594d4c83474e0c
@@ -44,7 +44,7 @@ class XcacheEngine extends CacheEngine {
* @return bool True if the engine has been successfully initialized, false if not
*/
public function init($settings = array()) {
if (php_sapi_name() !== 'cli') {
if (PHP_SAPI !== 'cli') {
parent::init(array_merge(array(
'engine' => 'Xcache',
'prefix' => Inflector::slug(APP_DIR) . '_',
@@ -77,7 +77,7 @@
}
// for built-in server
if (php_sapi_name() === 'cli-server') {
if (PHP_SAPI === 'cli-server') {
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
return false;
}
@@ -156,7 +156,7 @@ protected static function _getMessage($exception) {
$message .= "\nException Attributes: " . var_export($exception->getAttributes(), true);
}
}
if (php_sapi_name() !== 'cli') {
if (PHP_SAPI !== 'cli') {
$request = Router::getRequest();
if ($request) {
$message .= "\nRequest URL: " . $request->here();
@@ -952,7 +952,7 @@ public function testDebug() {
###########################
EXPECTED;
if (php_sapi_name() === 'cli') {
if (PHP_SAPI === 'cli') {
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18);
} else {
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 20);
@@ -977,7 +977,7 @@ public function testDebug() {
###########################
EXPECTED;
if (php_sapi_name() === 'cli') {
if (PHP_SAPI === 'cli') {
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 18);
} else {
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19);
@@ -1043,7 +1043,7 @@ public function testDebug() {
* @return void
*/
public function testPr() {
$this->skipIf(php_sapi_name() === 'cli', 'Skipping web test in cli mode');
$this->skipIf(PHP_SAPI === 'cli', 'Skipping web test in cli mode');
ob_start();
pr('this is a test');
$result = ob_get_clean();
@@ -1063,7 +1063,7 @@ public function testPr() {
* @return void
*/
public function testPrCli() {
$this->skipIf(php_sapi_name() != 'cli', 'Skipping cli test in web mode');
$this->skipIf(PHP_SAPI !== 'cli', 'Skipping cli test in web mode');
ob_start();
pr('this is a test');
$result = ob_get_clean();
@@ -34,7 +34,7 @@ public function setUp() {
parent::setUp();
$this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.');
if (php_sapi_name() === 'cli') {
if (PHP_SAPI === 'cli') {
$this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.');
}
@@ -373,7 +373,7 @@ public function testCache() {
* @return void
*/
public function testCompress() {
if (php_sapi_name() !== 'cli') {
if (PHP_SAPI !== 'cli') {
$this->markTestSkipped('The response compression can only be tested in cli.');
}
@@ -491,7 +491,7 @@ public function testOutputCompressed() {
if (!extension_loaded("zlib")) {
$this->markTestSkipped('Skipping further tests for outputCompressed as zlib extension is not loaded');
}
if (php_sapi_name() !== 'cli') {
if (PHP_SAPI !== 'cli') {
$this->markTestSkipped('Testing outputCompressed method with compression enabled done only in cli');
}
@@ -516,8 +516,8 @@ public function testDump() {
Debugger::dump($var);
$result = ob_get_clean();
$open = php_sapi_name() === 'cli' ? "\n" : '<pre>';
$close = php_sapi_name() === 'cli' ? "\n" : '</pre>';
$open = PHP_SAPI === 'cli' ? "\n" : '<pre>';
$close = PHP_SAPI === 'cli' ? "\n" : '</pre>';
$expected = <<<TEXT
{$open}array(
'People' => array(
@@ -540,8 +540,8 @@ public function testDump() {
Debugger::dump($var, 1);
$result = ob_get_clean();
$open = php_sapi_name() === 'cli' ? "\n" : '<pre>';
$close = php_sapi_name() === 'cli' ? "\n" : '</pre>';
$open = PHP_SAPI === 'cli' ? "\n" : '<pre>';
$close = PHP_SAPI === 'cli' ? "\n" : '</pre>';
$expected = <<<TEXT
{$open}array(
'People' => array(
@@ -100,7 +100,7 @@ function debug($var, $showHtml = null, $showFrom = true) {
TEXT;
$template = $html;
if (php_sapi_name() === 'cli' || $showHtml === false) {
if (PHP_SAPI === 'cli' || $showHtml === false) {
$template = $text;
if ($showFrom) {
$lineInfo = sprintf('%s (line %s)', $file, $line);
@@ -275,7 +275,7 @@ function pluginSplit($name, $dotAppend = false, $plugin = null) {
*/
function pr($var) {
if (Configure::read('debug') > 0) {
$template = php_sapi_name() !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
$template = PHP_SAPI !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
printf($template, print_r($var, true));
}
}

0 comments on commit a239324

Please sign in to comment.
You can’t perform that action at this time.