mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
namespace GraphQL\Tests\Validator;
|
|
|
|
use GraphQL\Validator\DocumentValidator;
|
|
use GraphQL\Validator\Rules\QueryComplexity;
|
|
|
|
class ValidationTest extends TestCase
|
|
{
|
|
// Validate: Supports full validation
|
|
|
|
/**
|
|
* @it validates queries
|
|
*/
|
|
public function testValidatesQueries()
|
|
{
|
|
$this->expectPassesCompleteValidation('
|
|
query {
|
|
catOrDog {
|
|
... on Cat {
|
|
furColor
|
|
}
|
|
... on Dog {
|
|
isHousetrained
|
|
}
|
|
}
|
|
}
|
|
');
|
|
}
|
|
/*
|
|
public function testAllowsSettingRulesGlobally()
|
|
{
|
|
$rule = new QueryComplexity(0);
|
|
|
|
DocumentValidator::addRule($rule);
|
|
$instance = DocumentValidator::getRule(QueryComplexity::class);
|
|
$this->assertSame($rule, $instance);
|
|
}
|
|
*/
|
|
public function testPassesValidationWithEmptyRules()
|
|
{
|
|
$query = '{invalid}';
|
|
|
|
$expectedError = [
|
|
'message' => 'Cannot query field "invalid" on type "QueryRoot".',
|
|
'locations' => [ ['line' => 1, 'column' => 2] ]
|
|
];
|
|
$this->expectFailsCompleteValidation($query, [$expectedError]);
|
|
$this->expectValid($this->getDefaultSchema(), [], $query);
|
|
}
|
|
}
|