/** * Generation template method * * @return bool */ public function generate() { try { if ($this->_validateData()) { $sourceCode = $this->_generateCode(); if ($sourceCode) { $fileName = $this->_ioObject->getResultFileName($this->_getResultClassName()); $this->_ioObject->writeResultFile($fileName, $sourceCode); return true; } else { $this->_addError('Can\'t generate source code.'); } } } catch (Exception $e) { $this->_addError($e->getMessage()); } return false; }
public function testWriteResultFile() { $this->_ioObjectMock->expects($this->once())->method('write')->with($this->equalTo(self::FILE_NAME), $this->equalTo("<?php\n" . self::FILE_CONTENT))->will($this->returnValue(true)); $this->assertTrue($this->_object->writeResultFile(self::FILE_NAME, self::FILE_CONTENT)); }