Skip to content

Commit

Permalink
Consider a SAPI of phpdbg to be the same as cli.
Browse files Browse the repository at this point in the history
This allows for doing things like code coverage enabled phpunit tests using phpdbg instead of xdebug.
  • Loading branch information
dakota committed Dec 3, 2015
1 parent 24718ff commit 5a04498
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Cache/Engine/XcacheEngine.php
Expand Up @@ -58,7 +58,7 @@ class XcacheEngine extends CacheEngine
*/
public function init(array $config = [])
{
if (PHP_SAPI === 'cli' || !extension_loaded('xcache')) {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') || !extension_loaded('xcache')) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Error/BaseErrorHandler.php
Expand Up @@ -69,7 +69,7 @@ public function register()
set_error_handler([$this, 'handleError'], $level);
set_exception_handler([$this, 'wrapAndHandleException']);
register_shutdown_function(function () {
if (PHP_SAPI === 'cli') {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
return;
}
$error = error_get_last();
Expand Down
2 changes: 1 addition & 1 deletion src/Network/Session.php
Expand Up @@ -219,7 +219,7 @@ public function __construct(array $config = [])
}

$this->_lifetime = ini_get('session.gc_maxlifetime');
$this->_isCLI = PHP_SAPI === 'cli';
$this->_isCLI = (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg');
session_register_shutdown();
}

Expand Down
4 changes: 2 additions & 2 deletions src/basics.php
Expand Up @@ -73,7 +73,7 @@ function debug($var, $showHtml = null, $showFrom = true)
TEXT;
$template = $html;
if (PHP_SAPI === 'cli' || $showHtml === false) {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') || $showHtml === false) {
$template = $text;
if ($showFrom) {
$lineInfo = sprintf('%s (line %s)', $file, $line);
Expand Down Expand Up @@ -157,7 +157,7 @@ function json_last_error_msg()
*/
function breakpoint()
{
if (PHP_SAPI === 'cli' && class_exists('\Psy\Shell')) {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && class_exists('\Psy\Shell')) {
return 'extract(\Psy\Shell::debug(get_defined_vars(), isset($this) ? $this : null));';
}
trigger_error(
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/BasicsTest.php
Expand Up @@ -301,7 +301,7 @@ public function testDebug()
###########################
EXPECTED;
if (PHP_SAPI === 'cli') {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
$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);
Expand All @@ -326,7 +326,7 @@ public function testDebug()
###########################
EXPECTED;
if (PHP_SAPI === 'cli') {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
$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);
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Cache/Engine/ApcEngineTest.php
Expand Up @@ -36,7 +36,7 @@ public function setUp()
parent::setUp();
$this->skipIf(!function_exists('apc_store'), 'Apc is not installed or configured properly.');

if (PHP_SAPI === 'cli') {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
$this->skipIf(!ini_get('apc.enable_cli'), 'APC is not enabled for the CLI.');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Cache/Engine/XcacheEngineTest.php
Expand Up @@ -35,7 +35,7 @@ class XcacheEngineTest extends TestCase
public function setUp()
{
parent::setUp();
if (PHP_SAPI === 'cli') {
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg')) {
$this->markTestSkipped('Xcache is not available for the CLI.');
}
if (!function_exists('xcache_set')) {
Expand Down

0 comments on commit 5a04498

Please sign in to comment.