示例#1
0
 /**
  * @param ResourceInterface $resource
  * @param array             $data
  */
 public function generate(ResourceInterface $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(ResourceInterface $resource, ExecutionContextInterface $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();
 }