/** * Creates a new FileReflector for the given filename or null if the file contains no modifications. * * @param ProjectDescriptorBuilder $builder * @param string $filename * * @return FileReflector|null Returns a new FileReflector or null if no modifications were detected for the given * filename. */ protected function createFileReflector(ProjectDescriptorBuilder $builder, $filename) { $file = new FileReflector($filename, $this->parser->doValidation(), $this->parser->getEncoding()); $file->setDefaultPackageName($this->parser->getDefaultPackageName()); $file->setMarkers($this->parser->getMarkers()); $file->setFilename($this->getRelativeFilename($filename)); $cachedFiles = $builder->getProjectDescriptor()->getFiles(); $hash = $cachedFiles->get($file->getFilename()) ? $cachedFiles->get($file->getFilename())->getHash() : null; return $hash === $file->getHash() && !$this->parser->isForced() ? null : $file; }
public function testForced() { // defaults to false $this->assertEquals(false, $this->fixture->isForced()); $xml = new \SimpleXMLElement('<project></project>'); $xml->addAttribute('version', \phpDocumentor\Application::VERSION); $this->fixture->setExistingXml($xml->asXML()); $this->assertEquals(false, $this->fixture->isForced()); // if version differs, we force a rebuild $xml['version'] = \phpDocumentor\Application::VERSION . 'a'; $this->fixture->setExistingXml($xml->asXML()); $this->assertEquals(true, $this->fixture->isForced()); // switching back should undo the force $xml['version'] = \phpDocumentor\Application::VERSION; $this->fixture->setExistingXml($xml->asXML()); $this->assertEquals(false, $this->fixture->isForced()); // manually setting forced should result in a force $this->fixture->setForced(true); $this->assertEquals(true, $this->fixture->isForced()); $this->fixture->setForced(false); $this->assertEquals(false, $this->fixture->isForced()); }
/** * @covers phpDocumentor\Parser\Parser::setForced * @covers phpDocumentor\Parser\Parser::isForced */ public function testSetAndCheckWhetherParsingIsForced() { $this->assertEquals(false, $this->fixture->isForced()); $this->fixture->setForced(true); $this->assertEquals(true, $this->fixture->isForced()); }