浏览代码

Improve debugging output.

euromark 11 年之前
父节点
当前提交
22a3f6b6eb

+ 2 - 1
Test/Case/Model/Behavior/PasswordableBehaviorTest.php

@@ -213,7 +213,8 @@ class PasswordableBehaviorTest extends CakeTestCase {
 	 * @return void
 	 * @return void
 	 */
 	 */
 	public function testValidateCustomRule() {
 	public function testValidateCustomRule() {
-		$rules = array('validateCustom' => array(
+		$rules = array(
+			'validateCustom' => array(
 				'rule' => array('custom', '#^[a-z0-9]+$#'), // Just a test example, never use this regexp!
 				'rule' => array('custom', '#^[a-z0-9]+$#'), // Just a test example, never use this regexp!
 				'message' => 'Foo Bar',
 				'message' => 'Foo Bar',
 				'last' => true,
 				'last' => true,

+ 10 - 3
TestSuite/MyCakeTestCase.php

@@ -26,13 +26,18 @@ abstract class MyCakeTestCase extends CakeTestCase {
 	 *
 	 *
 	 * @param mixed $data
 	 * @param mixed $data
 	 * @param bool $force Should the output be flushed (forced)
 	 * @param bool $force Should the output be flushed (forced)
+	 * @param bool $showHtml
 	 * @return void
 	 * @return void
 	 */
 	 */
-	public static function debug($data, $force = false) {
-		if (php_sapi_name() === 'cli') {
+	public static function debug($data, $force = false, $showHtml = null) {
+		if (!empty($_GET['debug']) || !empty($_SERVER['argv']) && (in_array('-v', $_SERVER['argv'], true) || in_array('-vv', $_SERVER['argv'], true))) {
+			if ($showHtml === null && php_sapi_name() === 'cli') {
+				$showHtml = true;
+			}
+			debug($data, $showHtml);
+		} else {
 			return;
 			return;
 		}
 		}
-		debug($data, null, false);
 		if (!$force) {
 		if (!$force) {
 			return;
 			return;
 		}
 		}
@@ -44,6 +49,8 @@ abstract class MyCakeTestCase extends CakeTestCase {
 	 * since PHPUnit>=3.6 swallowes all output by default
 	 * since PHPUnit>=3.6 swallowes all output by default
 	 * this is a convenience output handler
 	 * this is a convenience output handler
 	 *
 	 *
+	 * This method will not be part of 3.x! Please switch to debug().
+	 *
 	 * @param mixed $data
 	 * @param mixed $data
 	 * @param bool $force Should the output be flushed (forced)
 	 * @param bool $force Should the output be flushed (forced)
 	 * @return void
 	 * @return void

+ 1 - 1
TestSuite/TestConsoleOutput.php

@@ -28,7 +28,7 @@ class TestConsoleOutput extends ConsoleOutput {
 	 * @return void
 	 * @return void
 	 */
 	 */
 	protected function _write($message) {
 	protected function _write($message) {
-		if (php_sapi_name() !== 'cli' && !empty($_GET) && !empty($_GET['debug'])) {
+		if (!empty($_GET['debug']) || !empty($_SERVER['argv']) && (in_array('-v', $_SERVER['argv'], true) || in_array('-vv', $_SERVER['argv'], true))) {
 			debug($message);
 			debug($message);
 		}
 		}
 		$this->output[] = $message;
 		$this->output[] = $message;