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()
|
||||
{
|
||||
foreach (self::$_lazyLoadImplementations as $i => &$lazyLoadImplementation) {
|
||||
call_user_func($lazyLoadImplementation);
|
||||
unset(self::$_lazyLoadImplementations[$i]);
|
||||
foreach (self::$_lazyLoadImplementations as $lazyLoadImplementation) {
|
||||
$lazyLoadImplementation();
|
||||
}
|
||||
self::$_lazyLoadImplementations = [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,22 +232,24 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testIncludesInterfacesThunkSubtypesInTheTypeMap()
|
||||
{
|
||||
// includes interfaces' thunk subtypes in the type map
|
||||
$someInterface = new InterfaceType([
|
||||
'name' => 'SomeInterface',
|
||||
'fields' => [
|
||||
'f' => ['type' => Type::int()]
|
||||
]
|
||||
]);
|
||||
$someInterface = null;
|
||||
|
||||
$someSubtype = new ObjectType([
|
||||
'name' => 'SomeSubtype',
|
||||
'fields' => [
|
||||
'f' => ['type' => Type::int()]
|
||||
],
|
||||
'interfaces' => function() use ($someInterface) { return [$someInterface]; },
|
||||
'interfaces' => function() use (&$someInterface) { return [$someInterface]; },
|
||||
'isTypeOf' => function() {return true;}
|
||||
]);
|
||||
|
||||
$someInterface = new InterfaceType([
|
||||
'name' => 'SomeInterface',
|
||||
'fields' => [
|
||||
'f' => ['type' => Type::int()]
|
||||
]
|
||||
]);
|
||||
|
||||
$schema = new Schema(new ObjectType([
|
||||
'name' => 'Query',
|
||||
'fields' => [
|
||||
|
Loading…
x
Reference in New Issue
Block a user