-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from buggregator/mainenance/var-dumper-tests
Covers var-dumper handler with tests
- Loading branch information
Showing
5 changed files
with
112 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Feature\Interfaces\TCP; | ||
|
||
use Tests\TestCase; | ||
|
||
abstract class TCPTestCase extends TestCase | ||
{ | ||
|
||
} |
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,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Interfaces\TCP\VarDumper; | ||
|
||
use Modules\VarDumper\Interfaces\TCP\Service; | ||
use Spiral\RoadRunner\Tcp\Request; | ||
use Spiral\RoadRunner\Tcp\TcpEvent; | ||
use Tests\Feature\Interfaces\TCP\TCPTestCase; | ||
|
||
final class SymfonyV6Test extends TCPTestCase | ||
{ | ||
public function testSendDump(): void | ||
{ | ||
dump('foo'); | ||
|
||
$payload = 'YToyOntpOjA7TzozOToiU3ltZm9ueVxDb21wb25lbnRcVmFyRHVtcGVyXENsb25lclxEYXRhIjo3OntzOjQ1OiIAU3ltZm9ueVxDb21wb25lbnRcVmFyRHVtcGVyXENsb25lclxEYXRhAGRhdGEiO2E6MTp7aTowO2E6MTp7aTowO3M6MzoiZm9vIjt9fXM6NDk6IgBTeW1mb255XENvbXBvbmVud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zOjY6InNvdXJjZSI7YTo0OntzOjQ6Im5hbWUiO3M6MTc6IlN5bWZvbnlWNlRlc3QucGhwIjtzOjQ6ImZpbGUiO3M6OTE6Ii9yb290L3JlcG9zL2J1Z2dyZWFndG9yL3NwaXJhbC1hcHAvdGVzdHMvRmVhdHVyZS9JbnRlcmZhY2VzL1RDUC9WYXJEdW1wZXIvU3ltZm9ueVY2VGVzdC5waHAiO3M6NDoibGluZSI7aToxMztzOjEyOiJmaWxlX2V4Y2VycHQiO2I6MDt9fX0='; | ||
|
||
$service = $this->get(Service::class); | ||
|
||
$service->handle( | ||
new Request( | ||
remoteAddr: '127.0.0.1', | ||
event: TcpEvent::Data, | ||
body: $payload, | ||
connectionUuid: (string)$this->randomUuid(), | ||
server: 'local', | ||
), | ||
); | ||
|
||
$this->broadcastig->assertPushed('events', function (array $data) { | ||
$this->assertSame('event.received', $data['event']); | ||
$this->assertSame('var-dump', $data['data']['type']); | ||
|
||
$this->assertSame([ | ||
'type' => 'string', | ||
'value' => 'foo', | ||
], $data['data']['payload']['payload']); | ||
|
||
$this->assertNotEmpty($data['data']['uuid']); | ||
$this->assertNotEmpty($data['data']['timestamp']); | ||
|
||
|
||
return true; | ||
}); | ||
} | ||
} |
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Interfaces\TCP\VarDumper; | ||
|
||
use Modules\VarDumper\Interfaces\TCP\Service; | ||
use Spiral\RoadRunner\Tcp\Request; | ||
use Spiral\RoadRunner\Tcp\TcpEvent; | ||
use Tests\Feature\Interfaces\TCP\TCPTestCase; | ||
|
||
final class SymfonyV7Test extends TCPTestCase | ||
{ | ||
public function testSendDump(): void | ||
{ | ||
$payload = 'YToyOntpOjA7TzozOToiU3ltZm9ueVxDb21wb25lbnRcV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BocCAvcm9vdC9yZXBvcy9idWdncmVhZ3Rvci9zcGlyYWwtYXBwL3Rlc3RzL0ZlYXR1cmUvSW50ZXJmYWNlcy9UQ1AvVmFyRHVtcGVyIC0tdGVhbWNpdHkiO3M6MTA6ImlkZW50aWZpZXIiO3M6ODoiNmMwYjkyODMiO31zOjY6InNvdXJjZSI7YTo0OntzOjQ6Im5hbWUiO3M6MTc6IlN5bWZvbnlWNlRlc3QucGhwIjtzOjQ6ImZpbGUiO3M6OTE6Ii9yb290L3JlcG9zL2J1Z2dyZWFndG9yL3NwaXJhbC1hcHAvdGVzdHMvRmVhdHVyZS9JbnRlcmZhY2VzL1RDUC9WYXJEdW1wZXIvU3ltZm9ueVY2VGVzdC5waHAiO3M6NDoibGluZSI7aToxNjtzOjEyOiJmaWxlX2V4Y2VycHQiO2I6MDt9fX0='; | ||
|
||
$service = $this->get(Service::class); | ||
|
||
$service->handle( | ||
new Request( | ||
remoteAddr: '127.0.0.1', | ||
event: TcpEvent::Data, | ||
body: $payload, | ||
connectionUuid: (string)$this->randomUuid(), | ||
server: 'local', | ||
), | ||
); | ||
|
||
$this->broadcastig->assertPushed('events', function (array $data) { | ||
$this->assertSame('event.received', $data['event']); | ||
$this->assertSame('var-dump', $data['data']['type']); | ||
|
||
$this->assertSame([ | ||
'type' => 'string', | ||
'value' => 'foo', | ||
], $data['data']['payload']['payload']); | ||
|
||
$this->assertNotEmpty($data['data']['uuid']); | ||
$this->assertNotEmpty($data['data']['timestamp']); | ||
|
||
|
||
return true; | ||
}); | ||
} | ||
} |
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