2015-07-15 20:05:46 +03:00
|
|
|
<?php
|
2018-09-02 14:08:49 +03:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-04-09 10:36:53 +03:00
|
|
|
namespace GraphQL\Tests\Validator;
|
2015-07-15 20:05:46 +03:00
|
|
|
|
2016-10-21 12:39:57 +03:00
|
|
|
use GraphQL\Error\FormattedError;
|
2015-07-15 20:05:46 +03:00
|
|
|
use GraphQL\Language\SourceLocation;
|
|
|
|
use GraphQL\Validator\Rules\VariablesInAllowedPosition;
|
|
|
|
|
2018-07-29 18:43:10 +03:00
|
|
|
class VariablesInAllowedPositionTest extends ValidatorTestCase
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Validate: Variables are in allowed positions
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean => Boolean')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanXBoolean() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Boolean => Boolean
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($booleanArg: Boolean)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
booleanArgField(booleanArg: $booleanArg)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean => Boolean within fragment')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanXBooleanWithinFragment() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Boolean => Boolean within fragment
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
fragment booleanArgFrag on ComplicatedArgs {
|
|
|
|
booleanArgField(booleanArg: $booleanArg)
|
|
|
|
}
|
|
|
|
query Query($booleanArg: Boolean)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
...booleanArgFrag
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($booleanArg: Boolean)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
...booleanArgFrag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fragment booleanArgFrag on ComplicatedArgs {
|
|
|
|
booleanArgField(booleanArg: $booleanArg)
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean! => Boolean')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanNonNullXBoolean() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Boolean! => Boolean
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($nonNullBooleanArg: Boolean!)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
booleanArgField(booleanArg: $nonNullBooleanArg)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean! => Boolean within fragment')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanNonNullXBooleanWithinFragment() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Boolean! => Boolean within fragment
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
fragment booleanArgFrag on ComplicatedArgs {
|
|
|
|
booleanArgField(booleanArg: $nonNullBooleanArg)
|
|
|
|
}
|
|
|
|
|
|
|
|
query Query($nonNullBooleanArg: Boolean!)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
...booleanArgFrag
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Int => Int! with default')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testIntXIntNonNullWithDefault() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Int => Int! with default
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($intArg: Int = 1)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
nonNullIntArgField(nonNullIntArg: $intArg)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('[String] => [String]')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testListOfStringXListOfString() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($stringListVar: [String])
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
stringListArgField(stringListArg: $stringListVar)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('[String!] => [String]')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testListOfStringNonNullXListOfString() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($stringListVar: [String!])
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
stringListArgField(stringListArg: $stringListVar)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('String => [String] in item position')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testStringXListOfStringInItemPosition() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($stringVar: String)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
stringListArgField(stringListArg: [$stringVar])
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('String! => [String] in item position')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testStringNonNullXListOfStringInItemPosition() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($stringVar: String!)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
stringListArgField(stringListArg: [$stringVar])
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('ComplexInput => ComplexInput')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testComplexInputXComplexInput() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($complexVar: ComplexInput)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
complexArgField(complexArg: $ComplexInput)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('ComplexInput => ComplexInput in field position')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testComplexInputXComplexInputInFieldPosition() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($boolVar: Boolean = false)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
complexArgField(complexArg: {requiredArg: $boolVar})
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean! => Boolean! in directive')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanNonNullXBooleanNonNullInDirective() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($boolVar: Boolean!)
|
|
|
|
{
|
2015-08-17 17:01:55 +03:00
|
|
|
dog @include(if: $boolVar)
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean => Boolean! in directive with default')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanXBooleanNonNullInDirectiveWithDefault() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectPassesRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
query Query($boolVar: Boolean = false)
|
|
|
|
{
|
2015-08-17 17:01:55 +03:00
|
|
|
dog @include(if: $boolVar)
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
'
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Int => Int!')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testIntXIntNonNull() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2016-04-25 16:29:17 +03:00
|
|
|
query Query($intArg: Int) {
|
2015-07-15 20:05:46 +03:00
|
|
|
complicatedArgs {
|
|
|
|
nonNullIntArgField(nonNullIntArg: $intArg)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('intArg', 'Int', 'Int!'),
|
|
|
|
[new SourceLocation(2, 19), new SourceLocation(4, 45)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Int => Int! within fragment')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testIntXIntNonNullWithinFragment() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
fragment nonNullIntArgFieldFrag on ComplicatedArgs {
|
|
|
|
nonNullIntArgField(nonNullIntArg: $intArg)
|
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
query Query($intArg: Int) {
|
2015-07-15 20:05:46 +03:00
|
|
|
complicatedArgs {
|
|
|
|
...nonNullIntArgFieldFrag
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('intArg', 'Int', 'Int!'),
|
|
|
|
[new SourceLocation(6, 19), new SourceLocation(3, 43)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Int => Int! within nested fragment')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testIntXIntNonNullWithinNestedFragment() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// Int => Int! within nested fragment
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2015-07-15 20:05:46 +03:00
|
|
|
fragment outerFrag on ComplicatedArgs {
|
|
|
|
...nonNullIntArgFieldFrag
|
|
|
|
}
|
|
|
|
|
|
|
|
fragment nonNullIntArgFieldFrag on ComplicatedArgs {
|
|
|
|
nonNullIntArgField(nonNullIntArg: $intArg)
|
|
|
|
}
|
|
|
|
|
|
|
|
query Query($intArg: Int)
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
...outerFrag
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('intArg', 'Int', 'Int!'),
|
|
|
|
[new SourceLocation(10, 19), new SourceLocation(7, 43)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('String over Boolean')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testStringOverBoolean() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2016-04-25 16:29:17 +03:00
|
|
|
query Query($stringVar: String) {
|
2015-07-15 20:05:46 +03:00
|
|
|
complicatedArgs {
|
|
|
|
booleanArgField(booleanArg: $stringVar)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('stringVar', 'String', 'Boolean'),
|
|
|
|
[new SourceLocation(2, 19), new SourceLocation(4, 39)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('String => [String]')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testStringXListOfString() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2016-04-25 16:29:17 +03:00
|
|
|
query Query($stringVar: String) {
|
2015-07-15 20:05:46 +03:00
|
|
|
complicatedArgs {
|
|
|
|
stringListArgField(stringListArg: $stringVar)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('stringVar', 'String', '[String]'),
|
|
|
|
[new SourceLocation(2, 19), new SourceLocation(4, 45)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('Boolean => Boolean! in directive')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testBooleanXBooleanNonNullInDirective() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2016-04-25 16:29:17 +03:00
|
|
|
query Query($boolVar: Boolean) {
|
2015-08-17 17:01:55 +03:00
|
|
|
dog @include(if: $boolVar)
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('boolVar', 'Boolean', 'Boolean!'),
|
|
|
|
[new SourceLocation(2, 19), new SourceLocation(3, 26)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2016-04-25 16:29:17 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('String => Boolean! in directive')
|
2016-04-25 16:29:17 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testStringXBooleanNonNullInDirective() : void
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
// String => Boolean! in directive
|
2018-09-02 14:08:49 +03:00
|
|
|
$this->expectFailsRule(
|
|
|
|
new VariablesInAllowedPosition(),
|
|
|
|
'
|
2016-04-25 16:29:17 +03:00
|
|
|
query Query($stringVar: String) {
|
2015-08-17 17:01:55 +03:00
|
|
|
dog @include(if: $stringVar)
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('stringVar', 'String', 'Boolean!'),
|
|
|
|
[new SourceLocation(2, 19), new SourceLocation(3, 26)]
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|
|
|
|
|
2018-08-22 13:55:42 +03:00
|
|
|
/**
|
2018-08-31 11:55:14 +03:00
|
|
|
* @see it('[String] => [String!]')
|
2018-08-22 13:55:42 +03:00
|
|
|
*/
|
2018-08-31 12:07:29 +03:00
|
|
|
public function testStringArrayXStringNonNullArray() : void
|
2018-08-22 13:55:42 +03:00
|
|
|
{
|
|
|
|
$this->expectFailsRule(
|
2018-09-02 14:08:49 +03:00
|
|
|
new VariablesInAllowedPosition(),
|
2018-08-22 13:55:42 +03:00
|
|
|
'
|
|
|
|
query Query($stringListVar: [String])
|
|
|
|
{
|
|
|
|
complicatedArgs {
|
|
|
|
stringListNonNullArgField(stringListNonNullArg: $stringListVar)
|
|
|
|
}
|
|
|
|
}
|
2018-09-02 14:08:49 +03:00
|
|
|
',
|
|
|
|
[
|
2018-08-22 13:55:42 +03:00
|
|
|
FormattedError::create(
|
|
|
|
VariablesInAllowedPosition::badVarPosMessage('stringListVar', '[String]', '[String!]'),
|
|
|
|
[new SourceLocation(2, 19), new SourceLocation(5, 59)]
|
2018-09-02 14:08:49 +03:00
|
|
|
),
|
2018-08-22 13:55:42 +03:00
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
2015-07-15 20:05:46 +03:00
|
|
|
}
|