beloys / stub-grpc
此包最新版本(0.0.1)没有可用的许可证信息。
gRPC 模拟
0.0.1
2020-04-03 16:02 UTC
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: 2024-09-17 02:12:03 UTC
README
带有 PHPStorm 元数据的 gRPC 客户端模拟
安装
composer require beloys/stub-grpc --dev
示例
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();
测试
composer tests