-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
74 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Buggregator\Trap\Tests\Unit\Traffic\Dispatcher; | ||
|
||
use Buggregator\Trap\Test\Mock\StreamClientMock; | ||
use Buggregator\Trap\Tests\Unit\FiberTrait; | ||
use Buggregator\Trap\Traffic\Dispatcher\VarDumper; | ||
use DateTimeImmutable; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \Buggregator\Trap\Traffic\Dispatcher\Http | ||
*/ | ||
class VarDumperTest extends TestCase | ||
{ | ||
use FiberTrait; | ||
|
||
public static function detectProvider(): iterable | ||
{ | ||
yield ["ABC\n", true]; | ||
yield ["ABC\r\n", false]; | ||
yield ["A B C\n", false]; | ||
} | ||
|
||
#[DataProvider('detectProvider')] | ||
public function testDetect(string $data, ?bool $expected): void | ||
{ | ||
$dispatcher = new VarDumper(); | ||
$this->assertSame($expected, $dispatcher->detect($data, new DateTimeImmutable())); | ||
} | ||
|
||
public function testDispatchFramesTime(): void | ||
{ | ||
$dispatcher = new VarDumper(); | ||
$stream = StreamClientMock::createFromGenerator((function (): \Generator { | ||
yield "ABC\n"; | ||
yield "DEF\n"; | ||
yield "GHI\n"; | ||
})()); | ||
|
||
$resultGenerator = $dispatcher->dispatch($stream); | ||
|
||
$frames = $this->runInFiber(static fn () => \iterator_to_array($resultGenerator)); | ||
|
||
self::assertCount(3, $frames); | ||
self::assertNotSame($frames[0]->time, $frames[1]->time); | ||
self::assertNotSame($frames[1]->time, $frames[2]->time); | ||
} | ||
} |