PHPackages                             kunicmarko/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. [Testing &amp; Quality](/categories/testing)
4. /
5. kunicmarko/graphql-test

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kunicmarko/graphql-test
=======================

GraphQL Test Cases

0.2.0(5y ago)1359.0k↓33.3%7[1 issues](https://github.com/kunicmarko20/graphql-test/issues)MITPHPPHP ^7.1

Since Jul 7Pushed 5y ago3 watchersCompare

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

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

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

[](#graphql-test-case)

Makes testing your GraphQL queries and mutations easier.

Support for Symfony, Lumen and Laravel.

[![PHP Version](https://camo.githubusercontent.com/2dcf2757d7a2ae7d144c6e7d9b63bd3383509e6b70bacccb3bd8ad04d1c2541c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e312d626c75652e737667)](https://img.shields.io/badge/php-%5E7.1-blue.svg)[![Latest Stable Version](https://camo.githubusercontent.com/5fd9e2eaaba78cffc15dbe31b633bdafea4f3a4b80b79a6a29b11324feacacd4/68747470733a2f2f706f7365722e707567782e6f72672f6b756e69636d61726b6f2f6772617068716c2d746573742f762f737461626c65)](https://packagist.org/packages/kunicmarko/graphql-test)[![Latest Unstable Version](https://camo.githubusercontent.com/6fd9c14a4dfdb45e72f66fdac756b8be821794a1db03152b64d8f4b4dd9d8b4e/68747470733a2f2f706f7365722e707567782e6f72672f6b756e69636d61726b6f2f6772617068716c2d746573742f762f756e737461626c65)](https://packagist.org/packages/kunicmarko/graphql-test)

[![Build Status](https://camo.githubusercontent.com/3df29383215db58c71ba320a1e1b02c0c28c5407ba0fc097bd129119ed1ce8e0/68747470733a2f2f7472617669732d63692e6f72672f6b756e69636d61726b6f32302f6772617068716c2d746573742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kunicmarko20/graphql-test)[![Coverage Status](https://camo.githubusercontent.com/19042857ce02af1ad2ac1878b24a3ed644bd3252605d9fc0fb3fa44d3e2c38b1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6b756e69636d61726b6f32302f6772617068716c2d746573742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/kunicmarko20/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 kunicmarko/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 KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
use KunicMarko\GraphQLTest\Bridge\Lumen\TestCase;
use KunicMarko\GraphQLTest\Bridge\Laravel\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 KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;

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

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

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

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

Examples
--------

[](#examples)

### Query

[](#query)

```
use KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
use KunicMarko\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
    }
}
```

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

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

### Mutation

[](#mutation)

```
use KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
use KunicMarko\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
    }
}
```

`KunicMarko\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 KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
use KunicMarko\GraphQLTest\Operation\Mutation;
use KunicMarko\GraphQLTest\Type\EnumType;
use KunicMarko\GraphQLTest\Type\BooleanType;
use KunicMarko\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 `KunicMarko\GraphQLTest\Type\TypeInterface`and use your own Type instead.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~723 days

Total

2

Last Release

2139d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c1e666a733b6e07ad9507caffe4fb9ddbf91f9f2676bafd4845bc56cfdbe892?d=identicon)[kunicmarko20](/maintainers/kunicmarko20)

---

Top Contributors

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

---

Tags

graphqllaravellumensymfonytestingsymfonylaravelgraphqllumengraphql-test

### Embed Badge

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

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

###  Alternatives

[osteel/openapi-httpfoundation-testing

Validate HttpFoundation requests and responses against OpenAPI (3+) definitions

1201.9M6](/packages/osteel-openapi-httpfoundation-testing)[mattiasgeniar/phpunit-query-count-assertions

A custom assertion for phpunit that allows you to count the amount of SQL queries used in a test. Can be used to enforce certain performance characteristics (ie: limit queries to X for a certain action).

160730.9k2](/packages/mattiasgeniar-phpunit-query-count-assertions)[marvinrabe/laravel-graphql-test

Provides you with a simple GraphQL testing trait.

58329.7k](/packages/marvinrabe-laravel-graphql-test)[albertcht/lumen-testing

Testing Suite For Lumen like Laravel does.

4335.5k1](/packages/albertcht-lumen-testing)

PHPackages © 2026

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