public static function getProvider($type, $accessToken) { try { $namePart = implode(array_map('ucfirst', explode('_', $type))); $className = 'LibCloud\\Compute\\Providers\\' . $namePart . '\\' . $namePart . 'Provider'; return new $className($accessToken); } catch (\Exception $e) { throw new \Exception(sprintf("Class for '%s' not found", $type)); } }
public function setUp() { $this->provider = ComputeFactory::getProvider('rackspace', 'testuser:some_api_key'); # parent test case needs this before addMockSubscriber is called $this->client = $this->provider->getClient(); # initial call to getService will perform authentication $this->addMockSubscriber($this->getTestFilePath('Auth')); $this->addMockSubscriber($this->getTestFilePath('Extensions')); $this->provider->getService(); }