|
| 1 | +<?php |
| 2 | + |
| 3 | + |
| 4 | +use Ckoumpis\PhpPrompt\Console; |
| 5 | +use PHPUnit\Framework\TestCase; |
| 6 | + |
| 7 | +class ConsoleTest extends TestCase |
| 8 | +{ |
| 9 | + |
| 10 | + public function testWarning() |
| 11 | + { |
| 12 | + ob_start(); |
| 13 | + Console::warning('Testing warning!'); |
| 14 | + $output = ob_get_clean(); |
| 15 | + echo $output; |
| 16 | + $this->assertStringContainsString("\033[1;33", $output); |
| 17 | + } |
| 18 | + |
| 19 | + public function testCyan() |
| 20 | + { |
| 21 | + ob_start(); |
| 22 | + Console::cyan('Testing Cyan!'); |
| 23 | + $output = ob_get_clean(); |
| 24 | + echo $output; |
| 25 | + $this->assertStringContainsString("\033[0;36", $output); |
| 26 | + |
| 27 | + } |
| 28 | + |
| 29 | + public function testLog() |
| 30 | + { |
| 31 | + ob_start(); |
| 32 | + Console::log('Testing log!'); |
| 33 | + $output = ob_get_clean(); |
| 34 | + echo $output; |
| 35 | + $this->assertStringContainsString("\033[1;37", $output); |
| 36 | + } |
| 37 | + |
| 38 | + public function testError() |
| 39 | + { |
| 40 | + ob_start(); |
| 41 | + Console::error('Testing error!'); |
| 42 | + $output = ob_get_clean(); |
| 43 | + echo $output; |
| 44 | + $this->assertStringContainsString("\033[0;31", $output); |
| 45 | + } |
| 46 | + |
| 47 | + public function testSuccess() |
| 48 | + { |
| 49 | + ob_start(); |
| 50 | + Console::success('Testing success!'); |
| 51 | + $output = ob_get_clean(); |
| 52 | + echo $output; |
| 53 | + $this->assertStringContainsString("\033[0;32", $output); |
| 54 | + } |
| 55 | + |
| 56 | + public function testMagenta() |
| 57 | + { |
| 58 | + ob_start(); |
| 59 | + Console::magenta('Testing magenta!'); |
| 60 | + $output = ob_get_clean(); |
| 61 | + echo $output; |
| 62 | + $this->assertStringContainsString("\033[0;35", $output); |
| 63 | + |
| 64 | + } |
| 65 | + |
| 66 | + public function testBlue() |
| 67 | + { |
| 68 | + ob_start(); |
| 69 | + Console::blue('Testing blue!'); |
| 70 | + $output = ob_get_clean(); |
| 71 | + echo $output; |
| 72 | + $this->assertStringContainsString("\033[0;34", $output); |
| 73 | + } |
| 74 | + |
| 75 | + public function testDebug() |
| 76 | + { |
| 77 | + ob_start(); |
| 78 | + Console::debug('Testing debug!'); |
| 79 | + $output = ob_get_clean(); |
| 80 | + echo $output; |
| 81 | + $this->assertStringContainsString("\033[38;5;235", $output); |
| 82 | + } |
| 83 | + |
| 84 | + public function testNotice() |
| 85 | + { |
| 86 | + ob_start(); |
| 87 | + Console::notice('Testing notice!'); |
| 88 | + $output = ob_get_clean(); |
| 89 | + echo $output; |
| 90 | + $this->assertStringContainsString("\033[0;36", $output); |
| 91 | + |
| 92 | + } |
| 93 | +} |
0 commit comments