Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SendTestEmailCommand
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 getAllowedAppEnvs
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 handle
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Olz\Command;
4
5use Olz\Command\Common\OlzCommand;
6use Olz\Message\SendEmailMessage;
7use Symfony\Component\Console\Attribute\AsCommand;
8use Symfony\Component\Console\Command\Command;
9use Symfony\Component\Console\Input\InputInterface;
10use Symfony\Component\Console\Output\OutputInterface;
11
12#[AsCommand(name: 'olz:send-test-email')]
13class SendTestEmailCommand extends OlzCommand {
14    /** @return array<string> */
15    protected function getAllowedAppEnvs(): array {
16        return ['dev', 'staging', 'prod'];
17    }
18
19    protected function handle(InputInterface $input, OutputInterface $output): int {
20        $base_href = $this->envUtils()->getBaseHref();
21        $to = 'simon+olztestemail@hatt.style';
22        $subject = 'Test mail';
23        $content = "A test mail has been sent from {$base_href}!";
24        $message = new SendEmailMessage($to, $subject, $content);
25        $this->messageBus->dispatch($message);
26        $this->log()->info("Test SendEmailMessage dispatched.");
27        return Command::SUCCESS;
28    }
29}