1 | <?php |
||
17 | * created: 5/11/16 9:31 PM |
||
18 | */ |
||
19 | |||
20 | namespace Youshido\Tests\Library\Type; |
||
21 | |||
22 | use Youshido\GraphQL\Type\NonNullType; |
||
23 | use Youshido\GraphQL\Type\Scalar\StringType; |
||
24 | use Youshido\GraphQL\Type\TypeMap; |
||
25 | use Youshido\GraphQL\Type\TypeService; |
||
26 | |||
27 | class NonNullTypeTest extends \PHPUnit_Framework_TestCase |
||
28 | { |
||
29 | public function testInvalidParams(): void |
||
30 | { |
||
31 | $this->expectException(\Youshido\GraphQL\Exception\ConfigurationException::class); |
||
32 | |||
33 | new NonNullType('invalid param'); |
||
34 | } |
||
35 | |||
36 | public function testNonNullType(): void |
||
37 | { |
||
38 | $stringType = new StringType(); |
||
39 | $nonNullType = new NonNullType(new StringType()); |
||
40 | $nonNullOnString = new NonNullType(TypeMap::TYPE_STRING); |
||
41 | $testArray = ['a' => 'b']; |
||
42 | |||
43 | $this->assertEquals($nonNullType->getName(), null, 'Empty non-null name'); |
||
44 | $this->assertEquals($nonNullType->getKind(), TypeMap::KIND_NON_NULL); |
||
45 | $this->assertEquals($nonNullType->getType(), new NonNullType($stringType)); |
||
46 | $this->assertEquals($nonNullType->getNullableType(), $stringType); |
||
47 | $this->assertEquals($nonNullType->getNullableType(), $nonNullOnString->getNullableType()); |
||
48 | $this->assertEquals($nonNullType->getNamedType(), $stringType); |
||
49 | $this->assertEquals($nonNullType->getTypeOf(), $stringType); |
||
50 | $this->assertEquals($nonNullType->isCompositeType(), true); |
||
51 | $this->assertEquals(TypeService::isAbstractType($nonNullType), false); |
||
52 | $this->assertFalse($nonNullType->isValidValue(null)); |
||
59 |