mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Test for lazy interface initialization + minor related tweak
This commit is contained in:
parent
0a0c8181ea
commit
4d024ee85e
@ -60,10 +60,10 @@ class InterfaceType extends Type implements AbstractType, OutputType, CompositeT
|
|||||||
*/
|
*/
|
||||||
public static function loadImplementationToInterfaces()
|
public static function loadImplementationToInterfaces()
|
||||||
{
|
{
|
||||||
foreach (self::$_lazyLoadImplementations as $i => &$lazyLoadImplementation) {
|
foreach (self::$_lazyLoadImplementations as $lazyLoadImplementation) {
|
||||||
call_user_func($lazyLoadImplementation);
|
$lazyLoadImplementation();
|
||||||
unset(self::$_lazyLoadImplementations[$i]);
|
|
||||||
}
|
}
|
||||||
|
self::$_lazyLoadImplementations = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,22 +232,24 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testIncludesInterfacesThunkSubtypesInTheTypeMap()
|
public function testIncludesInterfacesThunkSubtypesInTheTypeMap()
|
||||||
{
|
{
|
||||||
// includes interfaces' thunk subtypes in the type map
|
// includes interfaces' thunk subtypes in the type map
|
||||||
$someInterface = new InterfaceType([
|
$someInterface = null;
|
||||||
'name' => 'SomeInterface',
|
|
||||||
'fields' => [
|
|
||||||
'f' => ['type' => Type::int()]
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
$someSubtype = new ObjectType([
|
$someSubtype = new ObjectType([
|
||||||
'name' => 'SomeSubtype',
|
'name' => 'SomeSubtype',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'f' => ['type' => Type::int()]
|
'f' => ['type' => Type::int()]
|
||||||
],
|
],
|
||||||
'interfaces' => function() use ($someInterface) { return [$someInterface]; },
|
'interfaces' => function() use (&$someInterface) { return [$someInterface]; },
|
||||||
'isTypeOf' => function() {return true;}
|
'isTypeOf' => function() {return true;}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$someInterface = new InterfaceType([
|
||||||
|
'name' => 'SomeInterface',
|
||||||
|
'fields' => [
|
||||||
|
'f' => ['type' => Type::int()]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
$schema = new Schema(new ObjectType([
|
$schema = new Schema(new ObjectType([
|
||||||
'name' => 'Query',
|
'name' => 'Query',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user