예제 #1
0
 public function testCodeGeneration()
 {
     $outputPath = __DIR__ . '/generated';
     $config = new Config();
     // wsdl document
     $config->setWsdlDocumentPath(__DIR__ . '/resources/service.wsdl');
     // output path
     $config->setOutputPath($outputPath);
     // parameters
     $config->setNamespace('Sapone\\Test\\GeneratedCode');
     $config->setAutoloader(Config::AUTOLOADER_PSR0);
     $config->setSplEnums(true);
     $config->setAccessors(true);
     // generate the code
     $generator = new Generator($config);
     $generator->generate();
     // assert that the generated code is syntactically correct
     foreach (Finder::create()->in($outputPath)->name('*.php')->files() as $file) {
         $process = new Process(sprintf('php -l %s', escapeshellarg($file)));
         $process->run();
         $this->assertTrue($process->isSuccessful());
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $config = new Config();
     $config->setWsdlDocumentPath($input->getArgument('wsdl-path'));
     $config->setOutputPath($input->getArgument('output-path'));
     if ($input->getOption('namespace')) {
         $config->setNamespace($input->getOption('namespace'));
     }
     if ($input->getOption('axis-namespaces')) {
         $config->setAxisNamespaces($input->getOption('axis-namespaces'));
     }
     if ($input->getOption('autoloader')) {
         $config->setAutoloader($input->getOption('autoloader'));
     }
     if ($input->getOption('spl-enums')) {
         $config->setSplEnums(true);
     }
     if ($input->getOption('accessors')) {
         $config->setAccessors(true);
     }
     if ($input->getOption('null-constructor-arguments')) {
         $config->setNullConstructorArguments(true);
     }
     $generator = new Generator($config);
     $generator->getEventDispatcher()->addListener(Event::ENUM_CREATE, function (Event $event) use($output) {
         $output->writeln('<info> * </info>Enum class created: ' . $event->getClassName());
     });
     $generator->getEventDispatcher()->addListener(Event::DTO_CREATE, function (Event $event) use($output) {
         $output->writeln('<info> * </info>Data Transfer Object class created: ' . $event->getClassName());
     });
     $generator->getEventDispatcher()->addListener(Event::SERVICE_CREATE, function (Event $event) use($output) {
         $output->writeln('<info> * </info>Service class created: ' . $event->getClassName());
     });
     $generator->getEventDispatcher()->addListener(Event::CLASSMAP_CREATE, function (Event $event) use($output) {
         $output->writeln('<info> * </info>Classmap class created: ' . $event->getClassName());
     });
     $generator->generate();
 }