Guest User

Untitled

a guest
Jan 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. /**
  2. * @test
  3. */
  4. public function test_command()
  5. {
  6. $kernel = static::createKernel();
  7. $kernel->boot();
  8.  
  9. $application = new Application($kernel);
  10. $application->add(new MyCommand());
  11.  
  12. $command = $application->find('my:command');
  13.  
  14. $commandTester = new CommandTester($command);
  15. $commandTester->execute(
  16. [
  17. 'command' => $command->getName(),
  18. ]
  19. );
  20. $statusCode = $commandTester->getStatusCode();
  21. $this->assertEquals(0, $statusCode);
  22. }
  23.  
  24. /**
  25. * {@inheritdoc}
  26. */
  27. protected function execute(InputInterface $input, OutputInterface $output)
  28. {
  29. $this->logger->info(sprintf('Starting job "%s"', $this->getName()));
  30.  
  31. try {
  32. $changesDone = $this->importService->importQuestionsAndChoices();
  33.  
  34. if ($changesDone) {
  35. if (!$input->getOption('no-profile-generation')) {
  36. $this->logger->info('Questions have changed. Re-generating table');
  37. $this->profileGenerator->generateEntity();
  38. }
  39. } else {
  40. $this->logger->info('No new questions or choices available');
  41. }
  42. } catch (Exception $exception) {
  43. $this->logger->error($exception->getMessage(), ['exception' => $exception]);
  44. }
  45.  
  46. $this->logger->info(sprintf('Ending job "%s"', $this->getName()));
  47. }
Add Comment
Please, Sign In to add comment