Test for lazy interface initialization + minor related tweak

This commit is contained in:
vladar 2016-04-20 18:04:11 +06:00
parent 0a0c8181ea
commit 4d024ee85e
2 changed files with 12 additions and 10 deletions

View File

@ -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 = [];
}
/**

View File

@ -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' => [