Browse Source

Move stub helper into a separate file.

It will be needed in other test cases so we might as well make it
reusable.
Mark Story 11 years ago
parent
commit
589ff7b1c0
2 changed files with 37 additions and 21 deletions
  1. 35 0
      src/TestSuite/Stub/ConsoleOutput.php
  2. 2 21
      tests/TestCase/Shell/Helper/TableHelperTest.php

+ 35 - 0
src/TestSuite/Stub/ConsoleOutput.php

@@ -0,0 +1,35 @@
+<?php
+/**
+ * CakePHP :  Rapid Development Framework (http://cakephp.org)
+ * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * For full copyright and license information, please see the LICENSE.txt
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
+ * @link          http://cakephp.org CakePHP Project
+ * @since         3.1.0
+ * @license       http://www.opensource.org/licenses/mit-license.php MIT License
+ */
+namespace Cake\TestSuite\Stub;
+
+use Cake\Console\ConsoleOutput as ConsoleOutputBase;
+
+/**
+ * StubOutput makes testing shell commands/shell helpers easier.
+ */
+class ConsoleOutput extends ConsoleOutputBase
+{
+    protected $_out = [];
+
+    public function write($message, $newlines = 1)
+    {
+        $this->_out[] = $message;
+    }
+
+    public function messages()
+    {
+        return $this->_out;
+    }
+}

+ 2 - 21
tests/TestCase/Shell/Helper/TableHelperTest.php

@@ -15,29 +15,11 @@
 namespace Cake\Test\TestCase\Shell\Helper;
 
 use Cake\Console\ConsoleIo;
-use Cake\Console\ConsoleOutput;
 use Cake\Shell\Helper\TableHelper;
+use Cake\TestSuite\Stub\ConsoleOutput;
 use Cake\TestSuite\TestCase;
 
 /**
- * StubOutput makes testing easier.
- */
-class StubOutput extends ConsoleOutput
-{
-    protected $_out = [];
-
-    public function write($message, $newlines = 1)
-    {
-        $this->_out[] = $message;
-    }
-
-    public function messages()
-    {
-        return $this->_out;
-    }
-}
-
-/**
  * TableHelper test.
  */
 class TableHelperTest extends TestCase
@@ -52,7 +34,7 @@ class TableHelperTest extends TestCase
     {
         parent::setUp();
 
-        $this->stub = new StubOutput();
+        $this->stub = new ConsoleOutput();
         $this->io = new ConsoleIo($this->stub);
         $this->helper = new TableHelper($this->io);
     }
@@ -124,7 +106,6 @@ class TableHelperTest extends TestCase
             '| Longer thing | longerish | Longest Value |',
             '+--------------+-----------+---------------+',
         ];
-        debug($this->stub->messages());
         $this->assertEquals($expected, $this->stub->messages());
     }
 }