Example #1
0
 /**
  * @test
  */
 function it_should_know_all_WSDL_functions()
 {
     $known = [new PhproSoapFunction('GetWeatherInformation', ['$parameters' => 'GetWeatherInformation'], 'GetWeatherInformationResponse'), new PhproSoapFunction('GetCityForecastByZIP', ['$parameters' => 'GetCityForecastByZIP'], 'GetCityForecastByZIPResponse'), new PhproSoapFunction('GetCityWeatherByZIP', ['$parameters' => 'GetCityWeatherByZIP'], 'GetCityWeatherByZIPResponse')];
     $functions = $this->client->getSoapFunctions();
     $this->assertCount(3, $functions);
     foreach ($known as $function) {
         $this->assertContains($function, $functions, null, false, false);
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $destination = rtrim($input->getArgument('destination'), '/\\');
     if (!$this->filesystem->dirextoryExists($destination)) {
         throw new RunTimeException(sprintf('The destination %s does not exist.', $destination));
     }
     $wsdl = $input->getOption('wsdl');
     if (!$wsdl) {
         throw new RuntimeException('You MUST specify a WSDL endpoint.');
     }
     $namespace = $input->getOption('namespace');
     $soapClient = new SoapClient($wsdl, []);
     $types = $soapClient->getSoapTypes();
     $functions = $soapClient->getSoapFunctions();
     $generator = new TypeGenerator($namespace);
     foreach ($types as $type => $properties) {
         // Check if file exists:
         $file = sprintf('%s/%s.php', $destination, ucfirst($type));
         $data = $generator->generate($type, $properties, $functions);
         // Existing files ...
         if ($this->filesystem->fileExists($file)) {
             $output->write(sprintf('Client class %s exists. Trying to patch ...', $type));
             $this->handleExistingFile($input, $output, $file, $type, $data);
             continue;
         }
         // New files...
         $this->filesystem->putFileContents($file, $data);
         $output->writeln(sprintf('Generated class %s to %s', $type, $file));
     }
     $output->writeln('Done');
 }