mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 08:26:02 +03:00
97e8a9e200
This is the second step of moving work from type constructors to the schema validation function. ref: graphql/graphql-js#1132
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
namespace GraphQL\Tests\Utils;
|
|
|
|
use GraphQL\Error\Error;
|
|
use GraphQL\Error\InvariantViolation;
|
|
use GraphQL\Utils\Utils;
|
|
|
|
class AssertValidNameTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
// Describe: assertValidName()
|
|
|
|
/**
|
|
* @it throws for use of leading double underscores
|
|
*/
|
|
public function testThrowsForUseOfLeadingDoubleUnderscores()
|
|
{
|
|
$this->setExpectedException(
|
|
Error::class,
|
|
'"__bad" must not begin with "__", which is reserved by GraphQL introspection.'
|
|
);
|
|
Utils::assertValidName('__bad');
|
|
}
|
|
|
|
/**
|
|
* @it throws for non-strings
|
|
*/
|
|
public function testThrowsForNonStrings()
|
|
{
|
|
$this->setExpectedException(
|
|
InvariantViolation::class,
|
|
'Expected string'
|
|
);
|
|
Utils::assertValidName([]);
|
|
}
|
|
|
|
/**
|
|
* @it throws for names with invalid characters
|
|
*/
|
|
public function testThrowsForNamesWithInvalidCharacters()
|
|
{
|
|
$this->setExpectedException(
|
|
Error::class,
|
|
'Names must match'
|
|
);
|
|
Utils::assertValidName('>--()-->');
|
|
}
|
|
}
|