public function registerProvider(Provider $provider, $tag = null) { if ($this->hasProvider($name = get_class($provider), $tag)) { throw new ProviderAlreadyRegisteredException("Provider already registered: \"{$name}\" with tag \"{$tag}\"."); } $this->providers[$this->hashProviderName($name, $tag)] = $provider; return $this; }
public function testApplyCacheAdvice() { $this->porter->registerProvider($provider = \Mockery::mock(implode(',', [Provider::class, CacheToggle::class]))->shouldReceive('fetch')->andReturn(new \EmptyIterator())->shouldReceive('disableCache')->once()->shouldReceive('enableCache')->once()->getMock()); $this->porter->import($specification = new ImportSpecification(MockFactory::mockResource($provider))); $this->porter->import($specification->setCacheAdvice(CacheAdvice::SHOULD_CACHE())); }