1. Go to this page and download the library: Download kunicmarko/graphql-test library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kunicmarko / graphql-test example snippets
use KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
use KunicMarko\GraphQLTest\Bridge\Lumen\TestCase;
use KunicMarko\GraphQLTest\Bridge\Laravel\TestCase;
public function query(QueryInterface $query, array $files = [], array $headers = []);
public function mutation(MutationInterface $mutation, array $files = [], array $headers = [])
use KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
class UserTest extends TestCase
{
public static $endpoint = '/';
}
use KunicMarko\GraphQLTest\Bridge\Symfony\TestCase;
class SettingsTest extends TestCase
{
protected function setUp()
{
$this->setDefaultHeaders([
'Content-Type' => 'application/json',
]);
}
}
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
}
}
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
}
}
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
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.