Source of file ArrayTypeParserTest.php
Size: 1,804 Bytes - Last Modified: 2021-12-23T10:31:47+00:00
/var/www/docs.ssmods.com/process/src/tests/Scaffolding/Util/ArrayTypeParserTest.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | <?php namespace SilverStripe\GraphQL\Tests\Scaffolding\Util; use GraphQL\Type\Definition\FieldDefinition; use GraphQL\Type\Definition\IntType; use GraphQL\Type\Definition\ObjectType; use GraphQL\Type\Definition\StringType; use InvalidArgumentException; use SilverStripe\Dev\SapphireTest; use SilverStripe\GraphQL\Scaffolding\Util\ArrayTypeParser; /** * @skipUpgrade */ class ArrayTypeParserTest extends SapphireTest { public function testConstructor() { $parser = new ArrayTypeParser('test', ['test' => 'String']); $this->assertEquals('test', $parser->getType()->name); } public function testGetType() { $parser = new ArrayTypeParser('test', [ 'FieldOne' => 'String', 'FieldTwo' => 'Int' ]); $type = $parser->getType(); $this->assertInstanceOf(ObjectType::class, $type); $this->assertInstanceOf(FieldDefinition::class, $type->getField('FieldOne')); $this->assertInstanceOf(FieldDefinition::class, $type->getField('FieldTwo')); $this->assertInstanceOf(StringType::class, $type->getField('FieldOne')->getType()); $this->assertInstanceOf(IntType::class, $type->getField('FieldTwo')->getType()); } public function testInvalidConstructorNotArray() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/second parameter must be an associative array/'); new ArrayTypeParser('test', 'String'); } public function testInvalidConstructorNotAssociative() { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessageMatches('/second parameter must be an associative array/'); new ArrayTypeParser('test', ['oranges', 'apples']); } } |