/**
  * @test
  */
 public function hasReturnsResultFromBackend()
 {
     $backend = $this->prepareDefaultBackend();
     $backend->expects($this->once())->method('has')->with($this->equalTo('StringCacheTest'))->will($this->returnValue(true));
     $cache = new StringFrontend('StringFrontend', $backend);
     $this->assertTrue($cache->has('StringCacheTest'), 'has() did not return TRUE.');
 }
Example #2
0
 /**
  * Checks which classes lack a cache entry and removes their reflection data
  * accordingly.
  *
  * @return void
  */
 protected function forgetChangedClasses()
 {
     $frozenNamespaces = [];
     /** @var $package Package */
     foreach ($this->packageManager->getAvailablePackages() as $packageKey => $package) {
         if ($this->packageManager->isPackageFrozen($packageKey)) {
             $frozenNamespaces = array_merge($frozenNamespaces, $package->getNamespaces());
         }
     }
     $frozenNamespaces = array_unique($frozenNamespaces);
     $classNames = array_keys($this->classReflectionData);
     foreach ($frozenNamespaces as $namespace) {
         $namespace .= '\\';
         foreach ($classNames as $index => $className) {
             if (strpos($className, $namespace) === 0) {
                 unset($classNames[$index]);
             }
         }
     }
     foreach ($classNames as $className) {
         if (!$this->statusCache->has($this->produceCacheIdentifierFromClassName($className))) {
             $this->forgetClass($className);
         }
     }
 }