diff --git a/tests/system/CLI/CommandRunnerTest.php b/tests/system/CLI/CommandRunnerTest.php index c84f29de19c4..961f2b4ebf8d 100644 --- a/tests/system/CLI/CommandRunnerTest.php +++ b/tests/system/CLI/CommandRunnerTest.php @@ -2,6 +2,7 @@ use Config\MockCLIConfig; use CodeIgniter\HTTP\UserAgent; +use CodeIgniter\Test\Filters\CITestStreamFilter; class CommandRunnerTest extends \CIUnitTestCase { @@ -10,8 +11,8 @@ class CommandRunnerTest extends \CIUnitTestCase public function setUp() { - CLICommandStreamFilter::$buffer = ''; - $this->stream_filter = stream_filter_append(STDOUT, 'CLICommandStreamFilter'); + CITestStreamFilter::$buffer = ''; + $this->stream_filter = stream_filter_append(STDOUT, 'CITestStreamFilter'); $this->env = new \CodeIgniter\Config\DotEnv(ROOTPATH); $this->env->load(); @@ -40,7 +41,7 @@ public function tearDown() public function testGoodCommand() { $this->runner->index(['list']); - $result = CLICommandStreamFilter::$buffer; + $result = CITestStreamFilter::$buffer; // make sure the result looks like a command list $this->assertContains('Lists the available commands.', $result); @@ -50,7 +51,7 @@ public function testGoodCommand() public function testDefaultCommand() { $this->runner->index([]); - $result = CLICommandStreamFilter::$buffer; + $result = CITestStreamFilter::$buffer; // make sure the result looks like basic help $this->assertContains('Displays basic usage information.', $result); @@ -60,7 +61,7 @@ public function testDefaultCommand() public function testEmptyCommand() { $this->runner->index([null,'list']); - $result = CLICommandStreamFilter::$buffer; + $result = CITestStreamFilter::$buffer; // make sure the result looks like a command list $this->assertContains('Lists the available commands.', $result); @@ -68,9 +69,9 @@ public function testEmptyCommand() public function testBadCommand() { - $this->error_filter = stream_filter_append(STDERR, 'CLICommandStreamFilter'); + $this->error_filter = stream_filter_append(STDERR, 'CITestStreamFilter'); $this->runner->index(['bogus']); - $result = CLICommandStreamFilter::$buffer; + $result = CITestStreamFilter::$buffer; stream_filter_remove($this->error_filter); // make sure the result looks like a command list @@ -78,22 +79,3 @@ public function testBadCommand() } } - -class CLICommandStreamFilter extends \php_user_filter -{ - - public static $buffer = ''; - - public function filter($in, $out, &$consumed, $closing) - { - while ($bucket = stream_bucket_make_writeable($in)) - { - self::$buffer .= $bucket->data; - $consumed += $bucket->datalen; - } - return PSFS_PASS_ON; - } - -} - -stream_filter_register('CLICommandStreamFilter', 'CodeIgniter\CLI\CLICommandStreamFilter'); diff --git a/tests/system/CLI/ConsoleTest.php b/tests/system/CLI/ConsoleTest.php index f42fbfee680d..db372db1ea2b 100644 --- a/tests/system/CLI/ConsoleTest.php +++ b/tests/system/CLI/ConsoleTest.php @@ -1,6 +1,7 @@ stream_filter = stream_filter_append(STDOUT, 'CLICTestStreamFilter'); + CITestStreamFilter::$buffer = ''; + $this->stream_filter = stream_filter_append(STDOUT, 'CITestStreamFilter'); $this->env = new \CodeIgniter\Config\DotEnv(ROOTPATH); $this->env->load(); @@ -44,7 +45,7 @@ public function testHeader() { $console = new \CodeIgniter\CLI\Console($this->app); $console->showHeader(); - $result = CLICTestStreamFilter::$buffer; + $result = CITestStreamFilter::$buffer; $this->assertTrue(strpos($result, 'CodeIgniter CLI Tool') > 0); } @@ -52,7 +53,7 @@ public function testRun() { $console = new \CodeIgniter\CLI\Console($this->app); $console->run(); - $result = CLICTestStreamFilter::$buffer; + $result = CITestStreamFilter::$buffer; // make sure the result looks like a command list $this->assertContains('Lists the available commands.', $result); @@ -60,22 +61,3 @@ public function testRun() } } - -class CLICTestStreamFilter extends \php_user_filter -{ - - public static $buffer = ''; - - public function filter($in, $out, &$consumed, $closing) - { - while ($bucket = stream_bucket_make_writeable($in)) - { - self::$buffer .= $bucket->data; - $consumed += $bucket->datalen; - } - return PSFS_PASS_ON; - } - -} - -stream_filter_register('CLICTestStreamFilter', 'CodeIgniter\CLI\CLICTestStreamFilter');