/** * test that the source setting only allows Documentors. * * @expectedException RuntimeException * @return void **/ function testSourceSetting() { $analyze = new DocBlockAnalyzer(); $reflection = new ClassDocumentor('TestSubjectOne'); $result = $analyze->setSource($reflection); $this->assertTrue($result); $fail = new StdClass(); $result = $analyze->setSource($fail); $this->assertFalse($result); }
/** * Analyzes Documentation coverage. * Use this method if you are unsure of the contents of an apiClass record, or * don't already have the reflection objects. * * @param array $apiClass An ApiClass record to be analyzed. * @return array Array of warnings / info / % complete * @throws RuntimeException Throws exception if you are looking at a non-concrete class, of if there * was an error with analyzation. **/ public function analyzeCoverage($apiClass) { App::import('Lib', 'ApiGenerator.DocBlockAnalyzer'); $className = $apiClass['ApiClass']['name']; $ApiFile = ClassRegistry::init('ApiFile'); $docsObjects = $ApiFile->loadFile($apiClass['ApiClass']['file_name'], array('useIndex' => true)); if ($apiClass['ApiClass']['flags'] & ApiClass::CONCRETE_CLASS) { $Analyzer = new DocBlockAnalyzer($this->config['coverageRules']); $Analyzer->setSource($docsObjects['class'][$className]); $coverage = $Analyzer->analyze(); $this->id = $apiClass['ApiClass']['id']; $this->saveField('coverage_cache', $coverage['finalScore']); return $coverage; } throw new RuntimeException(sprintf(__d('api_generator', '%s is a pseudo class, and cannot have coverage generated'), $apiClass['ApiClass']['name'])); }