Skip to content

Commit cf39706

Browse files
committed
Improved tests
1 parent f327ada commit cf39706

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/Unit/TokenizerTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,21 @@ public function simpleDataProvider() : array
458458
new \Graphpinator\Tokenizer\Token(TokenType::EQUAL, new \Graphpinator\Common\Location(1, 1)),
459459
],
460460
],
461+
[
462+
'schema SCHEMA type interface union input enum scalar implements repeatable',
463+
[
464+
new \Graphpinator\Tokenizer\Token(TokenType::SCHEMA, new \Graphpinator\Common\Location(1, 1)),
465+
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 8), 'SCHEMA'),
466+
new \Graphpinator\Tokenizer\Token(TokenType::TYPE, new \Graphpinator\Common\Location(1, 15)),
467+
new \Graphpinator\Tokenizer\Token(TokenType::INTERFACE, new \Graphpinator\Common\Location(1, 20)),
468+
new \Graphpinator\Tokenizer\Token(TokenType::UNION, new \Graphpinator\Common\Location(1, 30)),
469+
new \Graphpinator\Tokenizer\Token(TokenType::INPUT, new \Graphpinator\Common\Location(1, 36)),
470+
new \Graphpinator\Tokenizer\Token(TokenType::ENUM, new \Graphpinator\Common\Location(1, 42)),
471+
new \Graphpinator\Tokenizer\Token(TokenType::SCALAR, new \Graphpinator\Common\Location(1, 47)),
472+
new \Graphpinator\Tokenizer\Token(TokenType::IMPLEMENTS, new \Graphpinator\Common\Location(1, 54)),
473+
new \Graphpinator\Tokenizer\Token(TokenType::REPEATABLE, new \Graphpinator\Common\Location(1, 65)),
474+
],
475+
],
461476
];
462477
}
463478

@@ -560,6 +575,40 @@ public function testSkip(string $source, array $tokens) : void
560575
}
561576
}
562577

578+
public function noKeywordsDataProvider() : array
579+
{
580+
return [
581+
[
582+
'... type fragment',
583+
[
584+
new \Graphpinator\Tokenizer\Token(TokenType::ELLIP, new \Graphpinator\Common\Location(1, 1)),
585+
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 5), 'type'),
586+
new \Graphpinator\Tokenizer\Token(TokenType::NAME, new \Graphpinator\Common\Location(1, 10), 'fragment'),
587+
],
588+
],
589+
];
590+
}
591+
592+
/**
593+
* @dataProvider noKeywordsDataProvider
594+
* @param string $source
595+
* @param array $tokens
596+
*/
597+
public function testNoKeywords(string $source, array $tokens) : void
598+
{
599+
$source = new \Graphpinator\Source\StringSource($source);
600+
$tokenizer = new \Graphpinator\Tokenizer\Tokenizer($source, true, false);
601+
$index = 0;
602+
603+
foreach ($tokenizer as $token) {
604+
self::assertSame($tokens[$index]->getType(), $token->getType());
605+
self::assertSame($tokens[$index]->getValue(), $token->getValue());
606+
self::assertSame($tokens[$index]->getLocation()->getLine(), $token->getLocation()->getLine());
607+
self::assertSame($tokens[$index]->getLocation()->getColumn(), $token->getLocation()->getColumn());
608+
++$index;
609+
}
610+
}
611+
563612
public function invalidDataProvider() : array
564613
{
565614
return [

0 commit comments

Comments
 (0)