| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace Test\Michel\Console;
- use Michel\Console\Output;
- use Michel\UniTester\TestCase;
- class OutputTest extends TestCase
- {
- protected function setUp(): void
- {
- // TODO: Implement setUp() method.
- }
- protected function tearDown(): void
- {
- // TODO: Implement tearDown() method.
- }
- protected function execute(): void
- {
- $this->testWrite();
- $this->testWriteln();
- }
- public function testWrite()
- {
- $output = new Output(function ($message) {
- $this->assertEquals('Hello, world!', $message);
- });
- $output->write('Hello, world!');
- }
- public function testWriteln()
- {
- $lines = 0;
- $output = new Output(function ($message) use(&$lines) {
- if ($lines === 0) {
- $this->assertEquals('Hello, world!', $message);
- }
- if ($lines === 1) {
- $this->assertEquals(PHP_EOL, $message);
- }
- $lines++;
- });
- $output->writeln('Hello, world!');
- $this->assertEquals(2, $lines);
- }
- }
|