|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types = 1); |
| 4 | + |
| 5 | +namespace Graphpinator\Parser\Tests\Unit\TypeRef; |
| 6 | + |
| 7 | +use Graphpinator\Parser\TypeRef\ListTypeRef; |
| 8 | +use Graphpinator\Parser\TypeRef\NamedTypeRef; |
| 9 | +use Graphpinator\Parser\TypeRef\NotNullRef; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +final class TypeRefTest extends TestCase |
| 13 | +{ |
| 14 | + public function testNamedTypeRefPrint() : void |
| 15 | + { |
| 16 | + $typeRef = new NamedTypeRef('String'); |
| 17 | + |
| 18 | + self::assertSame('String', $typeRef->print()); |
| 19 | + } |
| 20 | + |
| 21 | + public function testNotNullRefPrint() : void |
| 22 | + { |
| 23 | + $innerRef = new NamedTypeRef('Int'); |
| 24 | + $typeRef = new NotNullRef($innerRef); |
| 25 | + |
| 26 | + self::assertSame('Int!', $typeRef->print()); |
| 27 | + } |
| 28 | + |
| 29 | + public function testListTypeRefPrint() : void |
| 30 | + { |
| 31 | + $innerRef = new NamedTypeRef('String'); |
| 32 | + $typeRef = new ListTypeRef($innerRef); |
| 33 | + |
| 34 | + self::assertSame('[String]', $typeRef->print()); |
| 35 | + } |
| 36 | + |
| 37 | + public function testComplexTypeRefPrint() : void |
| 38 | + { |
| 39 | + $namedRef = new NamedTypeRef('Int'); |
| 40 | + $notNullRef = new NotNullRef($namedRef); |
| 41 | + $listRef = new ListTypeRef($notNullRef); |
| 42 | + $outerNotNullRef = new NotNullRef($listRef); |
| 43 | + |
| 44 | + self::assertSame('[Int!]!', $outerNotNullRef->print()); |
| 45 | + } |
| 46 | + |
| 47 | + public function testNestedListTypeRefPrint() : void |
| 48 | + { |
| 49 | + $namedRef = new NamedTypeRef('String'); |
| 50 | + $innerListRef = new ListTypeRef($namedRef); |
| 51 | + $outerListRef = new ListTypeRef($innerListRef); |
| 52 | + |
| 53 | + self::assertSame('[[String]]', $outerListRef->print()); |
| 54 | + } |
| 55 | +} |
0 commit comments