Codeception的GraphQL扩展

v0.5.0 2023-04-10 14:36 UTC

This package is auto-updated.

Last update: 2024-09-10 17:29:43 UTC


README

一个用于调用GraphQL端点的Codeception扩展

这需要一个运行的服务器,如果需要,可以使用Codeception PhpBuiltInServer

安装

composer require zestic/codeception-graphql --dev

配置

在你的acceptance.suite.yml文件中

modules:
    enabled:
        - GraphQL:
            url: 'http://localhost:8080/'

测试

在测试中使用它

class PingCest
{
    public function testPing(AcceptanceTester $I)
    {
        $query = 'query{ping {response}}';
        $I->sendGraphQL($query);
        $expected = [
            'ping' => [
                'response' => 'pong',
            ],
        ];
        $I->assertEquals($expected, $I->grabResponseData());
    }
}