mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Added testWrite and testColor
This commit is contained in:
parent
5e4718a3f2
commit
03407e5488
1
.gitignore
vendored
1
.gitignore
vendored
@ -124,3 +124,4 @@ nb-configuration.xml
|
||||
.vscode/
|
||||
|
||||
/results/
|
||||
/phpunit.xml
|
@ -79,6 +79,70 @@ class CLITest extends \CIUnitTestCase
|
||||
$this->assertEquals("\033[1;37m\033[42m\033[4mtest\033[0m", CLI::color('test', 'white', 'green', 'underline'));
|
||||
}
|
||||
|
||||
public function testWrite()
|
||||
{
|
||||
CLI::write('test');
|
||||
$expected = <<<EOT
|
||||
test
|
||||
|
||||
EOT;
|
||||
$this->assertEquals($expected, CLITestStreamFilter::$buffer);
|
||||
}
|
||||
|
||||
public function testWriteForeground()
|
||||
{
|
||||
CLI::write('test', 'red');
|
||||
$expected = <<<EOT
|
||||
\033[0;31mtest\033[0m
|
||||
|
||||
EOT;
|
||||
$this->assertEquals($expected, CLITestStreamFilter::$buffer);
|
||||
}
|
||||
|
||||
public function testWriteBackground()
|
||||
{
|
||||
CLI::write('test', 'red', 'green');
|
||||
$expected = <<<EOT
|
||||
\033[0;31m\033[42mtest\033[0m
|
||||
|
||||
EOT;
|
||||
$this->assertEquals($expected, CLITestStreamFilter::$buffer);
|
||||
}
|
||||
|
||||
public function testError()
|
||||
{
|
||||
$this->stream_filter = stream_filter_append(STDERR, 'CLITestStreamFilter');
|
||||
CLI::error('test');
|
||||
// red expected cuz stderr
|
||||
$expected = <<<EOT
|
||||
\033[1;31mtest\033[0m
|
||||
|
||||
EOT;
|
||||
$this->assertEquals($expected, CLITestStreamFilter::$buffer);
|
||||
}
|
||||
|
||||
public function testErrorForeground()
|
||||
{
|
||||
$this->stream_filter = stream_filter_append(STDERR, 'CLITestStreamFilter');
|
||||
CLI::error('test', 'purple');
|
||||
$expected = <<<EOT
|
||||
\033[0;35mtest\033[0m
|
||||
|
||||
EOT;
|
||||
$this->assertEquals($expected, CLITestStreamFilter::$buffer);
|
||||
}
|
||||
|
||||
public function testErrorBackground()
|
||||
{
|
||||
$this->stream_filter = stream_filter_append(STDERR, 'CLITestStreamFilter');
|
||||
CLI::error('test', 'purple', 'green');
|
||||
$expected = <<<EOT
|
||||
\033[0;35m\033[42mtest\033[0m
|
||||
|
||||
EOT;
|
||||
$this->assertEquals($expected, CLITestStreamFilter::$buffer);
|
||||
}
|
||||
|
||||
public function testShowProgress()
|
||||
{
|
||||
CLI::write('first.');
|
||||
|
Loading…
x
Reference in New Issue
Block a user