use constant PHP_SAPI

This commit is contained in:
Mark Scherer 2015-07-26 15:35:03 +02:00
parent de4b44a37b
commit a239324a0d
8 changed files with 16 additions and 16 deletions

View file

@ -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) . '_',

View file

@ -77,7 +77,7 @@ if (!defined('WWW_ROOT')) {
}
// 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;
}

View file

@ -156,7 +156,7 @@ class ErrorHandler {
$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();

View file

@ -952,7 +952,7 @@ EXPECTED;
###########################
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 @@ EXPECTED;
###########################
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 @@ EXPECTED;
* @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 @@ EXPECTED;
* @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();

View file

@ -34,7 +34,7 @@ class ApcEngineTest extends CakeTestCase {
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.');
}

View file

@ -373,7 +373,7 @@ class CakeResponseTest extends CakeTestCase {
* @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 @@ class CakeResponseTest extends CakeTestCase {
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');
}

View file

@ -516,8 +516,8 @@ TEXT;
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 @@ TEXT;
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(

View file

@ -100,7 +100,7 @@ HTML;
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 @@ if (!function_exists('pr')) {
*/
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));
}
}