Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.9 KiB

5 years ago
  1. <?php
  2. namespace Prometeo\CommandsBundle\Commands;
  3. use Symfony\Component\Console\Command\Command as ContainerAwareCommand;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Input\InputOption;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Symfony\Component\DependencyInjection\ContainerInterface;
  10. class Selenium2Katalon extends ContainerAwareCommand
  11. {
  12. private $em;
  13. public function __construct(ContainerInterface $container)
  14. {
  15. parent::__construct();
  16. $this->em = $container->get('doctrine')->getManager();
  17. }
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function configure(): void
  22. {
  23. $this->setName('prometeo:test:selenium2katalon');
  24. $this->addArgument(
  25. 'seleniumfile',
  26. InputArgument::REQUIRED,
  27. 'Selenium File in SIDE format'
  28. )
  29. ;
  30. $this->addArgument(
  31. 'katalonfile',
  32. InputArgument::OPTIONAL,
  33. 'Katalon File in HTML format'
  34. );
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function execute(InputInterface $input, OutputInterface $output): void
  40. {
  41. $seleniumfile=$input->getArgument('seleniumfile');
  42. if ($input->getArgument('prefix')) {
  43. $katalonfile=$input->getArgument('katalonfile');
  44. }else{
  45. $katalonfile=$seleniumfile.'.html';
  46. }
  47. $selenium=file_get_contents($seleniumfile);
  48. $seleniumobj=json_decode($selenium,true);
  49. $header="<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  50. <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
  51. <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
  52. <head>
  53. <meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\" />
  54. <title>".$seleniumobj['name']."</title>
  55. </head>";
  56. $body='<body>';
  57. foreach($seleniumobj['tests'] as $test){
  58. $body.="<table cellpadding=\"1\" cellspacing=\"1\" border=\"1\">
  59. <thead>
  60. <tr><td rowspan=\"1\" colspan=\"3\">".$test['name']."</td></tr>
  61. </thead>
  62. <tbody>";
  63. foreach($test['commands'] as $command){
  64. $body.="<tr><td>".$command['command']."</td><td>".$command['target']."<datalist>";
  65. foreach($command['targets'] as $target){
  66. $body.="<option>".$target[0]."</option>";
  67. }
  68. $body.='</datalist></td><td>'.$command['value']."</td></tr>";
  69. }
  70. $body.="</tbody></table>";
  71. }
  72. $body='</body></html>';
  73. file_put_contents($katalonfile,$header.$body);
  74. echo "Conversion finalizada";
  75. }
  76. }