ソースを参照

MyConsoleOutput class

euromark 12 年 前
コミット
2331633871
1 ファイル変更43 行追加0 行削除
  1. 43 0
      TestSuite/MyConsoleOutput.php

+ 43 - 0
TestSuite/MyConsoleOutput.php

@@ -0,0 +1,43 @@
+<?php
+App::uses('ConsoleOutput', 'Console');
+
+/**
+ * Use as
+ *
+ *  App::uses('MyConsoleOutput', 'Tools.TestSuite');
+ *
+ *  $stdOut = new MyConsoleOutput();
+ *  $this->MyShell = new MyShell($stdOut);
+ *
+ * @license MIT
+ * @author Mark Scherer
+ */
+class MyConsoleOutput extends ConsoleOutput {
+
+	/**
+	 * Holds all output messages.
+	 *
+	 * @var array
+	 */
+	public $output = array();
+
+	/**
+	 * Overwrite _write to output the message to debug instead of CLI.
+	 *
+	 * @param string $message
+	 * @return void
+	 */
+	protected function _write($message) {
+		$this->output[] = $message;
+	}
+
+	/**
+	 * Helper method to return the debug output as string.
+	 *
+	 * @return string
+	 */
+	public function output() {
+		return implode('', $this->output);
+	}
+
+}