-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix QueryScaffolder not using inheritance types
- Loading branch information
Aaron Carlino
committed
Aug 7, 2018
1 parent
e84947b
commit e9de436
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace SilverStripe\GraphQL\Tests\Scaffolders\Scaffolding; | ||
|
||
use GraphQL\Type\Definition\ObjectType; | ||
use GraphQL\Type\Definition\Type; | ||
use GraphQL\Type\Definition\UnionType; | ||
use SilverStripe\Dev\SapphireTest; | ||
use SilverStripe\GraphQL\Manager; | ||
use SilverStripe\GraphQL\Scaffolding\Scaffolders\ItemQueryScaffolder; | ||
use SilverStripe\GraphQL\Scaffolding\Scaffolders\SchemaScaffolder; | ||
use SilverStripe\GraphQL\Scaffolding\StaticSchema; | ||
use SilverStripe\GraphQL\Tests\Fake\FakePage; | ||
use SilverStripe\GraphQL\Tests\Fake\FakeRedirectorPage; | ||
|
||
class QueryScaffolderTest extends SapphireTest | ||
{ | ||
public function testInheritedTypes() | ||
{ | ||
$scaffolder = new SchemaScaffolder(); | ||
$scaffolder | ||
->type(FakeRedirectorPage::class); | ||
$scaffolder->addToManager($manager = new Manager()); | ||
$manager->addType(new ObjectType([ | ||
'name' => 'CustomTypeName', | ||
'fields' => [ | ||
'Test' => Type::string(), | ||
] | ||
])); | ||
$query = new ItemQueryScaffolder(null, 'CustomTypeName', null, FakePage::class); | ||
$result = $query->scaffold($manager); | ||
$type = $result['type']; | ||
$this->assertInstanceOf(ObjectType::class, $type); | ||
$this->assertEquals('CustomTypeName', $type->config['name']); | ||
|
||
$query = new ItemQueryScaffolder(null, null, null, FakePage::class); | ||
$result = $query->scaffold($manager); | ||
$type = $result['type']; | ||
$this->assertInstanceOf(UnionType::class, $type); | ||
$this->assertEquals( | ||
StaticSchema::inst()->inheritanceTypeNameForDataObject(FakePage::class), | ||
$type->config['name'] | ||
); | ||
} | ||
} |