public function append() { if ($this->controllerGenerator) { $controllerPath = $this->controllerGenerator->getControllerPath(); $controllerContents = $this->controllerGenerator->getControllerContents(); $actionContents = $this->actionGenerator->templateContents(); $controllerContents = preg_replace('/}\\s*$/', $actionContents . PHP_EOL . '}' . PHP_EOL, $controllerContents); file_put_contents($controllerPath, $controllerContents); } if ($this->viewGenerator) { file_put_contents(Path::join($this->viewGenerator->getViewPath(), $this->actionGenerator->getActionViewFile()), PHP_EOL); } return true; }
/** * @test */ public function shouldReturnReplacedTemplateContents() { //given $actionGenerator = new ActionGenerator('index'); //when $templateContents = $actionGenerator->templateContents(); //then Assert::thatString($templateContents)->contains('public function index'); }