Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TestCommand | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| getAllowedAppEnvs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| handle | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Command; |
| 4 | |
| 5 | use Olz\Command\Common\OlzCommand; |
| 6 | use Olz\Entity\Throttling; |
| 7 | use Olz\Message\TestMessage; |
| 8 | use Olz\Utils\WithUtilsTrait; |
| 9 | use Symfony\Component\Console\Attribute\AsCommand; |
| 10 | use Symfony\Component\Console\Command\Command; |
| 11 | use Symfony\Component\Console\Input\InputInterface; |
| 12 | use Symfony\Component\Console\Output\OutputInterface; |
| 13 | |
| 14 | #[AsCommand(name: 'olz:test')] |
| 15 | class TestCommand extends OlzCommand { |
| 16 | use WithUtilsTrait; |
| 17 | |
| 18 | /** @return array<string> */ |
| 19 | protected function getAllowedAppEnvs(): array { |
| 20 | return ['dev', 'test', 'staging', 'prod']; |
| 21 | } |
| 22 | |
| 23 | protected function handle(InputInterface $input, OutputInterface $output): int { |
| 24 | $data_path = $this->envUtils()->getDataPath(); |
| 25 | $private_path = $this->envUtils()->getPrivatePath(); |
| 26 | $mysql_host = $this->envUtils()->getMysqlHost(); |
| 27 | $smtp_from = $this->envUtils()->getSmtpFrom(); |
| 28 | $app_env = $_ENV['APP_ENV']; |
| 29 | $throttling_repo = $this->entityManager()->getRepository(Throttling::class); |
| 30 | $pretty_throttlings = ''; |
| 31 | foreach ($throttling_repo->findAll() as $throttling) { |
| 32 | $name = $throttling->getEventName(); |
| 33 | $pretty_date = $throttling->getLastOccurrence()?->format('Y-m-d H:i:s'); |
| 34 | $pretty_throttlings .= " {$name}: {$pretty_date}\n"; |
| 35 | } |
| 36 | |
| 37 | $info = <<<ZZZZZZZZZZ |
| 38 | Data path: {$data_path} |
| 39 | Private path: {$private_path} |
| 40 | MySQL host: {$mysql_host} |
| 41 | SMTP from: {$smtp_from} |
| 42 | App env: {$app_env} |
| 43 | Throttlings: |
| 44 | {$pretty_throttlings} |
| 45 | ZZZZZZZZZZ; |
| 46 | $output->writeln($info); |
| 47 | $this->log()->info($info); |
| 48 | |
| 49 | $this->messageBus()->dispatch(new TestMessage()); |
| 50 | |
| 51 | return Command::SUCCESS; |
| 52 | } |
| 53 | } |