PHPackages                             vladdnepr/graphql-test - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. vladdnepr/graphql-test

ActiveLibrary[API Development](/categories/api)

vladdnepr/graphql-test
======================

GraphQL Test Cases

v0.3.1(3y ago)121.9k↓45.2%MITPHPPHP ^8.1

Since Sep 12Pushed 3y agoCompare

[ Source](https://github.com/vladdnepr/graphql-test)[ Packagist](https://packagist.org/packages/vladdnepr/graphql-test)[ Docs](https://github.com/kunicmarko20/graphql-test)[ RSS](/packages/vladdnepr-graphql-test/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

GraphQL Test Case
=================

[](#graphql-test-case)

Makes testing your GraphQL queries and mutations easier.

Support for Symfony.

[![PHP Version](https://camo.githubusercontent.com/62a0059ce3aa1adb8a6ff1e13feec4cc5561cdec00541e59a5a36efc71e8681c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f766c6164646e6570722f6772617068716c2d74657374)](https://camo.githubusercontent.com/62a0059ce3aa1adb8a6ff1e13feec4cc5561cdec00541e59a5a36efc71e8681c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f766c6164646e6570722f6772617068716c2d74657374)[![Latest Stable Version](https://camo.githubusercontent.com/45596aa4aff14b5c54c945b285d691de1c014b4113c69dfa7e2bc4e6dde4f4f7/687474703a2f2f706f7365722e707567782e6f72672f766c6164646e6570722f6772617068716c2d746573742f76)](https://packagist.org/packages/vladdnepr/graphql-test)[![Latest Unstable Version](https://camo.githubusercontent.com/3ac3800a5542be54e6678855045c343d026b4c8ffc48d60ce9104894b1d64dc4/687474703a2f2f706f7365722e707567782e6f72672f766c6164646e6570722f6772617068716c2d746573742f762f756e737461626c65)](https://packagist.org/packages/vladdnepr/graphql-test)

[![Build Status](https://camo.githubusercontent.com/e4d89643647fa3ebdd411d52ea43d8b4376b4103927161615e5857001de33bdf/68747470733a2f2f6170702e7472617669732d63692e636f6d2f766c6164646e6570722f6772617068716c2d746573742e7376673f6272616e63683d6d6173746572)](https://app.travis-ci.com/vladdnepr/graphql-test)[![Coverage Status](https://camo.githubusercontent.com/9fc4b1501656187de276cc5688a512c9dee78e6b3ab799fbc659c38b36baaae2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f766c6164646e6570722f6772617068716c2d746573742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/vladdnepr/graphql-test?branch=master)

Documentation
-------------

[](#documentation)

- [Installation](#installation)
- [How to use](#how-to-use)
- [Examples](#examples)
    - [Query](#query)
    - [Mutation](#mutation)

Installation
------------

[](#installation)

**1.** Add dependency with composer

```
composer require --dev vladdnepr/graphql-test
```

> If you are using Symfony you will have to install "symfony/browser-kit".

How to use
----------

[](#how-to-use)

Depending on your framework, extend the correct `TestCase`:

```
use VladDnepr\GraphQLTest\Bridge\Symfony\TestCase;
```

> Everything you see in the next snippets is the same for all Test Cases.

In your tests you now have 2 additional helper methods:

```
public function query(QueryInterface $query, array $files = [], array $headers = []);
public function mutation(MutationInterface $mutation, array $files = [], array $headers = [])
```

By default, endpoint is `/graphql`, you can overwrite this by changing variable in your tests:

```
use VladDnepr\GraphQLTest\Bridge\Symfony\TestCase;

class UserTest extends TestCase
{
    public static $endpoint = '/';
}
```

There is a helper method that allows you to preset headers:

```
use VladDnepr\GraphQLTest\Bridge\Symfony\TestCase;

class SettingsTest extends TestCase
{
    protected function setUp()
    {
        $this->setDefaultHeaders([
            'Content-Type' => 'application/json',
        ]);
    }
}
```

Examples
--------

[](#examples)

### Query

[](#query)

```
use VladDnepr\GraphQLTest\Bridge\Symfony\TestCase;
use VladDnepr\GraphQLTest\Operation\Query;

class SettingsQueryTest extends TestCase
{
    public static $endpoint = '/';

    protected function setUp()
    {
        $this->setDefaultHeaders([
            'Content-Type' => 'application/json',
        ]);
    }

    public function testSettingsQuery(): void
    {
        $query = $this->query(
            new Query(
                'settings',
                [],
                [
                    'name',
                    'isEnabled',
                ],
            )
        );

        //Fetch response and do asserts
    }
}
```

`VladDnepr\GraphQLTest\Operation\Query` construct accepts 3 arguments:

- name of query (mandatory)
- parameters (optional)
- fields (optional)

### Mutation

[](#mutation)

```
use VladDnepr\GraphQLTest\Bridge\Symfony\TestCase;
use VladDnepr\GraphQLTest\Operation\Mutation;

class SettingsMutationTest extends TestCase
{
    public static $endpoint = '/';

    protected function setUp()
    {
        $this->setDefaultHeaders([
            'Content-Type' => 'application/json',
        ]);
    }

    public function testSettingsMutation(): void
    {
        $mutation = $this->mutation(
            new Mutation(
                'createSettings',
                [
                    'name' => 'hide-menu-bar',
                    'isEnabled' => true,
                ],
                [
                    'name',
                    'isEnabled',
                ],
            )
        );

        //Fetch response and do asserts
    }
}
```

`VladDnepr\GraphQLTest\Operation\Mutation` construct accepts 3 arguments:

- name of mutation (mandatory)
- parameters (optional)
- fields (optional)

If you have a Enum, Boolean or Array as an argument you can pass it as following:

```
use VladDnepr\GraphQLTest\Bridge\Symfony\TestCase;
use VladDnepr\GraphQLTest\Operation\Mutation;
use VladDnepr\GraphQLTest\Type\EnumType;
use VladDnepr\GraphQLTest\Type\BooleanType;
use VladDnepr\GraphQLTest\Type\ArrayType;

class UserMutationTest extends TestCase
{
    //...
    public function testUserMutation(): void
    {
        $mutation = $this->mutation(
            new Mutation(
                'createUser',
                [

                    'username' => 'kunicmarko20',
                    'salutation' => new EnumType('Mr'),
                    'enabled' => new BooleanType(true),
                    'roles' => new ArrayType(['ROLE_ADMIN', 'ROLE_TEST']),
                    //..
                ],
                [
                    'username',
                    'salutation',
                ],
            )
        );

        //Fetch response and do asserts
    }
}
```

Also, if you need a custom type you can always extend `VladDnepr\GraphQLTest\Type\TypeInterface`and use your own Type instead.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1345d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/101d5dc30b6dcc6122f15c83a22d9f1cdbe20e6e34d55cfa352de58d6a4d131b?d=identicon)[vladdnepr](/maintainers/vladdnepr)

---

Top Contributors

[![kunicmarko20](https://avatars.githubusercontent.com/u/13528674?v=4)](https://github.com/kunicmarko20 "kunicmarko20 (12 commits)")[![vlydev](https://avatars.githubusercontent.com/u/2308269?v=4)](https://github.com/vlydev "vlydev (8 commits)")[![chrisnharvey](https://avatars.githubusercontent.com/u/619298?v=4)](https://github.com/chrisnharvey "chrisnharvey (1 commits)")

---

Tags

symfonygraphqlgraphql-test

### Embed Badge

![Health badge](/badges/vladdnepr-graphql-test/health.svg)

```
[![Health](https://phpackages.com/badges/vladdnepr-graphql-test/health.svg)](https://phpackages.com/packages/vladdnepr-graphql-test)
```

###  Alternatives

[gmostafa/php-graphql-client

GraphQL client and query builder.

3217.6M25](/packages/gmostafa-php-graphql-client)[thecodingmachine/graphqlite-bundle

A Symfony bundle for thecodingmachine/graphqlite.

371.6M3](/packages/thecodingmachine-graphqlite-bundle)[kunicmarko/graphql-test

GraphQL Test Cases

1359.0k](/packages/kunicmarko-graphql-test)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
