feat: enhance service providers with provides method and integrate command bus in handlers
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m40s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m42s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m53s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m55s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m42s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m24s

This commit is contained in:
2025-12-22 13:18:13 -05:00
parent cae1de6ef3
commit de0c95db2a
17 changed files with 107 additions and 60 deletions

View File

@@ -4,19 +4,32 @@ declare(strict_types=1);
namespace Siteworxpro\Tests\GrpcHandlers;
use GRPC\Greeter\HelloRequest;
use League\Tactician\CommandBus;
use Siteworxpro\App\GrpcHandlers\GreeterHandler;
use Siteworxpro\Tests\Unit;
use Spiral\RoadRunner\GRPC\ContextInterface;
class GreeterHandlerTest extends Unit
{
/**
* @throws \ReflectionException
*/
public function testSayHello(): void
{
$request = new \GRPC\Greeter\HelloRequest();
$this->getContainer()->bind(CommandBus::class, function () {
return \Mockery::mock(CommandBus::class)
->shouldReceive('handle')
->andReturn('Hello World')
->getMock();
});
$request = new HelloRequest();
$request->setName('World');
$context = \Mockery::mock(ContextInterface::class);
$handler = new \Siteworxpro\App\GrpcHandlers\GreeterHandler();
$handler = new GreeterHandler();
$response = $handler->SayHello($context, $request);
$this->assertEquals('Hello World', $response->getMessage());
}