Skip to content
Permalink
Browse files

Consider a SAPI of phpdbg to be the same as cli.

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 5a0449822a818cf1faf4c1864cbadb6ecbd7dba8
@@ -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;
}
@@ -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();
@@ -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();
}
@@ -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);
@@ -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(
@@ -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);
@@ -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);
@@ -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.');
}
@@ -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')) {

0 comments on commit 5a04498

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