beloys / stub-grpc
Mock for gRPC
Installs: 50 569
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.1
- ext-grpc: *
- google/protobuf: ^3.11
- grpc/grpc: ^1.27
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpunit/phpunit: ^6
This package is auto-updated.
Last update: 2025-03-17 03:24:21 UTC
README
Mocks for gRPC clients with PHPStorm meta
Installation
composer require beloys/stub-grpc --dev
Examples
use Beloys\StubGrpc\StubGrpc; use Grpc\Health\V1\HealthCheckResponse; use Grpc\Health\V1\HealthCheckRequest; use Grpc\Health\V1\HealthClient; $mock = StubGrpc::make(HealthClient::class, [ '/grpc.health.v1.Health/Check' => new HealthCheckResponse(['status' => HealthCheckResponse\ServingStatus::SERVING]), ]); $mock = StubGrpc::make(HealthClient::class, [ '/grpc.health.v1.Health/Check' => function(HealthCheckRequest $in){ return [new HealthCheckResponse(), null]; }, ]); $mock = (new StubGrpc(HealthClient::class)) ->methodWillReturn('/cyberxpert.grpc.user.User/ViewByUuid', new HealthCheckResponse(), (object)['status' => 1]) ->build();
Tests
composer tests