|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Tests\Unit\Subscriber\Application; |
| 4 | + |
| 5 | +use PHPUnit\Event\Application\Started; |
| 6 | +use PHPUnit\Event\Runtime\Runtime; |
| 7 | +use PHPUnit\Event\Telemetry\Duration; |
| 8 | +use PHPUnit\Event\Telemetry\GarbageCollectorStatus; |
| 9 | +use PHPUnit\Event\Telemetry\HRTime; |
| 10 | +use PHPUnit\Event\Telemetry\Info; |
| 11 | +use PHPUnit\Event\Telemetry\MemoryUsage; |
| 12 | +use PHPUnit\Event\Telemetry\Snapshot; |
| 13 | +use PHPUnit\Framework\TestCase; |
| 14 | +use RobinIngelbrecht\PHPUnitPrettyPrint\Subscriber\Application\ApplicationStartedSubscriber; |
| 15 | +use Spatie\Snapshots\MatchesSnapshots; |
| 16 | +use Tests\SpyOutput; |
| 17 | + |
| 18 | +use function Termwind\renderUsing; |
| 19 | + |
| 20 | +class ApplicationStartedSubscriberTest extends TestCase |
| 21 | +{ |
| 22 | + use MatchesSnapshots; |
| 23 | + |
| 24 | + public function testNotify(): void |
| 25 | + { |
| 26 | + $spyOutput = new SpyOutput(); |
| 27 | + renderUsing($spyOutput); |
| 28 | + |
| 29 | + $subscriber = new ApplicationStartedSubscriber(); |
| 30 | + $subscriber->notify(new Started( |
| 31 | + new Info( |
| 32 | + new Snapshot( |
| 33 | + HRTime::fromSecondsAndNanoseconds(1, 0), |
| 34 | + MemoryUsage::fromBytes(100), |
| 35 | + MemoryUsage::fromBytes(100), |
| 36 | + new GarbageCollectorStatus(0, 0, 0, 0, null, null, null, null, null, null, null, null) |
| 37 | + ), |
| 38 | + Duration::fromSecondsAndNanoseconds(1, 0), |
| 39 | + MemoryUsage::fromBytes(100), |
| 40 | + Duration::fromSecondsAndNanoseconds(1, 0), |
| 41 | + MemoryUsage::fromBytes(100), |
| 42 | + ), |
| 43 | + new Runtime() |
| 44 | + )); |
| 45 | + |
| 46 | + $this->assertMatchesRegularExpression('/Runtime: PHPUnit [\s\S]+ using PHP [\s\S]+ on [\s\S]+/', $spyOutput); |
| 47 | + } |
| 48 | +} |
0 commit comments