/** * @param Resource $resource * @param array $data */ public function generate(Resource $resource, array $data = array()) { $filepath = $this->getFilePath($resource); if ($this->fileAlreadyExists($filepath)) { if ($this->userAborts($filepath)) { return; } $this->io->writeln(); } $this->createDirectoryIfItDoesExist($filepath); $this->generateFileAndRenderTemplate($resource, $filepath); $this->executionContext->addGeneratedType($resource->getSrcClassname()); }
function it_records_that_class_was_created_in_executioncontext(Resource $resource, ExecutionContext $executionContext) { $resource->getName()->willReturn('App'); $resource->getSrcFilename()->willReturn('/project/src/Acme/App.php'); $resource->getSrcNamespace()->willReturn('Acme'); $resource->getSrcClassname()->willReturn('Acme\\App'); $this->generate($resource); $executionContext->addGeneratedType('Acme\\App')->shouldHaveBeenCalled(); }