/** * @test * * @covers Pipedrive\Services\CacheProvider::register */ public function shouldRegisterAppCache() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['app.cache'] = $this->getMock(ArrayCache::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $this->assertInstanceOf(ArrayCache::class, $app['app.cache']); }
/** * @test * * @covers Pipedrive\Services\ValidatorProvider::register */ public function shouldRegisterValidator() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['validator.builder'] = $this->getMock(ValidatorInterface::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $this->assertInstanceOf(ValidatorInterface::class, $app['validator.builder']); }
/** * @test * * @covers Pipedrive\Services\BrokerProvider::register */ public function shouldRegisterBrokerClientProvider() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['broker'] = $this->getMock(Broker::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $this->assertInstanceOf(Broker::class, $app['broker']); }
/** * @test * * @covers Pipedrive\Services\DbProvider::register */ public function shouldRegisterConfiguration() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['annotation.reader.internal'] = $this->getMock(Configuration::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $this->assertInstanceOf(Configuration::class, $app['annotation.reader.internal']); }
/** * @test * * @covers Pipedrive\Services\EventDispatcherProvider::register */ public function shouldRegisterNetworkProvider() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['event.dispatcher'] = $this->getMock(EventDispatcher::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $this->assertInstanceOf(EventDispatcher::class, $app['event.dispatcher']); }
/** * Registers a service provider. * * @param \Silex\ServiceProviderInterface|ServiceProviderInterface $provider * @param array $values * @return Application */ public function registerService($provider, array $values = array()) { $this->providers[] = $provider; $provider->register($this); foreach ($values as $key => $value) { $this[$key] = $value; } return $this; }
/** * @test * * @covers Pipedrive\Services\HttpProvider::register */ public function shouldRegisterNetworkProvider() { $this->serviceProvider->method('register')->willReturnCallback(function (Application $app) { $app['api.pipedrive.client'] = $this->getMock(Client::class, [], [], '', false); }); $app = new Application(); $app->register($this->serviceProvider); $this->assertInstanceOf(Client::class, $app['api.pipedrive.client']); }
/** * Registers a service provider. * * @param \Cilex\ServiceProviderInterface|\Silex\ServiceProviderInterface $provider * A ServiceProviderInterface instance * @param mixed[] $values * An array of values that customizes the provider * * @return void */ public function register($provider, array $values = array()) { if (!$provider instanceof \Cilex\ServiceProviderInterface && !$provider instanceof \Silex\ServiceProviderInterface) { throw new \InvalidArgumentException('Extensions should implement either Cilex or Silex\' ServiceProviderInterface'); } $provider->register($this); foreach ($values as $key => $value) { $this[$key] = $value; } }
/** * Registers a service provider. * * @param ServiceProviderInterface $provider A ServiceProviderInterface instance * @param array $values An array of values that customizes the provider */ public function register(ServiceProviderInterface $provider, array $values = array()) { foreach ($values as $key => $value) { $this[$key] = $value; } $provider->register($this); }
/** * @param ServiceProviderInterface $serviceProvider * @param array $values * @return Application * @throws \RuntimeException If plugin is already loaded */ public function register(ServiceProviderInterface $serviceProvider, array $values = []) { if ($serviceProvider instanceof PluginInterface) { $name = $serviceProvider->getName(); if ($this->hasPlugin($name)) { throw new \RuntimeException(sprintf('Plugin %s is already loaded.', $name)); } $this->plugins[$name] = $serviceProvider; } return parent::register($serviceProvider, $values); }
/** * This will pass all the override parameters into the serviceprovider prior to * creating the instance. This allows service providers to be setup via the additional * array instead of relying on application global state. * @param ServiceProviderInterface $provider * @param array $values * @return $this */ public function registerOverride(ServiceProviderInterface $provider, array $values = array()) { $this->providers[] = $provider; foreach ($values as $key => $value) { $this[$key] = $value; } $provider->register($this); return $this; }