/** * 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 testPostGetSourceCodeEmptySourceStringPassesAndReturnsNull() { $c = new cfhCompile_Class_Reflection($this); $cr = new cfhCompile_CodeReader(); $code = ' '; $plugin = $this->getMock('cfhCompile_CodeReader_Plugin_Abstract'); $plugin->expects($this->any())->method('postGetSourceCode')->with($this->equalTo($cr), $this->equalTo($c), $this->equalTo(NULL))->will($this->returnValue($code)); $b = new cfhCompile_CodeReader_PluginBroker(); $b->attach($plugin); $this->assertNull($b->postGetSourceCode($cr, $c, $code)); }