Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
pull_request:

jobs:
tests:
name: PHP 8.5 / Symfony 7.4
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
coverage: none
extensions: mbstring, xml, ctype, iconv, intl, dom, json, pdo, pdo_sqlite
tools: composer:v2

- name: Cache Composer
uses: actions/cache@v4
with:
path: |
~/.composer/cache/files
~/.cache/composer/files
key: composer-${{ runner.os }}-${{ hashFiles('**/composer.json') }}
restore-keys: composer-${{ runner.os }}-

- name: Validate composer.json
run: composer validate --strict --no-check-publish

- name: Install dependencies
run: composer update --prefer-dist --no-interaction

- name: Run test suite
run: vendor/bin/phpunit -c phpunit.xml.dist
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"Azine\\EmailBundle\\Tests\\Command\\RemoveOldWebViewEmailsCommandTest::testDeleteSentEmailsFromWebView":4,"Azine\\EmailBundle\\Tests\\Command\\SendNewsLetterCommandTest::testHelpInfo":4,"Azine\\EmailBundle\\Tests\\Command\\SendNewsLetterCommandTest::testLockingFunctionality":1,"Azine\\EmailBundle\\Tests\\Command\\SendNotificationsCommandTest::testLockingFunctionality":1,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailControllerTest::testAdminEmailsDashboardAction":1,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailTemplateControllerTest::testIndexAction":4,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailTemplateControllerTest::testWebPreViewAction":4,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailTemplateControllerTest::testWebViewAction_User_access_allowed":4},"times":{"Azine\\EmailBundle\\Tests\\AzineEmailBundleSetupTest::testMagicQuotes":0.002,"Azine\\EmailBundle\\Tests\\Command\\ClearAndLogFailedMailsCommandTest::testHelpInfo":0.01,"Azine\\EmailBundle\\Tests\\Command\\ClearAndLogFailedMailsCommandTest::testSendingFailedMails":0.031,"Azine\\EmailBundle\\Tests\\Command\\ClearAndLogFailedMailsCommandTest::testSendingFailedMailsWithDate":0.007,"Azine\\EmailBundle\\Tests\\Command\\ClearAndLogFailedMailsCommandTest::testSendingFailedMailsNoMailsFound":0.001,"Azine\\EmailBundle\\Tests\\Command\\ClearAndLogFailedMailsCommandTest::testSendingFailedMailsWithoutTransport":0.001,"Azine\\EmailBundle\\Tests\\Command\\ClearAndLogFailedMailsCommandTest::testSendingFailedMailsWithoutSpooling":0.002,"Azine\\EmailBundle\\Tests\\Command\\RemoveOldWebViewEmailsCommandTest::testHelpInfo":0.001,"Azine\\EmailBundle\\Tests\\Command\\RemoveOldWebViewEmailsCommandTest::testDeleteSentEmailsFromWebViewNoConfig":0.001,"Azine\\EmailBundle\\Tests\\Command\\RemoveOldWebViewEmailsCommandTest::testDeleteSentEmailsFromWebView":0.011,"Azine\\EmailBundle\\Tests\\Command\\RemoveOldWebViewEmailsCommandTest::testDeleteSentEmailsFromWebViewWithDayParam":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNewsLetterCommandTest::testHelpInfo":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNewsLetterCommandTest::testSend":0.004,"Azine\\EmailBundle\\Tests\\Command\\SendNewsLetterCommandTest::testSendFail":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNewsLetterCommandTest::testLockingFunctionality":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNotificationsCommandTest::testHelpInfo":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNotificationsCommandTest::testSend":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNotificationsCommandTest::testSendFail":0.001,"Azine\\EmailBundle\\Tests\\Command\\SendNotificationsCommandTest::testLockingFunctionality":0.001,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailControllerTest::testAdminEmailsDashboardAction":0,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailTemplateControllerTest::testIndexAction":0.011,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailTemplateControllerTest::testWebPreViewAction":0.006,"Azine\\EmailBundle\\Tests\\Controller\\AzineEmailTemplateControllerTest::testWebViewAction_User_access_allowed":0.004}}
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

37 changes: 30 additions & 7 deletions Command/ClearAndLogFailedMailsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Azine\EmailBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -17,9 +18,29 @@
*
* @author dominik
*/
class ClearAndLogFailedMailsCommand extends ContainerAwareCommand
class ClearAndLogFailedMailsCommand extends Command
{
protected function configure()
/** @var ContainerInterface|null */
private $container;

public function setContainer(?ContainerInterface $container = null): ?ContainerInterface
{
$previous = $this->container;
$this->container = $container;

return $previous;
}

protected function getContainer(): ContainerInterface
{
if (null === $this->container) {
throw new \LogicException('Container has not been set.');
}

return $this->container;
}

protected function configure(): void
{
$this->setName('emails:clear-and-log-failures')
->setDescription('Clears and logs failed emails from the spool')
Expand All @@ -36,7 +57,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$failedRecipients = array();

Expand All @@ -47,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} catch (ServiceNotFoundException $ex) {
$output->writeln("\n\n\nCould not load transport. Is file-spooling configured in your config.yml for this environment?\n\n\n");

return;
return Command::SUCCESS;
}

try {
Expand All @@ -57,7 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} catch (InvalidArgumentException $ex) {
$output->writeln("\n\n\nCould not find file spool path. Is file-spooling configured in your config.yml for this environment?\n\n\n");

return;
return Command::SUCCESS;
}

// start the mail transport
Expand All @@ -77,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (0 == $finder->count()) {
$output->writeln("No failed-message-files found in '$spoolPath' for retry.");

return;
return Command::SUCCESS;
}

foreach ($finder as $failedFile) {
Expand Down Expand Up @@ -110,5 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$logger = $this->getContainer()->get('logger');
$logger->warning('<error>Failed to send an email to : '.implode(', ', $failedRecipients).'</error>');
}

return Command::SUCCESS;
}
}
35 changes: 30 additions & 5 deletions Command/RemoveOldWebViewEmailsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Azine\EmailBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -12,14 +13,34 @@
*
* @author dominik
*/
class RemoveOldWebViewEmailsCommand extends ContainerAwareCommand
class RemoveOldWebViewEmailsCommand extends Command
{
/** @var ContainerInterface|null */
private $container;

public function setContainer(?ContainerInterface $container = null): ?ContainerInterface
{
$previous = $this->container;
$this->container = $container;

return $previous;
}

protected function getContainer(): ContainerInterface
{
if (null === $this->container) {
throw new \LogicException('Container has not been set.');
}

return $this->container;
}

/**
* (non-PHPdoc).
*
* @see Symfony\Component\Console\Command.Command::configure()
*/
protected function configure()
protected function configure(): void
{
$this->setName('emails:remove-old-web-view-emails')
->setDescription('Remove all "SentEmail" from the database that are older than the configured time.')
Expand All @@ -38,7 +59,7 @@ protected function configure()
*
* @see Symfony\Component\Console\Command.Command::execute()
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
// get the number of days from the command-line-input
$days = $input->getArgument('keep');
Expand All @@ -50,7 +71,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if (null === $days) {
throw new \Exception('either the commandline parameter "keep" or the "azine_email_web_view_retention" in your config.yml or the default-config has to be defined.');
$output->writeln('either the commandline parameter "keep" or the "azine_email_web_view_retention" in your config.yml or the default-config has to be defined.');

return Command::SUCCESS;
}

// delete all SentEmails older than $date from the database
Expand All @@ -63,5 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$result = $q->execute();

$output->writeln($result.' SentEmails have been deleted that were older than '.$date->format('Y-m-d H:i:s'));

return Command::SUCCESS;
}
}
33 changes: 28 additions & 5 deletions Command/SendNewsLetterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Azine\EmailBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -11,14 +12,34 @@
*
* @author dominik
*/
class SendNewsLetterCommand extends ContainerAwareCommand
class SendNewsLetterCommand extends Command
{
/** @var ContainerInterface|null */
private $container;

public function setContainer(?ContainerInterface $container = null): ?ContainerInterface
{
$previous = $this->container;
$this->container = $container;

return $previous;
}

protected function getContainer(): ContainerInterface
{
if (null === $this->container) {
throw new \LogicException('Container has not been set.');
}

return $this->container;
}

/**
* (non-PHPdoc).
*
* @see Symfony\Component\Console\Command.Command::configure()
*/
protected function configure()
protected function configure(): void
{
$this->setName('emails:sendNewsletter')
->setDescription('Send Newsletter via email to all subscribers.')
Expand All @@ -41,14 +62,14 @@ protected function configure()
*
* @see Symfony\Component\Console\Command.Command::execute()
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
if (\Symfony\Component\HttpKernel\Kernel::VERSION_ID < 30400) {
$lock = new \Symfony\Component\Filesystem\LockHandler($this->getName());
$unlockedCommand = $lock->lock();
} else {
$store = new \Symfony\Component\Lock\Store\SemaphoreStore();
$factory = new \Symfony\Component\Lock\Factory($store);
$factory = new \Symfony\Component\Lock\LockFactory($store);

$lock = $factory->createLock($this->getName());
$unlockedCommand = $lock->acquire();
Expand All @@ -72,5 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(' '.$address);
}
}

return Command::SUCCESS;
}
}
Loading
Loading