getFunctionMock('Thrift\ClassLoader', 'apcu_fetch') ->expects($useApcu ? $this->any() : $this->never()) ->with($apcuPrefix . $class) ->willReturn(false); $this->getFunctionMock('Thrift\ClassLoader', 'apcu_store') ->expects($useApcu ? $this->any() : $this->never()) ->with($apcuPrefix . $class, $this->anything()) ->willReturn(true); $loader = new ThriftClassLoader($useApcu, $apcuPrefix); foreach ($definitions as $namespace => $paths) { $loader->registerDefinition($namespace, $paths); } $loader->register(); $loader->loadClass($class); if ($checkInterfaceExist) { $this->assertTrue(interface_exists($class, false), "->loadClass() loads '$class'"); } else { $this->assertTrue(class_exists($class, false), "->loadClass() loads '$class'"); } } public function registerDefinitionDataProvider() { yield 'loadType' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => 'Classmap\ThriftTest\Xtruct', ]; yield 'loadInterface' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => '\Classmap\ThriftTest\ThriftTestIf', 'checkInterfaceExist' => true, ]; yield 'loadClient' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => '\Classmap\ThriftTest\ThriftTestClient', ]; yield 'loadProcessor' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => '\Classmap\ThriftTest\ThriftTestProcessor', ]; yield 'loadRest' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => '\Classmap\ThriftTest\ThriftTestRest', ]; yield 'load_args' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => '\Classmap\ThriftTest\ThriftTest_testVoid_args', ]; yield 'load_result' => [ 'definitions' => [ 'Classmap' => __DIR__ . '/../../../Resources/packages/phpcm', ], 'class' => '\Classmap\ThriftTest\ThriftTest_testVoid_result', ]; yield 'pathAsArray' => [ 'definitions' => [ 'Classmap' => [__DIR__ . '/../../../Resources/packages/phpcm'], ], 'class' => 'Classmap\ThriftTest\Xtruct', ]; yield 'severalDefinitions' => [ 'definitions' => [ 'Classmap\ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], 'Classmap\TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], ], 'class' => '\Classmap\TestValidators\TestServiceClient', ]; yield 'useApcu' => [ 'definitions' => [ 'Classmap\ThriftTest' => [__DIR__ . '/../../../Resources/packages/phpcm'], 'Classmap\TestValidators' => [__DIR__ . '/../../../Resources/packages/phpcm'], ], 'class' => '\Classmap\TestValidators\TestServiceClient', 'checkInterfaceExist' => false, 'useApcu' => true, 'apcuPrefix' => 'APCU_PREFIX', ]; } }