/** * @covers phpDocumentor\Descriptor\ProjectDescriptor::__construct * @covers phpDocumentor\Descriptor\ProjectDescriptor::setSettings * @covers phpDocumentor\Descriptor\ProjectDescriptor::getSettings */ public function testGetSetSettings() { $this->assertInstanceOf('phpDocumentor\\Descriptor\\ProjectDescriptor\\Settings', $this->fixture->getSettings()); $settings = new Settings(); $this->fixture->setSettings($settings); $this->assertSame($settings, $this->fixture->getSettings()); }
/** * Stores a Project Descriptor in the Cache. * * @param ProjectDescriptor $projectDescriptor * * @return void */ public function save(ProjectDescriptor $projectDescriptor) { $keys = array(); $cache = $this->getCache(); /** @var IteratorInterface $iteratorInterface */ $iteratorInterface = $cache->getIterator(); // FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154 if ($iteratorInterface->valid()) { foreach ($cache as $key) { $keys[] = $key; } } // store the settings for this Project Descriptor $cache->setItem(self::KEY_SETTINGS, $projectDescriptor->getSettings()); // store cache items $usedKeys = array(); foreach ($projectDescriptor->getFiles() as $file) { $key = self::FILE_PREFIX . md5($file->getPath()); $usedKeys[] = $key; $cache->setItem($key, $file); } // remove any keys that are no longer used. $invalidatedKeys = array_diff($keys, $usedKeys); if ($invalidatedKeys) { $cache->removeItems($invalidatedKeys); } if ($cache instanceof OptimizableInterface) { $cache->optimize(); } }
/** * @covers phpDocumentor\Descriptor\ProjectDescriptorBuilder::isVisibilityAllowed */ public function testDeterminesWhetherASpecificVisibilityIsAllowedToBeIncluded() { $projectDescriptorName = 'My Descriptor'; $projectDescriptorMock = new ProjectDescriptor($projectDescriptorName); $projectDescriptorMock->getSettings()->setVisibility(Settings::VISIBILITY_PUBLIC); $this->fixture->setProjectDescriptor($projectDescriptorMock); $this->assertTrue($this->fixture->isVisibilityAllowed(Settings::VISIBILITY_PUBLIC)); $this->assertFalse($this->fixture->isVisibilityAllowed(Settings::VISIBILITY_PRIVATE)); }