private function applyCacheAdvice(Provider $provider, CacheAdvice $cacheAdvice) { try { if (!$provider instanceof CacheToggle) { throw CacheUnavailableException::modify(); } switch ("{$cacheAdvice}") { case CacheAdvice::MUST_CACHE: case CacheAdvice::SHOULD_CACHE: $provider->enableCache(); break; case CacheAdvice::MUST_NOT_CACHE: case CacheAdvice::SHOULD_NOT_CACHE: $provider->disableCache(); } } catch (CacheUnavailableException $exception) { if ($cacheAdvice === CacheAdvice::MUST_NOT_CACHE() || $cacheAdvice === CacheAdvice::MUST_CACHE()) { throw $exception; } } }
public function testCacheUnavailable() { $this->setExpectedException(CacheUnavailableException::class); $this->porter->import($this->specification->setCacheAdvice(CacheAdvice::MUST_CACHE())); }
public function testCacheAdvice() { self::assertSame($advice = CacheAdvice::MUST_CACHE(), $this->specification->setCacheAdvice($advice)->getCacheAdvice()); }