|
| 1 | +<?php declare(strict_types=1); |
| 2 | +/* |
| 3 | + * This file is part of PHPUnit. |
| 4 | + * |
| 5 | + * (c) Sebastian Bergmann <[email protected]> |
| 6 | + * |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
| 9 | + */ |
| 10 | +namespace PHPUnit\TextUI\Output\Default; |
| 11 | + |
| 12 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 13 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 14 | +use PHPUnit\Framework\Attributes\Medium; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | +use PHPUnit\TextUI\InvalidSocketException; |
| 17 | +use PHPUnit\TextUI\Output\DefaultPrinter; |
| 18 | + |
| 19 | +#[CoversClass(DefaultPrinter::class)] |
| 20 | +#[Medium] |
| 21 | +final class DefaultPrinterTest extends TestCase |
| 22 | +{ |
| 23 | + public static function providePrinter(): array |
| 24 | + { |
| 25 | + return [ |
| 26 | + [DefaultPrinter::standardOutput()], |
| 27 | + [DefaultPrinter::standardError()], |
| 28 | + [DefaultPrinter::from('socket://hostname:port')], |
| 29 | + ]; |
| 30 | + } |
| 31 | + |
| 32 | + #[DataProvider('providePrinter')] |
| 33 | + public function testFlush(DefaultPrinter $printer): void |
| 34 | + { |
| 35 | + $printer->flush(); |
| 36 | + $this->expectOutputString(''); |
| 37 | + } |
| 38 | + |
| 39 | + public function testInvalidSocket(): void |
| 40 | + { |
| 41 | + $this->expectException(InvalidSocketException::class); |
| 42 | + DefaultPrinter::from('socket://hostname:port:wrong'); |
| 43 | + } |
| 44 | +} |
0 commit comments