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