/** * Gets the source code for the specified class. * * @param cfhCompile_Class_Interface $class * @return String * @throws cfhCompile_CodeReader_Exception */ public function getSourceCode(cfhCompile_Class_Interface $class) { $class = $this->plugin->preGetSourceCode($this, $class); $source = $this->read->getSourceCode($class); if (!is_string($source) && !is_null($source)) { throw new cfhCompile_CodeReader_Exception(get_class($this->read) . '->getSourceCode() ' . 'failed to return NULL or a string.'); } return $this->plugin->postGetSourceCode($this, $class, $source); }
public function testPreGetSourceCodeInvalidReturnThrowsException() { $c = new cfhCompile_Class_Reflection($this); $cr = new cfhCompile_CodeReader(); $plugin = $this->getMock('cfhCompile_CodeReader_Plugin_Abstract'); $plugin->expects($this->any())->method('preGetSourceCode'); $b = new cfhCompile_CodeReader_PluginBroker(); $b->attach($plugin); try { $b->preGetSourceCode($cr, $c); } catch (cfhCompile_CodeReader_Plugin_Exception $e) { return; } $this->fail('Expecting to catch cfhCompile_CodeReader_Plugin_Exception.'); }