Skip to content

Commit

Permalink
Make debug status boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Mar 17, 2014
1 parent 2ab9feb commit 3d1a78f
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/Console/Command/BakeShell.php
Expand Up @@ -60,7 +60,7 @@ class BakeShell extends Shell {
*/
public function startup() {
parent::startup();
Configure::write('debug', 2);
Configure::write('debug', true);
Cache::disable();

$task = Inflector::classify($this->command);
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/Task/BakeTask.php
Expand Up @@ -54,7 +54,7 @@ class BakeTask extends Shell {
* @return void
*/
public function startup() {
Configure::write('debug', 2);
Configure::write('debug', true);
Cache::disable();
parent::startup();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Component/AuthComponent.php
Expand Up @@ -273,7 +273,7 @@ public function initialize(Event $event) {
$this->response = $controller->response;
$this->_methods = $controller->methods;

if (Configure::read('debug') > 0) {
if (Configure::read('debug')) {
Debugger::checkSecurityKeys();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Element/sql_dump.ctp
Expand Up @@ -15,7 +15,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

if (!class_exists('ConnectionManager') || Configure::read('debug') < 2) {
if (!class_exists('ConnectionManager')) {
return false;
}
$noLogs = !isset($sqlLogs);
Expand Down
2 changes: 1 addition & 1 deletion src/View/Helper.php
Expand Up @@ -304,7 +304,7 @@ protected function _encodeUrl($url) {
*/
public function assetTimestamp($path) {
$stamp = Configure::read('Asset.timestamp');
$timestampEnabled = $stamp === 'force' || ($stamp === true && Configure::read('debug') > 0);
$timestampEnabled = $stamp === 'force' || ($stamp === true && Configure::read('debug'));
if ($timestampEnabled && strpos($path, '?') === false) {
$filepath = preg_replace(
'/^' . preg_quote($this->request->webroot, '/') . '/',
Expand Down
2 changes: 1 addition & 1 deletion src/View/View.php
Expand Up @@ -549,7 +549,7 @@ public function renderCache($filename, $timeStart) {
include $filename;

$type = $response->mapType($response->type());
if (Configure::read('debug') > 0 && $type === 'html') {
if (Configure::read('debug') && $type === 'html') {
echo "<!-- Cached Render Time: " . round(microtime(true) - $timeStart, 4) . "s -->";
}
$out = ob_get_clean();
Expand Down
4 changes: 2 additions & 2 deletions src/basics.php
Expand Up @@ -75,7 +75,7 @@ function config() {
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#debug
*/
function debug($var, $showHtml = null, $showFrom = true) {
if (Configure::read('debug') > 0) {
if (Configure::read('debug')) {
$file = '';
$line = '';
$lineInfo = '';
Expand Down Expand Up @@ -264,7 +264,7 @@ function namespaceSplit($class) {
* @link http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#pr
*/
function pr($var) {
if (Configure::read('debug') > 0) {
if (Configure::read('debug')) {
$template = php_sapi_name() !== 'cli' ? '<pre>%s</pre>' : "\n%s\n";
printf($template, print_r($var, true));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Cache/Engine/FileEngineTest.php
Expand Up @@ -401,7 +401,7 @@ public function testWriteQuotedString() {
*/
public function testPathDoesNotExist() {
$this->skipIf(is_dir(TMP . 'tests' . DS . 'autocreate'), 'Cannot run if test directory exists.');
Configure::write('debug', 2);
Configure::write('debug', true);

Cache::drop('file_test');
Cache::config('file_test', array(
Expand All @@ -424,7 +424,7 @@ public function testPathDoesNotExist() {
*/
public function testPathDoesNotExistDebugOff() {
$this->skipIf(is_dir(TMP . 'tests/autocreate'), 'Cannot run if test directory exists.');
Configure::write('debug', 0);
Configure::write('debug', false);

Cache::drop('file_groups');
Cache::config('file_groups', array(
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -380,7 +380,7 @@ public function testBeforeRenderCallbackChangingViewClass() {
'_serialize' => ['test']
]);
$debug = Configure::read('debug');
Configure::write('debug', 0);
Configure::write('debug', false);
$result = $Controller->render('index');
$this->assertEquals('{"test":"value"}', $result->body());
Configure::write('debug', $debug);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/PagesControllerTest.php
Expand Up @@ -57,7 +57,7 @@ public function testDisplay() {
* @return void
*/
public function testMissingView() {
Configure::write('debug', 0);
Configure::write('debug', false);
$Pages = new PagesController(new Request(), new Response());
$Pages->display('non_existing_page');
}
Expand All @@ -70,7 +70,7 @@ public function testMissingView() {
* @return void
*/
public function testMissingViewInDebug() {
Configure::write('debug', 1);
Configure::write('debug', true);
$Pages = new PagesController(new Request(), new Response());
$Pages->display('non_existing_page');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Core/ConfigureTest.php
Expand Up @@ -140,11 +140,11 @@ public function testWrite() {
* @return void
*/
public function testDebugSettingDisplayErrors() {
Configure::write('debug', 0);
Configure::write('debug', false);
$result = ini_get('display_errors');
$this->assertEquals(0, $result);

Configure::write('debug', 2);
Configure::write('debug', true);
$result = ini_get('display_errors');
$this->assertEquals(1, $result);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -46,7 +46,7 @@ public function setUp() {
$request = new Request();
$request->base = '';
Router::setRequestInfo($request);
Configure::write('debug', 2);
Configure::write('debug', true);

$this->_logger = $this->getMock('Cake\Log\LogInterface');
Log::config('error_test', [
Expand Down Expand Up @@ -141,7 +141,7 @@ public function testErrorSuppressed() {
* @return void
*/
public function testHandleErrorDebugOff() {
Configure::write('debug', 0);
Configure::write('debug', false);
$errorHandler = new ErrorHandler();
$errorHandler->register();
$this->_restoreError = true;
Expand All @@ -159,7 +159,7 @@ public function testHandleErrorDebugOff() {
* @return void
*/
public function testHandleErrorLoggingTrace() {
Configure::write('debug', 0);
Configure::write('debug', false);
$errorHandler = new ErrorHandler(['trace' => true]);
$errorHandler->register();
$this->_restoreError = true;
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testLoadPluginHandler() {
public function testHandleFatalErrorPage() {
$line = __LINE__;
$errorHandler = new ErrorHandler();
Configure::write('debug', 1);
Configure::write('debug', true);
ob_start();
ob_start();
$errorHandler->handleFatalError(E_ERROR, 'Something wrong', __FILE__, $line);
Expand All @@ -285,7 +285,7 @@ public function testHandleFatalErrorPage() {

ob_start();
ob_start();
Configure::write('debug', 0);
Configure::write('debug', false);
$errorHandler->handleFatalError(E_ERROR, 'Something wrong', __FILE__, $line);
$result = ob_get_clean();
$this->assertNotContains('Something wrong', $result, 'message must not appear.');
Expand Down
14 changes: 7 additions & 7 deletions tests/TestCase/Error/ExceptionRendererTest.php
Expand Up @@ -138,7 +138,7 @@ public function setUp() {
$request = new Request();
$request->base = '';
Router::setRequestInfo($request);
Configure::write('debug', 2);
Configure::write('debug', true);
}

/**
Expand Down Expand Up @@ -170,7 +170,7 @@ protected function _mockResponse($error) {
* @return void
*/
public function testSubclassMethodsNotBeingConvertedToError() {
Configure::write('debug', 2);
Configure::write('debug', true);

$exception = new MissingWidgetThingException('Widget not found');
$ExceptionRenderer = $this->_mockResponse(new MyCustomExceptionRenderer($exception));
Expand All @@ -188,7 +188,7 @@ public function testSubclassMethodsNotBeingConvertedToError() {
* @return void
*/
public function testSubclassMethodsNotBeingConvertedDebug0() {
Configure::write('debug', 0);
Configure::write('debug', false);
$exception = new MissingWidgetThingException('Widget not found');
$ExceptionRenderer = $this->_mockResponse(new MyCustomExceptionRenderer($exception));

Expand All @@ -207,7 +207,7 @@ public function testSubclassMethodsNotBeingConvertedDebug0() {
* @return void
*/
public function testSubclassConvertingFrameworkErrors() {
Configure::write('debug', 0);
Configure::write('debug', false);

$exception = new Error\MissingControllerException('PostsController');
$ExceptionRenderer = $this->_mockResponse(new MyCustomExceptionRenderer($exception));
Expand Down Expand Up @@ -241,7 +241,7 @@ public function testConstruction() {
* @return void
*/
public function testErrorMethodCoercion() {
Configure::write('debug', 0);
Configure::write('debug', false);
$exception = new Error\MissingActionException('Page not found');
$ExceptionRenderer = new ExceptionRenderer($exception);

Expand Down Expand Up @@ -311,7 +311,7 @@ public function testUnknownExceptionTypeWithNoCodeIsA500() {
* @return void
*/
public function testUnknownExceptionInProduction() {
Configure::write('debug', 0);
Configure::write('debug', false);

$exception = new \OutOfBoundsException('foul ball.');
$ExceptionRenderer = new ExceptionRenderer($exception);
Expand Down Expand Up @@ -378,7 +378,7 @@ public function testError400() {
* @return void
*/
public function testerror400OnlyChangingCakeException() {
Configure::write('debug', 0);
Configure::write('debug', false);

$exception = new Error\NotFoundException('Custom message');
$ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception));
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Network/SessionTest.php
Expand Up @@ -695,7 +695,7 @@ public function testReadAndWriteWithDatabaseStorage() {
* @return void
*/
public function testSessionTimeout() {
Configure::write('debug', 2);
Configure::write('debug', true);
Configure::write('Session.defaults', 'cake');
Configure::write('Session.autoRegenerate', false);

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/DispatcherTest.php
Expand Up @@ -888,7 +888,7 @@ public function testFullPageCachingDispatch($url) {
Cache::enable();
Configure::write('Cache.disable', false);
Configure::write('Cache.check', true);
Configure::write('debug', 2);
Configure::write('debug', true);

Router::reload();
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Utility/DebuggerTest.php
Expand Up @@ -54,7 +54,7 @@ class DebuggerTest extends TestCase {
*/
public function setUp() {
parent::setUp();
Configure::write('debug', 2);
Configure::write('debug', true);
Configure::write('log', false);
}

Expand Down
20 changes: 10 additions & 10 deletions tests/TestCase/View/Helper/HtmlHelperTest.php
Expand Up @@ -415,7 +415,7 @@ public function testImageWithTimestampping() {
$result = $this->Html->image('cake.icon.png');
$this->assertTags($result, array('img' => array('src' => 'preg:/\/img\/cake\.icon\.png\?\d+/', 'alt' => '')));

Configure::write('debug', 0);
Configure::write('debug', false);
Configure::write('Asset.timestamp', 'force');

$result = $this->Html->image('cake.icon.png');
Expand All @@ -441,7 +441,7 @@ public function testImageTagWithTheme() {
new File($testfile, true);

Configure::write('Asset.timestamp', true);
Configure::write('debug', 1);
Configure::write('debug', true);

$this->Html->request->webroot = '/';
$this->Html->theme = 'test_theme';
Expand Down Expand Up @@ -672,7 +672,7 @@ public function testPluginCssLink() {
* @return void
*/
public function testCssTimestamping() {
Configure::write('debug', 2);
Configure::write('debug', true);
Configure::write('Asset.timestamp', true);

$expected = array(
Expand All @@ -683,7 +683,7 @@ public function testCssTimestamping() {
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
$this->assertTags($result, $expected);

Configure::write('debug', 0);
Configure::write('debug', false);

$result = $this->Html->css('cake.generic');
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css/';
Expand Down Expand Up @@ -714,7 +714,7 @@ public function testCssTimestamping() {
public function testPluginCssTimestamping() {
Plugin::load('TestPlugin');

Configure::write('debug', 2);
Configure::write('debug', true);
Configure::write('Asset.timestamp', true);

$expected = array(
Expand All @@ -725,7 +725,7 @@ public function testPluginCssTimestamping() {
$expected['link']['href'] = 'preg:/.*test_plugin\/css\/test_plugin_asset\.css\?[0-9]+/';
$this->assertTags($result, $expected);

Configure::write('debug', 0);
Configure::write('debug', false);

$result = $this->Html->css('TestPlugin.test_plugin_asset');
$expected['link']['href'] = 'preg:/.*test_plugin\/css\/test_plugin_asset\.css/';
Expand Down Expand Up @@ -758,7 +758,7 @@ public function testPluginCssTimestamping() {
public function testScriptTimestamping() {
$this->skipIf(!is_writable(WWW_ROOT . 'js'), 'webroot/js is not Writable, timestamp testing has been skipped.');

Configure::write('debug', 2);
Configure::write('debug', true);
Configure::write('Asset.timestamp', true);

touch(WWW_ROOT . 'js/__cake_js_test.js');
Expand All @@ -767,7 +767,7 @@ public function testScriptTimestamping() {
$result = $this->Html->script('__cake_js_test', array('once' => false));
$this->assertRegExp('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');

Configure::write('debug', 0);
Configure::write('debug', false);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->script('__cake_js_test', array('once' => false));
$this->assertRegExp('/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
Expand All @@ -787,7 +787,7 @@ public function testPluginScriptTimestamping() {
$pluginJsPath = $pluginPath . 'webroot/js';
$this->skipIf(!is_writable($pluginJsPath), $pluginJsPath . ' is not Writable, timestamp testing has been skipped.');

Configure::write('debug', 2);
Configure::write('debug', true);
Configure::write('Asset.timestamp', true);

touch($pluginJsPath . DS . '__cake_js_test.js');
Expand All @@ -796,7 +796,7 @@ public function testPluginScriptTimestamping() {
$result = $this->Html->script('TestPlugin.__cake_js_test', array('once' => false));
$this->assertRegExp('/test_plugin\/js\/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');

Configure::write('debug', 0);
Configure::write('debug', false);
Configure::write('Asset.timestamp', 'force');
$result = $this->Html->script('TestPlugin.__cake_js_test', array('once' => false));
$this->assertRegExp('/test_plugin\/js\/__cake_js_test.js\?' . $timestamp . '[0-9]{2}"/', $result, 'Timestamp value not found %s');
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/View/HelperTest.php
Expand Up @@ -264,7 +264,7 @@ public function testAssetTimestamp() {
$this->assertEquals(Configure::read('App.cssBaseUrl') . 'cake.generic.css', $result);

Configure::write('Asset.timestamp', true);
Configure::write('debug', 0);
Configure::write('debug', false);

$result = $this->Helper->assetTimestamp('/%3Cb%3E/cake.generic.css');
$this->assertEquals('/%3Cb%3E/cake.generic.css', $result);
Expand All @@ -273,12 +273,12 @@ public function testAssetTimestamp() {
$this->assertEquals(Configure::read('App.cssBaseUrl') . 'cake.generic.css', $result);

Configure::write('Asset.timestamp', true);
Configure::write('debug', 2);
Configure::write('debug', true);
$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css');
$this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);

Configure::write('Asset.timestamp', 'force');
Configure::write('debug', 0);
Configure::write('debug', false);
$result = $this->Helper->assetTimestamp(Configure::read('App.cssBaseUrl') . 'cake.generic.css');
$this->assertRegExp('/' . preg_quote(Configure::read('App.cssBaseUrl') . 'cake.generic.css?', '/') . '[0-9]+/', $result);

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/JsonViewTest.php
Expand Up @@ -32,7 +32,7 @@ class JsonViewTest extends TestCase {

public function setUp() {
parent::setUp();
Configure::write('debug', 0);
Configure::write('debug', false);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/View/ViewTest.php
Expand Up @@ -275,7 +275,7 @@ public function setUp() {
App::objects('Plugin', null, false);

Plugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs'));
Configure::write('debug', 2);
Configure::write('debug', true);
}

/**
Expand Down

0 comments on commit 3d1a78f

Please sign in to comment.