Browse Source

Use output buffering instead of a log file

Yves P 11 years ago
parent
commit
5f86f594aa

+ 2 - 6
tests/TestCase/Console/ShellTest.php

@@ -831,11 +831,11 @@ class ShellTest extends TestCase
      */
     public function testDispatchShell()
     {
-        $this->skipIf(!touch(TEST_APP . 'shell.log'), 'Can\'t write shell test log file');
         $Shell = new TestingDispatchShell();
+        ob_start();
         $Shell->runCommand(['test_task'], true);
+        $result = ob_get_clean();
 
-        $result = file_get_contents(TEST_APP . 'shell.log');
         $expected = <<<TEXT
 <info>Welcome to CakePHP v3.0.1 Console</info>
 I am a test task, I dispatch another Shell
@@ -844,10 +844,6 @@ I am a dispatched Shell
 
 TEXT;
         $this->assertEquals($expected, $result);
-
-        //@codingStandardsIgnoreStart
-        @unlink(TEST_APP . 'shell.log');
-        //@codingStandardsIgnoreEnd
     }
 
     /**

+ 1 - 3
tests/test_app/TestApp/Shell/TestingDispatchShell.php

@@ -25,8 +25,6 @@ use Cake\Core\Configure;
 class TestingDispatchShell extends Shell
 {
 
-    public $outPath = '';
-
     protected function _welcome()
     {
         $this->out(sprintf('<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
@@ -34,7 +32,7 @@ class TestingDispatchShell extends Shell
 
     public function out($message = null, $newlines = 1, $level = Shell::NORMAL)
     {
-        file_put_contents(TEST_APP . 'shell.log', $message . "\n", FILE_APPEND);
+        echo $message . "\n";
     }
 
     public function testTask()