diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..70f31fb0
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -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
diff --git a/.phpunit.result.cache b/.phpunit.result.cache
new file mode 100644
index 00000000..24bede98
--- /dev/null
+++ b/.phpunit.result.cache
@@ -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}}
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 5f4a19aa..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,50 +0,0 @@
-language: php
-
-php:
- - 7.1
- - 7.2
-
-env:
- - SYMFONY_VERSION=lts:^2
- - SYMFONY_VERSION=lts:^3
- - SYMFONY_VERSION=flex:^1
- - SYMFONY_VERSION=lts:^4
-
-
-matrix:
- fast_finish: true
- include:
- - env:
- - SYMFONY_VERSION=lts:^2
- - dependencies=lowest
-
- - env:
- - SYMFONY_VERSION=lts:^3
- - cs_fixer=cs_dry_run
-
- allow_failures:
- - env: SYMFONY_VERSION=lts:^4
-
-cache:
- directories:
- - $HOME/.composer/cache
-
-before_install:
- - mv /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ~/xdebug.ini
- - composer self-update
-
-before_script:
- - phpenv config-add travis.php.ini
- - travis_wait composer require symfony/${SYMFONY_VERSION} --prefer-source --no-update -v
- - mv ~/xdebug.ini /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- - if [ "$dependencies" != "lowest" ]; then travis_wait composer update --prefer-source; fi;
- - if [ "$dependencies" = "lowest" ]; then travis_wait composer update --prefer-lowest --prefer-stable -n; fi;
-
-script:
- - travis_wait vendor/phpunit/phpunit/phpunit --coverage-text --coverage-clover=coverage.clover Tests/
- - wget https://scrutinizer-ci.com/ocular.phar
- - php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- - if [ "$cs_fixer" = "cs_dry_run" ]; then php vendor/friendsofphp/php-cs-fixer/php-cs-fixer --diff --dry-run -v fix --config=.php_cs.dist ./; fi;
-
-notifications:
- email: travis@azine-it.ch
diff --git a/Command/ClearAndLogFailedMailsCommand.php b/Command/ClearAndLogFailedMailsCommand.php
index 808d2535..6529b2f1 100644
--- a/Command/ClearAndLogFailedMailsCommand.php
+++ b/Command/ClearAndLogFailedMailsCommand.php
@@ -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;
@@ -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')
@@ -36,7 +57,7 @@ protected function configure()
;
}
- protected function execute(InputInterface $input, OutputInterface $output)
+ protected function execute(InputInterface $input, OutputInterface $output): int
{
$failedRecipients = array();
@@ -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 {
@@ -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
@@ -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) {
@@ -110,5 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$logger = $this->getContainer()->get('logger');
$logger->warning('Failed to send an email to : '.implode(', ', $failedRecipients).'');
}
+
+ return Command::SUCCESS;
}
}
diff --git a/Command/RemoveOldWebViewEmailsCommand.php b/Command/RemoveOldWebViewEmailsCommand.php
index 94b0e55a..b63f8ddd 100644
--- a/Command/RemoveOldWebViewEmailsCommand.php
+++ b/Command/RemoveOldWebViewEmailsCommand.php
@@ -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;
@@ -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.')
@@ -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');
@@ -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
@@ -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;
}
}
diff --git a/Command/SendNewsLetterCommand.php b/Command/SendNewsLetterCommand.php
index 15d99421..b10a68a1 100644
--- a/Command/SendNewsLetterCommand.php
+++ b/Command/SendNewsLetterCommand.php
@@ -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;
@@ -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.')
@@ -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();
@@ -72,5 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(' '.$address);
}
}
+
+ return Command::SUCCESS;
}
}
diff --git a/Command/SendNotificationsCommand.php b/Command/SendNotificationsCommand.php
index c388b1fd..a5e4804e 100644
--- a/Command/SendNotificationsCommand.php
+++ b/Command/SendNotificationsCommand.php
@@ -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;
@@ -11,14 +12,34 @@
*
* @author dominik
*/
-class SendNotificationsCommand extends ContainerAwareCommand
+class SendNotificationsCommand 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:sendNotifications')
->setDescription('Aggregate and send pending notifications via email.')
@@ -40,14 +61,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();
@@ -72,5 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// (optional) release the lock (otherwise, PHP will do it for you automatically)
$lock->release();
+
+ return Command::SUCCESS;
}
}
diff --git a/Controller/AzineEmailController.php b/Controller/AzineEmailController.php
index b755260c..8d787409 100644
--- a/Controller/AzineEmailController.php
+++ b/Controller/AzineEmailController.php
@@ -5,14 +5,14 @@
use Azine\EmailBundle\Entity\Repositories\SentEmailRepository;
use Azine\EmailBundle\Entity\SentEmail;
use Azine\EmailBundle\Form\SentEmailType;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* This controller provides actions related to SentEmails stored in the database.
*/
-class AzineEmailController extends Controller
+class AzineEmailController extends AbstractController
{
/**
* Displays an Emails-Dashboard with filters for each property of SentEmails entity and links to
@@ -26,9 +26,9 @@ public function emailsDashboardAction(Request $request)
$form->handleRequest($request);
$searchParams = $form->getData();
/** @var SentEmailRepository $repository */
- $repository = $this->getDoctrine()->getManager()->getRepository(SentEmail::class);
+ $repository = $this->container->container->get('doctrine')->getManager()->getRepository(SentEmail::class);
$query = $repository->search($searchParams);
- $pagination = $this->get('knp_paginator')->paginate($query, $request->query->getInt('page', 1));
+ $pagination = $this->container->get('knp_paginator')->paginate($query, $request->query->getInt('page', 1));
return $this->render('AzineEmailBundle::emailsDashboard.html.twig',
array('form' => $form->createView(), 'pagination' => $pagination));
@@ -43,7 +43,7 @@ public function emailsDashboardAction(Request $request)
*/
public function emailDetailsByTokenAction(Request $request, $token)
{
- $email = $this->getDoctrine()->getManager()->getRepository(SentEmail::class)
+ $email = $this->container->container->get('doctrine')->getManager()->getRepository(SentEmail::class)
->findOneByToken($token);
if ($email instanceof SentEmail) {
@@ -55,7 +55,7 @@ public function emailDetailsByTokenAction(Request $request, $token)
}
// the parameters-array is null => the email is not available in webView
- $days = $this->getParameter('azine_email_web_view_retention');
+ $days = $this->container->getParameter('azine_email_web_view_retention');
$response = $this->render('AzineEmailBundle:Webview:mail.not.available.html.twig', array('days' => $days));
$response->setStatusCode(404);
diff --git a/Controller/AzineEmailTemplateController.php b/Controller/AzineEmailTemplateController.php
index d5fecf47..021396d0 100644
--- a/Controller/AzineEmailTemplateController.php
+++ b/Controller/AzineEmailTemplateController.php
@@ -5,7 +5,7 @@
use Azine\EmailBundle\Entity\SentEmail;
use Azine\EmailBundle\Services\TemplateProviderInterface;
use Doctrine\ORM\EntityManager;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -27,7 +27,7 @@
*
* @author dominik
*/
-class AzineEmailTemplateController extends Controller
+class AzineEmailTemplateController extends AbstractController
{
/**
* Show a set of options to view html- and text-versions of email in the browser and send them as emails to test-accounts.
@@ -35,10 +35,10 @@ class AzineEmailTemplateController extends Controller
public function indexAction(Request $request)
{
$customEmail = $request->get('customEmail', 'custom@email.com');
- $templates = $this->get('azine_email_web_view_service')->getTemplatesForWebPreView();
- $emails = $this->get('azine_email_web_view_service')->getTestMailAccounts();
+ $templates = $this->container->get('azine_email_web_view_service')->getTemplatesForWebPreView();
+ $emails = $this->container->get('azine_email_web_view_service')->getTestMailAccounts();
- return $this->get('templating')
+ return $this->container->get('templating')
->renderResponse('AzineEmailBundle:Webview:index.html.twig',
array(
'customEmail' => $customEmail,
@@ -66,7 +66,7 @@ public function webPreViewAction(Request $request, $template, $format = null)
// merge request vars with dummyVars, but make sure request vars remain as they are.
$emailVars = array_merge(array(), $request->query->all());
- $emailVars = $this->get('azine_email_web_view_service')->getDummyVarsFor($template, $locale, $emailVars);
+ $emailVars = $this->container->get('azine_email_web_view_service')->getDummyVarsFor($template, $locale, $emailVars);
$emailVars = array_merge($emailVars, $request->query->all());
// add the styles
@@ -74,7 +74,7 @@ public function webPreViewAction(Request $request, $template, $format = null)
// add the from-email for the footer-text
if (!array_key_exists('fromEmail', $emailVars)) {
- $noReply = $this->getParameter('azine_email_no_reply');
+ $noReply = $this->container->getParameter('azine_email_no_reply');
$emailVars['fromEmail'] = $noReply['email'];
$emailVars['fromName'] = $noReply['name'];
}
@@ -96,9 +96,9 @@ public function webPreViewAction(Request $request, $template, $format = null)
$campaignParams['utm_medium'] = 'webPreview';
if (sizeof($campaignParams) > 0) {
$content = $response->getContent();
- $content = $this->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($content, $campaignParams);
+ $content = $this->container->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($content, $campaignParams);
- $emailOpenTrackingCodeBuilder = $this->get('azine_email_email_open_tracking_code_builder');
+ $emailOpenTrackingCodeBuilder = $this->container->get('azine_email_email_open_tracking_code_builder');
if ($emailOpenTrackingCodeBuilder) {
// add an image at the end of the html tag with the tracking-params to track email-opens
$imgTrackingCode = $emailOpenTrackingCodeBuilder->getTrackingImgCode($template, $campaignParams, $emailVars, 'dummy', 'dummy@from.email.com', null, null);
@@ -160,19 +160,19 @@ public function webViewAction(Request $request, $token)
$campaignParams = $templateProvider->getCampaignParamsFor($template, $emailVars);
if (null != $campaignParams && sizeof($campaignParams) > 0) {
- $response->setContent($this->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($response->getContent(), $campaignParams));
+ $response->setContent($this->container->get('azine.email.bundle.twig.filters')->addCampaignParamsToAllUrls($response->getContent(), $campaignParams));
}
return $response;
// if the user is not allowed to see this mail
}
- $msg = $this->get('translator')->trans('web.pre.view.test.mail.access.denied');
+ $msg = $this->container->get('translator')->trans('web.pre.view.test.mail.access.denied');
throw new AccessDeniedException($msg);
}
// the parameters-array is null => the email is not available in webView
- $days = $this->getParameter('azine_email_web_view_retention');
+ $days = $this->container->getParameter('azine_email_web_view_retention');
$response = $this->renderResponse('AzineEmailBundle:Webview:mail.not.available.html.twig', array('days' => $days));
$response->setStatusCode(404);
@@ -201,7 +201,7 @@ private function userIsAllowedToSeeThisMail(SentEmail $mail)
throw new \LogicException('The SecurityBundle is not registered in your application.');
// @codeCoverageIgnoreEnd
}
- $token = $this->get('security.token_storage')->getToken();
+ $token = $this->container->get('security.token_storage')->getToken();
// check if the token is not null and the user in the token an object
if ($token instanceof TokenInterface && is_object($token->getUser())) {
@@ -242,7 +242,7 @@ private function userIsAllowedToSeeThisMail(SentEmail $mail)
private function reAttachAllEntities(array &$vars)
{
/** @var EntityManager $em */
- $em = $this->get('doctrine')->getManager();
+ $em = $this->container->get('doctrine')->getManager();
foreach ($vars as $key => $next) {
if (is_object($next) && method_exists($next, 'getId')) {
$className = get_class($next);
@@ -273,7 +273,7 @@ public function serveImageAction(Request $request, $folderKey, $filename)
$folder = $this->getTemplateProviderService()->getFolderFrom($folderKey);
if (false !== $folder) {
$fullPath = $folder.urldecode($filename);
- $response = BinaryFileResponse::create($fullPath);
+ $response = new BinaryFileResponse($fullPath);
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE);
$response->headers->set('Content-Type', 'image');
@@ -288,7 +288,7 @@ public function serveImageAction(Request $request, $folderKey, $filename)
*/
protected function getTemplateProviderService()
{
- return $this->get('azine_email_template_provider');
+ return $this->container->get('azine_email_template_provider');
}
/**
@@ -297,9 +297,9 @@ protected function getTemplateProviderService()
*
* @return Response
*/
- protected function renderResponse($view, array $parameters = array(), Response $response = null)
+ protected function renderResponse($view, array $parameters = array(), ?Response $response = null)
{
- return $this->get('templating')->renderResponse($view, $parameters, $response);
+ return $this->container->get('templating')->renderResponse($view, $parameters, $response);
}
/**
@@ -311,7 +311,7 @@ protected function renderResponse($view, array $parameters = array(), Response $
*/
protected function getSentEmailForToken($token)
{
- $sentEmail = $this->get('doctrine')->getRepository('AzineEmailBundle:SentEmail')->findOneByToken($token);
+ $sentEmail = $this->container->get('doctrine')->getRepository('AzineEmailBundle:SentEmail')->findOneByToken($token);
return $sentEmail;
}
@@ -331,11 +331,11 @@ public function sendTestEmailAction(Request $request, $template, $email)
$template = urldecode($template);
// get the email-vars for email-sending => absolute fs-paths to images
- $emailVars = $this->get('azine_email_web_view_service')->getDummyVarsFor($template, $locale);
+ $emailVars = $this->container->get('azine_email_web_view_service')->getDummyVarsFor($template, $locale);
// send the mail
$message = new \Swift_Message();
- $mailer = $this->get('azine_email_template_twig_swift_mailer');
+ $mailer = $this->container->get('azine_email_template_twig_swift_mailer');
$emailArray = array();
foreach (mailparse_rfc822_parse_addresses($email) as $next){
$emailArray[$next['address']] = "Test-Mail-Recipient";
@@ -374,19 +374,19 @@ public function sendTestEmailAction(Request $request, $template, $email)
// inform about sent/failed emails
if ($sent) {
- $msg = $this->get('translator')->trans('web.pre.view.test.mail.sent.for.%template%.to.%email%', array('%template%' => $template, '%email%' => $email));
+ $msg = $this->container->get('translator')->trans('web.pre.view.test.mail.sent.for.%template%.to.%email%', array('%template%' => $template, '%email%' => $email));
$flashBag->add('info', $msg);
//@codeCoverageIgnoreStart
} else {
// this only happens if the mail-server has a problem
- $msg = $this->get('translator')->trans('web.pre.view.test.mail.failed.for.%template%.to.%email%', array('%template%' => $template, '%email%' => $email));
+ $msg = $this->container->get('translator')->trans('web.pre.view.test.mail.failed.for.%template%.to.%email%', array('%template%' => $template, '%email%' => $email));
$flashBag->add('warn', $msg);
//@codeCoverageIgnoreStart
}
// show the index page again.
- return new RedirectResponse($this->get('router')->generate('azine_email_template_index', array('customEmail' => $email)));
+ return new RedirectResponse($this->container->get('router')->generate('azine_email_template_index', array('customEmail' => $email)));
}
/**
@@ -454,7 +454,7 @@ private function getSpamIndexReport($msgString, $report = 'long')
*/
public function checkSpamScoreOfSentEmailAction(Request $request)
{
- $msgString = $request->get('emailSource');
+ $msgString = $request->request->get('emailSource');
$spamReport = $this->getSpamIndexReport($msgString);
$spamInfo = '';
if (is_array($spamReport)) {
diff --git a/DependencyInjection/AzineEmailExtension.php b/DependencyInjection/AzineEmailExtension.php
index 411232d2..fd40c100 100644
--- a/DependencyInjection/AzineEmailExtension.php
+++ b/DependencyInjection/AzineEmailExtension.php
@@ -46,7 +46,7 @@ class AzineEmailExtension extends Extension
/**
* {@inheritdoc}
*/
- public function load(array $configs, ContainerBuilder $container)
+ public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index a2f47c81..8f8764d8 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -14,17 +14,17 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
- $treeBuilder = new TreeBuilder();
- $rootNode = $treeBuilder->root('azine_email');
+ $treeBuilder = new TreeBuilder('azine_email');
+ $rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
- ->scalarNode(AzineEmailExtension::RECIPIENT_CLASS)->isRequired()->defaultValue('Acme\\SomeBundle\\Entity\\User')->info('the class of your implementation of the RecipientInterface')->end()
+ ->scalarNode(AzineEmailExtension::RECIPIENT_CLASS)->defaultValue('Acme\\SomeBundle\\Entity\\User')->info('the class of your implementation of the RecipientInterface')->end()
->scalarNode(AzineEmailExtension::RECIPIENT_NEWSLETTER_FIELD)->defaultValue('newsletter')->info('the fieldname of the boolean field on the recipient class indicating, that a newsletter should be sent or not')->end()
->scalarNode(AzineEmailExtension::NOTIFIER_SERVICE)->defaultValue('azine_email.example.notifier_service')->info('the service-id of your implementation of the nofitier service to be used')->end()
- ->scalarNode(AzineEmailExtension::TEMPLATE_PROVIDER)->isRequired()->defaultValue('azine_email.example.template_provider')->info('the service-id of your implementation of the template provider service to be used')->end()
+ ->scalarNode(AzineEmailExtension::TEMPLATE_PROVIDER)->defaultValue('azine_email.example.template_provider')->info('the service-id of your implementation of the template provider service to be used')->end()
->scalarNode(AzineEmailExtension::RECIPIENT_PROVIDER)->defaultValue('azine_email.default.recipient_provider')->info('the service-id of the implementation of the RecipientProviderInterface to be used')->end()
->scalarNode(AzineEmailExtension::TEMPLATE_TWIG_SWIFT_MAILER)->defaultValue('azine_email.default.template_twig_swift_mailer')->info('the service-id of the mailer service to be used')->end()
->arrayNode(AzineEmailExtension::NO_REPLY)->isRequired()
diff --git a/README.md b/README.md
index 338c7871..fe3178f3 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,26 @@ provide recipient information (name/email/notification interval/newsletter subsc
for the mails to be sent.
## Installation
+
+## Modern platform requirements
+
+As of this modernization pass, this bundle targets:
+
+- PHP **8.5+**
+- Symfony **7.4+**
+- PHPUnit **11.5+** (development/test)
+
+### Running tests locally
+
+```bash
+composer validate --strict --no-check-publish
+composer update
+vendor/bin/phpunit -c phpunit.xml.dist
+```
+
+> Note: this bundle still uses SwiftMailer APIs internally for backward compatibility with existing integrations.
+
+
To install AzineEmailBundle with Composer just add the following to your `composer.json` file:
```javascript
diff --git a/Services/AzineEmailTwigExtension.php b/Services/AzineEmailTwigExtension.php
index 1cd8c43d..4e6d5a00 100644
--- a/Services/AzineEmailTwigExtension.php
+++ b/Services/AzineEmailTwigExtension.php
@@ -2,9 +2,9 @@
namespace Azine\EmailBundle\Services;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
-class AzineEmailTwigExtension extends \Twig_Extension
+class AzineEmailTwigExtension extends \Twig\Extension\AbstractExtension
{
/**
* @var TemplateProviderInterface
diff --git a/Services/AzineNotifierService.php b/Services/AzineNotifierService.php
index d78962dc..be43143e 100644
--- a/Services/AzineNotifierService.php
+++ b/Services/AzineNotifierService.php
@@ -6,9 +6,9 @@
use Azine\EmailBundle\Entity\Notification;
use Azine\EmailBundle\Entity\RecipientInterface;
use Azine\EmailBundle\Entity\Repositories\NotificationRepository;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
/**
* This Service compiles and renders the emails to be sent.
diff --git a/Services/AzineRecipientProvider.php b/Services/AzineRecipientProvider.php
index b20d4658..dd590915 100644
--- a/Services/AzineRecipientProvider.php
+++ b/Services/AzineRecipientProvider.php
@@ -2,7 +2,7 @@
namespace Azine\EmailBundle\Services;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
/**
* Default implementation of the RecipientProviderInterface.
diff --git a/Services/AzineTemplateProvider.php b/Services/AzineTemplateProvider.php
index 24841ca1..8b9e4616 100644
--- a/Services/AzineTemplateProvider.php
+++ b/Services/AzineTemplateProvider.php
@@ -9,7 +9,7 @@
use Azine\EmailBundle\DependencyInjection\AzineEmailExtension;
use Symfony\Bundle\FrameworkBundle\Translation\Translator;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
class AzineTemplateProvider implements TemplateProviderInterface
{
diff --git a/Services/AzineTwigSwiftMailer.php b/Services/AzineTwigSwiftMailer.php
index d6b26215..d2617628 100644
--- a/Services/AzineTwigSwiftMailer.php
+++ b/Services/AzineTwigSwiftMailer.php
@@ -5,13 +5,13 @@
use Azine\EmailBundle\DependencyInjection\AzineEmailExtension;
use Azine\EmailBundle\Entity\SentEmail;
use Azine\EmailUpdateConfirmationBundle\Mailer\EmailUpdateConfirmationMailerInterface;
-use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Persistence\ManagerRegistry;
use FOS\UserBundle\Mailer\TwigSwiftMailer;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\HttpFoundation\File\Exception\FileException;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RequestContext;
-use Symfony\Component\Translation\TranslatorInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
/**
* This Service is used to send html-emails with embedded images.
@@ -348,7 +348,7 @@ private function removeUnreferecedEmbededItemsFromMessage(\Swift_Message $messag
*
* @param string $template
*
- * @return \Twig_Template
+ * @return \Twig\Template
*/
private function loadTemplate($template)
{
diff --git a/Tests/AzineEmailBundleSetupTest.php b/Tests/AzineEmailBundleSetupTest.php
index 16ff0920..29a9e449 100644
--- a/Tests/AzineEmailBundleSetupTest.php
+++ b/Tests/AzineEmailBundleSetupTest.php
@@ -9,6 +9,12 @@ class AzineEmailBundleSetupTest extends \PHPUnit\Framework\TestCase
{
public function testMagicQuotes()
{
+ if (!function_exists('get_magic_quotes_gpc')) {
+ $this->assertTrue(true);
+
+ return;
+ }
+
$this->assertFalse(get_magic_quotes_gpc(), 'magic_quotes_gpc should be turned off in php.ini');
}
}
diff --git a/Tests/Command/ClearAndLogFailedMailsCommandTest.php b/Tests/Command/ClearAndLogFailedMailsCommandTest.php
index 651a095f..f263cf9f 100644
--- a/Tests/Command/ClearAndLogFailedMailsCommandTest.php
+++ b/Tests/Command/ClearAndLogFailedMailsCommandTest.php
@@ -20,7 +20,7 @@ public function testHelpInfo()
$command = $this->getCommand();
$display = $command->getHelp();
- $this->assertContains('Any email-address that still failed, is logged.', $display);
+ $this->assertStringContainsString('Any email-address that still failed, is logged.', $display);
}
public function testSendingFailedMails()
@@ -33,8 +33,8 @@ public function testSendingFailedMails()
$command->setContainer($this->getMockSetup($failedRecipients, false, false, $this->exactly($count)));
$display = $this->executeCommandAndGetDisplay($command, array(''));
- $this->assertContains("Retrying to send 'subject blabbla' to 'test-recipient@example.com'", $display);
- $this->assertContains('Sent!', $display);
+ $this->assertStringContainsString("Retrying to send 'subject blabbla' to 'test-recipient@example.com'", $display);
+ $this->assertStringContainsString('Sent!', $display);
}
public function testSendingFailedMailsWithDate()
@@ -47,8 +47,8 @@ public function testSendingFailedMailsWithDate()
$command->setContainer($this->getMockSetup($failedRecipients, false, false, $this->exactly($count)));
$display = $this->executeCommandAndGetDisplay($command, array('date' => ' > now -1 minute'));
- $this->assertContains("Retrying to send 'subject blabbla' to 'test-recipient@example.com'", $display);
- $this->assertContains('Sent!', $display);
+ $this->assertStringContainsString("Retrying to send 'subject blabbla' to 'test-recipient@example.com'", $display);
+ $this->assertStringContainsString('Sent!', $display);
}
public function testSendingFailedMailsNoMailsFound()
@@ -59,7 +59,7 @@ public function testSendingFailedMailsNoMailsFound()
$display = $this->executeCommandAndGetDisplay($command, array(''));
- $this->assertContains('No failed-message-files found', $display);
+ $this->assertStringContainsString('No failed-message-files found', $display);
}
public function testSendingFailedMailsWithoutTransport()
@@ -70,7 +70,7 @@ public function testSendingFailedMailsWithoutTransport()
$display = $this->executeCommandAndGetDisplay($command, array(''));
- $this->assertContains('Could not load transport. Is file-spooling configured in your config.yml for this environment?', $display);
+ $this->assertStringContainsString('Could not load transport. Is file-spooling configured in your config.yml for this environment?', $display);
}
public function testSendingFailedMailsWithoutSpooling()
@@ -81,7 +81,7 @@ public function testSendingFailedMailsWithoutSpooling()
$display = $this->executeCommandAndGetDisplay($command, array(''));
- $this->assertContains('Could not find file spool path. Is file-spooling configured in your config.yml for this environment?', $display);
+ $this->assertStringContainsString('Could not find file spool path. Is file-spooling configured in your config.yml for this environment?', $display);
}
/**
@@ -207,7 +207,7 @@ private function executeCommandAndGetDisplay($command, $input)
return $display;
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
$finder = Finder::create()->in(__DIR__.'/mock.spool.path/')->name('*');
diff --git a/Tests/Command/RemoveOldWebViewEmailsCommandTest.php b/Tests/Command/RemoveOldWebViewEmailsCommandTest.php
index b9387c8d..38a543ba 100644
--- a/Tests/Command/RemoveOldWebViewEmailsCommandTest.php
+++ b/Tests/Command/RemoveOldWebViewEmailsCommandTest.php
@@ -18,8 +18,8 @@ public function testHelpInfo()
$application->add(new RemoveOldWebViewEmailsCommand());
$command = $application->find('emails:remove-old-web-view-emails');
- $this->assertContains('command deletes all SentEmail entities from the database', $command->getHelp());
- $this->assertContains('Remove all "SentEmail" from the database that are older than the configured time.', $command->getDescription());
+ $this->assertStringContainsString('command deletes all SentEmail entities from the database', $command->getHelp());
+ $this->assertStringContainsString('Remove all "SentEmail" from the database that are older than the configured time.', $command->getDescription());
}
/**
@@ -37,7 +37,7 @@ public function testDeleteSentEmailsFromWebViewNoConfig()
$tester = new CommandTester($command);
$tester->execute(array(''));
$display = $tester->getDisplay();
- $this->assertContains('either the commandline parameter "keep" or the "azine_email_web_view_retention" in your config.yml or the default-config has to be defined.', $display);
+ $this->assertStringContainsString('either the commandline parameter "keep" or the "azine_email_web_view_retention" in your config.yml or the default-config has to be defined.', $display);
}
public function testDeleteSentEmailsFromWebView()
@@ -53,8 +53,8 @@ public function testDeleteSentEmailsFromWebView()
$tester = new CommandTester($command);
$tester->execute(array(''));
$display = $tester->getDisplay();
- $this->assertContains("using the parameter from the configuration => '$days' days.", $display);
- $this->assertContains("$deletedWebMails SentEmails have been deleted that were older than", $display);
+ $this->assertStringContainsString("using the parameter from the configuration => '$days' days.", $display);
+ $this->assertStringContainsString("$deletedWebMails SentEmails have been deleted that were older than", $display);
}
public function testDeleteSentEmailsFromWebViewWithDayParam()
@@ -70,7 +70,7 @@ public function testDeleteSentEmailsFromWebViewWithDayParam()
$tester = new CommandTester($command);
$tester->execute(array('keep' => 121));
$display = $tester->getDisplay();
- $this->assertContains("$deletedWebMails SentEmails have been deleted that were older than", $display);
+ $this->assertStringContainsString("$deletedWebMails SentEmails have been deleted that were older than", $display);
$this->assertTrue(false === strpos($display, 'using the parameter from the configuration'), "display is:\n\n$display");
}
@@ -93,7 +93,7 @@ private function getMockSetup($days, $deletedWebMails, $useKeep = false)
$entityManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
$entityManagerMock->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilderMock));
- $doctrineMock = $this->getMockBuilder("\Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineMock = $this->getMockBuilder("\Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineMock->expects($this->once())->method('getManager')->will($this->returnValue($entityManagerMock));
if (!$useKeep) {
diff --git a/Tests/Command/SendNewsLetterCommandTest.php b/Tests/Command/SendNewsLetterCommandTest.php
index 37f58a76..946b1176 100644
--- a/Tests/Command/SendNewsLetterCommandTest.php
+++ b/Tests/Command/SendNewsLetterCommandTest.php
@@ -16,7 +16,7 @@ public function testHelpInfo()
{
$command = $this->getCommand();
$display = $command->getHelp();
- $this->assertContains('Depending on you Swiftmailer-Configuration the email will be send directly or will be written to the spool.', $display);
+ $this->assertStringContainsString('Depending on you Swiftmailer-Configuration the email will be send directly or will be written to the spool.', $display);
}
public function testSend()
@@ -25,7 +25,7 @@ public function testSend()
$tester = new CommandTester($command);
$tester->execute(array(''));
$display = $tester->getDisplay();
- $this->assertContains(AzineNotifierServiceMock::EMAIL_COUNT.' newsletter emails have been sent.', $display);
+ $this->assertStringContainsString(AzineNotifierServiceMock::EMAIL_COUNT.' newsletter emails have been sent.', $display);
}
public function testSendFail()
@@ -34,8 +34,8 @@ public function testSendFail()
$tester = new CommandTester($command);
$tester->execute(array(''));
$display = $tester->getDisplay();
- $this->assertContains((AzineNotifierServiceMock::EMAIL_COUNT - 1).' newsletter emails have been sent.', $display);
- $this->assertContains(AzineNotifierServiceMock::FAILED_ADDRESS, $display);
+ $this->assertStringContainsString((AzineNotifierServiceMock::EMAIL_COUNT - 1).' newsletter emails have been sent.', $display);
+ $this->assertStringContainsString(AzineNotifierServiceMock::FAILED_ADDRESS, $display);
}
/**
@@ -80,6 +80,6 @@ public function testLockingFunctionality()
usleep(10);
}
- $this->assertContains('The command is already running in another process.', $process2->getOutput().$process1->getOutput());
+ $this->assertStringContainsString('The command is already running in another process.', $process2->getOutput().$process1->getOutput());
}
}
diff --git a/Tests/Command/SendNotificationsCommandTest.php b/Tests/Command/SendNotificationsCommandTest.php
index 43a24fdf..cc0769df 100644
--- a/Tests/Command/SendNotificationsCommandTest.php
+++ b/Tests/Command/SendNotificationsCommandTest.php
@@ -16,7 +16,7 @@ public function testHelpInfo()
{
$command = $this->getCommand();
$display = $command->getHelp();
- $this->assertContains('Depending on you Swiftmailer-Configuration the email will be send directly or will be written to the spool.', $display);
+ $this->assertStringContainsString('Depending on you Swiftmailer-Configuration the email will be send directly or will be written to the spool.', $display);
}
public function testSend()
@@ -25,7 +25,7 @@ public function testSend()
$tester = new CommandTester($command);
$tester->execute(array(''));
$display = $tester->getDisplay();
- $this->assertContains(AzineNotifierServiceMock::EMAIL_COUNT.' emails have been processed.', $display);
+ $this->assertStringContainsString(AzineNotifierServiceMock::EMAIL_COUNT.' emails have been processed.', $display);
}
public function testSendFail()
@@ -34,8 +34,8 @@ public function testSendFail()
$tester = new CommandTester($command);
$tester->execute(array(''));
$display = $tester->getDisplay();
- $this->assertContains((AzineNotifierServiceMock::EMAIL_COUNT - 1).' emails have been processed.', $display);
- $this->assertContains(AzineNotifierServiceMock::FAILED_ADDRESS, $display);
+ $this->assertStringContainsString((AzineNotifierServiceMock::EMAIL_COUNT - 1).' emails have been processed.', $display);
+ $this->assertStringContainsString(AzineNotifierServiceMock::FAILED_ADDRESS, $display);
}
/**
@@ -80,6 +80,6 @@ public function testLockingFunctionality()
usleep(10);
}
- $this->assertContains('The command is already running in another process.', $process2->getOutput().$process1->getOutput());
+ $this->assertStringContainsString('The command is already running in another process.', $process2->getOutput().$process1->getOutput());
}
}
diff --git a/Tests/Compat/TwigEngineCompat.php b/Tests/Compat/TwigEngineCompat.php
new file mode 100644
index 00000000..1d9d06c1
--- /dev/null
+++ b/Tests/Compat/TwigEngineCompat.php
@@ -0,0 +1,13 @@
+filter('input')->count() && 1 == $crawler->filter('#username')->count() && 1 == $crawler->filter('#password')->count()) {
// set the password of the admin
- $userProvider = $this->getContainer()->get('fos_user.user_provider.username_email');
+ $userProvider = $this->getLegacyContainer()->get('fos_user.user_provider.username_email');
$user = $userProvider->loadUserByUsername($username);
$user->setPlainPassword($password);
$user->addRole('ROLE_ADMIN');
- $userManager = $this->getContainer()->get('fos_user.user_manager');
+ $userManager = $this->getLegacyContainer()->get('fos_user.user_manager');
$userManager->updateUser($user);
$crawler = $crawler->filter("input[type='submit']");
@@ -130,7 +130,7 @@ private function loginUserIfRequired(Client $client, $url, $username = 'dominik'
*/
private function getRouter()
{
- return $this->getContainer()->get('router');
+ return $this->getLegacyContainer()->get('router');
}
/**
@@ -138,10 +138,10 @@ private function getRouter()
*
* @return \Symfony\Component\DependencyInjection\ContainerInterface
*/
- private function getContainer()
+ private function getLegacyContainer()
{
if (null == $this->appContainer) {
- $this->appContainer = static::$kernel->getContainer();
+ $this->appContainer = static::$kernel->getLegacyContainer();
}
return $this->appContainer;
@@ -152,7 +152,7 @@ private function getContainer()
*/
private function getEntityManager()
{
- return $this->getContainer()->get('doctrine.orm.entity_manager');
+ return $this->getLegacyContainer()->get('doctrine.orm.entity_manager');
}
/**
diff --git a/Tests/Controller/AzineEmailTemplateControllerTest.php b/Tests/Controller/AzineEmailTemplateControllerTest.php
index 1183e5d0..4bc3fed1 100644
--- a/Tests/Controller/AzineEmailTemplateControllerTest.php
+++ b/Tests/Controller/AzineEmailTemplateControllerTest.php
@@ -10,7 +10,7 @@
use Azine\EmailBundle\Tests\FindInFileUtil;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\ParameterBag;
+use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
@@ -27,7 +27,7 @@ class AzineEmailTemplateControllerTest extends WebTestCase
/**
* delete all files from spool-folder.
*/
- protected function setUp()
+ protected function setUp(): void
{
}
@@ -84,7 +84,7 @@ public function testWebPreViewAction()
{
$requestMock = $this->getMockBuilder("Symfony\Component\HttpFoundation\Request")->disableOriginalConstructor()->setMethods(array('getLocale'))->getMock();
$requestMock->expects($this->exactly(3))->method('getLocale')->will($this->returnValue('en'));
- $requestMock->query = new ParameterBag();
+ $requestMock->query = new InputBag();
$webViewServiceMock = $this->getMockBuilder("Azine\EmailBundle\Services\AzineWebViewService")->disableOriginalConstructor()->getMock();
$webViewServiceMock->expects($this->exactly(3))->method('getDummyVarsFor')->will($this->returnValue(array()));
$twigMock = $this->getMockBuilder("Symfony\Bundle\TwigBundle\TwigEngine")->disableOriginalConstructor()->getMock();
@@ -121,7 +121,7 @@ public function testWebPreViewAction()
$controller->webPreViewAction($requestMock, AzineTemplateProvider::NEWSLETTER_TEMPLATE, 'html');
$response = $controller->webPreViewAction($requestMock, AzineTemplateProvider::NEWSLETTER_TEMPLATE, 'txt');
$this->assertSame('text/plain', $response->headers->get('Content-Type'));
- $this->assertNotContains('getContent());
+ $this->assertStringNotContainsString('getContent());
}
public function testWebViewAction_User_access_allowed()
@@ -130,7 +130,7 @@ public function testWebViewAction_User_access_allowed()
$twigMock = $this->getMockBuilder("Symfony\Bundle\TwigBundle\TwigEngine")->disableOriginalConstructor()->getMock();
$twigMock->expects($this->once())->method('renderResponse')->will($this->returnCallback(array($this, 'renderResponseCallback')));
$userMail = 'a-user@email.com';
- $userMock = $this->getMockBuilder('FOS\UserBundle\Model\User')->getMock();
+ $userMock = $this->getMockBuilder('stdClass')->addMethods(array('getEmail', 'hasRole'))->getMock();
$userMock->expects($this->once())->method('getEmail')->will($this->returnValue($userMail));
$sentEmail = new SentEmail();
$sentEmail->setRecipients(array($userMail));
@@ -141,12 +141,12 @@ public function testWebViewAction_User_access_allowed()
$repositoryMock = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\SentEmailRepository")->disableOriginalConstructor()->setMethods(array('findOneByToken'))->getMock();
$repositoryMock->expects($this->once())->method('findOneByToken')->will($this->returnValue($sentEmail));
$doctrineManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManagerMock")->disableOriginalConstructor()->getMock();
- $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineManagerRegistryMock->expects($this->once())->method('getRepository')->with('AzineEmailBundle:SentEmail')->will($this->returnValue($repositoryMock));
$doctrineManagerRegistryMock->expects($this->once())->method('getManager')->will($this->returnValue($this->returnValue($doctrineManagerMock)));
- $securityTokenMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\TokenInterface")->disableOriginalConstructor()->getMock();
+ $securityTokenMock = $this->getMockBuilder('stdClass')->addMethods(array('getUser'))->getMock();
$securityTokenMock->expects($this->exactly(2))->method('getUser')->will($this->returnValue($userMock));
- $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage")->disableOriginalConstructor()->getMock();
+ $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface")->disableOriginalConstructor()->getMock();
$tokenStorageMock->expects($this->once())->method('getToken')->will($this->returnValue($securityTokenMock));
$templateProviderMock = $this->getMockBuilder("Azine\EmailBundle\Services\AzineTemplateProvider")->disableOriginalConstructor()->getMock();
$templateProviderMock->expects($this->once())->method('getWebViewTokenId')->will($this->returnValue('tokenId'));
@@ -177,12 +177,12 @@ public function testWebViewAction_Anonymous_access_allowed()
$repositoryMock = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\SentEmailRepository")->disableOriginalConstructor()->setMethods(array('findOneByToken'))->getMock();
$repositoryMock->expects($this->once())->method('findOneByToken')->will($this->returnValue($sentEmail));
$doctrineManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManagerMock")->disableOriginalConstructor()->getMock();
- $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineManagerRegistryMock->expects($this->once())->method('getRepository')->with('AzineEmailBundle:SentEmail')->will($this->returnValue($repositoryMock));
$doctrineManagerRegistryMock->expects($this->once())->method('getManager')->will($this->returnValue($this->returnValue($doctrineManagerMock)));
- $securityTokenMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\TokenInterface")->disableOriginalConstructor()->getMock();
+ $securityTokenMock = $this->getMockBuilder('stdClass')->addMethods(array('getUser'))->getMock();
$securityTokenMock->expects($this->never())->method('getUser');
- $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage")->disableOriginalConstructor()->getMock();
+ $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface")->disableOriginalConstructor()->getMock();
$tokenStorageMock->expects($this->never())->method('getToken');
$templateProviderMock = $this->getMockBuilder("Azine\EmailBundle\Services\AzineTemplateProvider")->disableOriginalConstructor()->getMock();
$templateProviderMock->expects($this->once())->method('getWebViewTokenId')->will($this->returnValue('tokenId'));
@@ -207,7 +207,7 @@ public function testWebViewAction_User_access_denied()
{
$token = 'fdasdfasfafsadf';
$userMail = 'an-other-user@email.com';
- $userMock = $this->getMockBuilder('FOS\UserBundle\Model\User')->getMock();
+ $userMock = $this->getMockBuilder('stdClass')->addMethods(array('getEmail', 'hasRole'))->getMock();
$userMock->expects($this->once())->method('getEmail')->will($this->returnValue($userMail));
$sentEmail = new SentEmail();
$sentEmail->setRecipients(array('someuser@email.com'));
@@ -218,11 +218,11 @@ public function testWebViewAction_User_access_denied()
$repositoryMock = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\SentEmailRepository")->disableOriginalConstructor()->setMethods(array('findOneByToken'))->getMock();
$repositoryMock->expects($this->once())->method('findOneByToken')->will($this->returnValue($sentEmail));
$doctrineManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManagerMock")->disableOriginalConstructor()->getMock();
- $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineManagerRegistryMock->expects($this->once())->method('getRepository')->with('AzineEmailBundle:SentEmail')->will($this->returnValue($repositoryMock));
- $securityTokenMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\TokenInterface")->disableOriginalConstructor()->getMock();
+ $securityTokenMock = $this->getMockBuilder('stdClass')->addMethods(array('getUser'))->getMock();
$securityTokenMock->expects($this->exactly(2))->method('getUser')->will($this->returnValue($userMock));
- $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage")->disableOriginalConstructor()->getMock();
+ $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface")->disableOriginalConstructor()->getMock();
$tokenStorageMock->expects($this->once())->method('getToken')->will($this->returnValue($securityTokenMock));
$translatorMock = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Translation\Translator")->disableOriginalConstructor()->setMethods(array('trans'))->getMock();
$translatorMock->expects($this->once())->method('trans')->will($this->returnValue('translation'));
@@ -254,11 +254,11 @@ public function testWebViewAction_Anonymous_Access_denied()
$repositoryMock = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\SentEmailRepository")->disableOriginalConstructor()->setMethods(array('findOneByToken'))->getMock();
$repositoryMock->expects($this->once())->method('findOneByToken')->will($this->returnValue($sentEmail));
$doctrineManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManagerMock")->disableOriginalConstructor()->getMock();
- $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineManagerRegistryMock->expects($this->once())->method('getRepository')->with('AzineEmailBundle:SentEmail')->will($this->returnValue($repositoryMock));
- $securityTokenMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\TokenInterface")->disableOriginalConstructor()->getMock();
+ $securityTokenMock = $this->getMockBuilder('stdClass')->addMethods(array('getUser'))->getMock();
$securityTokenMock->expects($this->once())->method('getUser')->will($this->returnValue(null));
- $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage")->disableOriginalConstructor()->getMock();
+ $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface")->disableOriginalConstructor()->getMock();
$tokenStorageMock->expects($this->once())->method('getToken')->will($this->returnValue($securityTokenMock));
$translatorMock = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Translation\Translator")->disableOriginalConstructor()->setMethods(array('trans'))->getMock();
$translatorMock->expects($this->once())->method('trans')->will($this->returnValue('translation'));
@@ -280,7 +280,7 @@ public function testWebViewAction_Admin_with_CampaignParams()
$token = 'fdasdfasfafsadf';
$twigMock = $this->getMockBuilder("Symfony\Bundle\TwigBundle\TwigEngine")->disableOriginalConstructor()->getMock();
$twigMock->expects($this->once())->method('renderResponse')->will($this->returnCallback(array($this, 'renderResponseCallback')));
- $userMock = $this->getMockBuilder('FOS\UserBundle\Model\User')->getMock();
+ $userMock = $this->getMockBuilder('stdClass')->addMethods(array('getEmail', 'hasRole'))->getMock();
$userMock->expects($this->once())->method('getEmail')->will($this->returnValue('admin@email.com'));
$userMock->expects($this->once())->method('hasRole')->with('ROLE_ADMIN')->will($this->returnValue(true));
$sentEmail = new SentEmail();
@@ -292,12 +292,12 @@ public function testWebViewAction_Admin_with_CampaignParams()
$repositoryMock = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\SentEmailRepository")->disableOriginalConstructor()->setMethods(array('findOneByToken'))->getMock();
$repositoryMock->expects($this->once())->method('findOneByToken')->will($this->returnValue($sentEmail));
$doctrineManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManagerMock")->disableOriginalConstructor()->getMock();
- $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineManagerRegistryMock->expects($this->once())->method('getRepository')->with('AzineEmailBundle:SentEmail')->will($this->returnValue($repositoryMock));
$doctrineManagerRegistryMock->expects($this->once())->method('getManager')->will($this->returnValue($this->returnValue($doctrineManagerMock)));
- $securityTokenMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\TokenInterface")->disableOriginalConstructor()->getMock();
+ $securityTokenMock = $this->getMockBuilder('stdClass')->addMethods(array('getUser'))->getMock();
$securityTokenMock->expects($this->exactly(2))->method('getUser')->will($this->returnValue($userMock));
- $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage")->disableOriginalConstructor()->getMock();
+ $tokenStorageMock = $this->getMockBuilder("Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface")->disableOriginalConstructor()->getMock();
$tokenStorageMock->expects($this->once())->method('getToken')->will($this->returnValue($securityTokenMock));
$translatorMock = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Translation\Translator")->disableOriginalConstructor()->getMock();
$translatorMock->expects($this->any())->method('trans')->will($this->returnArgument(0));
@@ -318,8 +318,8 @@ public function testWebViewAction_Admin_with_CampaignParams()
$controller = new AzineEmailTemplateController();
$controller->setContainer($containerMock);
$response = $controller->webViewAction($requestMock, $token);
- $this->assertContains('http://testurl.com/?campaign=newsletter&keyword=2013-11-19', $response->getContent());
- $this->assertContains('http://testurl.com/with/?param=1&campaign=newsletter&keyword=2013-11-19', $response->getContent());
+ $this->assertStringContainsString('http://testurl.com/?campaign=newsletter&keyword=2013-11-19', $response->getContent());
+ $this->assertStringContainsString('http://testurl.com/with/?param=1&campaign=newsletter&keyword=2013-11-19', $response->getContent());
}
public function testWebViewAction_MailNotFound()
@@ -329,7 +329,7 @@ public function testWebViewAction_MailNotFound()
$twigMock->expects($this->once())->method('renderResponse')->will($this->returnCallback(array($this, 'renderResponseCallback')));
$repositoryMock = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\SentEmailRepository")->disableOriginalConstructor()->setMethods(array('findOneByToken'))->getMock();
$repositoryMock->expects($this->once())->method('findOneByToken')->will($this->returnValue(null));
- $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $doctrineManagerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$doctrineManagerRegistryMock->expects($this->once())->method('getRepository')->with('AzineEmailBundle:SentEmail')->will($this->returnValue($repositoryMock));
$containerMock = $this->getMockBuilder("Symfony\Component\DependencyInjection\ContainerInterface")->disableOriginalConstructor()->getMock();
$containerMock->expects($this->once())->method('getParameter')->with('azine_email_web_view_retention')->will($this->returnValue(123));
@@ -423,7 +423,7 @@ public function testSendTestEmailAction()
$response = $controller->sendTestEmailAction($container->get('request'), AzineTemplateProvider::NEWSLETTER_TEMPLATE, $to);
$this->assertSame(302, $response->getStatusCode(), 'Status-Code 302 expected.');
$uri = $router->generate('azine_email_template_index');
- $this->assertContains("Redirecting to $uri", $response->getContent(), 'Redirect expected.');
+ $this->assertStringContainsString("Redirecting to $uri", $response->getContent(), 'Redirect expected.');
$findInFile = new FindInFileUtil();
$findInFile->excludeMode = false;
$findInFile->formats = array('.message');
@@ -492,7 +492,7 @@ public function testCheckSpamScoreOfSentEmailAction()
if (false !== strpos($json, 'Getting the spam-info failed')) {
$this->markTestIncomplete("It seems postmarks spam-check-service is unresponsive.\n\n$json");
}
- $this->assertNotContains('Getting the spam-info failed.', $jsonResponse->getContent(), "Spamcheck returned:\n".$jsonResponse->getContent());
- $this->assertContains('SpamScore', $jsonResponse->getContent());
+ $this->assertStringNotContainsString('Getting the spam-info failed.', $jsonResponse->getContent(), "Spamcheck returned:\n".$jsonResponse->getContent());
+ $this->assertStringContainsString('SpamScore', $jsonResponse->getContent());
}
}
diff --git a/Tests/DependencyInjection/AzineEmailExtensionTest.php b/Tests/DependencyInjection/AzineEmailExtensionTest.php
index 0abcc185..1b537ac3 100644
--- a/Tests/DependencyInjection/AzineEmailExtensionTest.php
+++ b/Tests/DependencyInjection/AzineEmailExtensionTest.php
@@ -224,7 +224,7 @@ private function assertNotHasDefinition($id)
$this->assertFalse(($this->configuration->hasDefinition($id) ?: $this->configuration->hasAlias($id)));
}
- protected function tearDown()
+ protected function tearDown(): void
{
unset($this->configuration);
}
diff --git a/Tests/Entity/SentEmailTest.php b/Tests/Entity/SentEmailTest.php
index 95f17695..63ce0eb4 100644
--- a/Tests/Entity/SentEmailTest.php
+++ b/Tests/Entity/SentEmailTest.php
@@ -11,7 +11,7 @@ public function testGetNewToken()
$tockens = array();
while (sizeof($tockens) < 100) {
$newToken = SentEmail::getNewToken();
- $this->assertNotContains($newToken, $tockens);
+ $this->assertStringNotContainsString($newToken, $tockens);
$tockens[] = $newToken;
}
}
diff --git a/Tests/Functional/EmailImagesInEmailAndWebViewTest.php b/Tests/Functional/EmailImagesInEmailAndWebViewTest.php
index c534911e..818b5415 100644
--- a/Tests/Functional/EmailImagesInEmailAndWebViewTest.php
+++ b/Tests/Functional/EmailImagesInEmailAndWebViewTest.php
@@ -37,7 +37,7 @@ class EmailImagesInEmailAndWebViewTest extends WebTestCase
/** @var array */
private $testImages = array();
- public function setUp()
+ public function setUp(): void
{
$this->uniqueId = md5(microtime().'_'.random_int(0, 1000));
@@ -100,7 +100,7 @@ public function testImagesFromAllConfiguredAllowedFolders()
$this->verifyWebView();
}
- public function tearDown()
+ public function tearDown(): void
{
// revert the test-User password & salt
$this->testRecipient->setPassword($this->originalUserPassword);
diff --git a/Tests/Services/AzineEmailTwigExtensionTest.php b/Tests/Services/AzineEmailTwigExtensionTest.php
index 23664e23..4cfe7c11 100644
--- a/Tests/Services/AzineEmailTwigExtensionTest.php
+++ b/Tests/Services/AzineEmailTwigExtensionTest.php
@@ -98,11 +98,11 @@ public function testStripAndConvertTags()
$twigExtension = $this->getAzineEmailTwigExtensionWithMocks();
$txt = $twigExtension->stripAndConvertTags($html);
- $this->assertContains('link text1: http://acme.com/link1', $txt, "Link with html as link-text didn't work as expected.");
- $this->assertContains('link text2: http://acme.com/link2', $txt, "Link with html and linebreaks as link-text didn't work as expected.");
- $this->assertContains('http://acme.com/link3', $txt, "Link with url as link-text didn't work as expected.");
- $this->assertNotContains('link text3: http://acme.com/link3', $txt, "Link with url as link-text didn't work as expected.");
- $this->assertContains('here: http://acme.com/link4', $txt, "Link with url as link-text didn't work as expected.");
+ $this->assertStringContainsString('link text1: http://acme.com/link1', $txt, "Link with html as link-text didn't work as expected.");
+ $this->assertStringContainsString('link text2: http://acme.com/link2', $txt, "Link with html and linebreaks as link-text didn't work as expected.");
+ $this->assertStringContainsString('http://acme.com/link3', $txt, "Link with url as link-text didn't work as expected.");
+ $this->assertStringNotContainsString('link text3: http://acme.com/link3', $txt, "Link with url as link-text didn't work as expected.");
+ $this->assertStringContainsString('here: http://acme.com/link4', $txt, "Link with url as link-text didn't work as expected.");
}
/**
diff --git a/Tests/Services/AzineNotifierServiceTest.php b/Tests/Services/AzineNotifierServiceTest.php
index 186f51b9..e360b9b1 100644
--- a/Tests/Services/AzineNotifierServiceTest.php
+++ b/Tests/Services/AzineNotifierServiceTest.php
@@ -19,7 +19,7 @@ private function getMockSetup()
$mocks['router'] = $this->getMockBuilder("Symfony\Component\Routing\Generator\UrlGeneratorInterface")->disableOriginalConstructor()->getMock();
$mocks['entityManager'] = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
$mocks['notificationRepository'] = $this->getMockBuilder("Azine\EmailBundle\Entity\Repositories\NotificationRepository")->disableOriginalConstructor()->getMock();
- $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$mocks['managerRegistry']->expects($this->any())->method('getManager')->will($this->returnValue($mocks['entityManager']));
$mocks['managerRegistry']->expects($this->any())->method('getRepository')->will($this->returnValue($mocks['notificationRepository']));
$mocks['templateProvider'] = $this->getMockBuilder("Azine\EmailBundle\Services\TemplateProviderInterface")->disableOriginalConstructor()->getMock();
diff --git a/Tests/Services/AzineRecipientProviderTest.php b/Tests/Services/AzineRecipientProviderTest.php
index eb3730d6..23728884 100644
--- a/Tests/Services/AzineRecipientProviderTest.php
+++ b/Tests/Services/AzineRecipientProviderTest.php
@@ -21,7 +21,7 @@ public function testGetRecipient()
$entityManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
$entityManagerMock->expects($this->once())->method('getRepository')->will($this->returnValue($repositoryMock));
- $managerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $managerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$managerRegistryMock->expects($this->any())->method('getManager')->will($this->returnValue($entityManagerMock));
$recipientProvider = new AzineRecipientProvider($managerRegistryMock, 'a-user-class', 'newsletterField');
@@ -46,7 +46,7 @@ public function testGetNewsletterRecipientIDs()
$entityManagerMock = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
$entityManagerMock->expects($this->once())->method('createQueryBuilder')->will($this->returnValue($queryBuilderMock));
- $managerRegistryMock = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $managerRegistryMock = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$managerRegistryMock->expects($this->any())->method('getManager')->will($this->returnValue($entityManagerMock));
$recipientProvider = new AzineRecipientProvider($managerRegistryMock, 'a-user-class', 'newsletterField');
diff --git a/Tests/Services/AzineTwigSwiftMailerTest.php b/Tests/Services/AzineTwigSwiftMailerTest.php
index 1de73aff..02851364 100644
--- a/Tests/Services/AzineTwigSwiftMailerTest.php
+++ b/Tests/Services/AzineTwigSwiftMailerTest.php
@@ -15,7 +15,7 @@ private function getMockSetup($sendCallback)
$mocks['mailer']->expects($this->once())->method('send')->will($this->returnCallback($sendCallback));
$mocks['router'] = $this->getMockBuilder("Symfony\Component\Routing\Generator\UrlGeneratorInterface")->disableOriginalConstructor()->getMock();
$mocks['twig'] = $this->getMockBuilder("\Twig_Environment")->disableOriginalConstructor()->getMock();
- $mocks['baseTemplateMock'] = $this->getMockBuilder("\Twig_Template")->disableOriginalConstructor()->setMethods(array('renderBlock'))->getMockForAbstractClass();
+ $mocks['baseTemplateMock'] = $this->getMockBuilder("\Twig\Template")->disableOriginalConstructor()->setMethods(array('renderBlock'))->getMockForAbstractClass();
$mocks['twig']->expects($this->once())->method('loadTemplate')->will($this->returnValue($mocks['baseTemplateMock']));
$mocks['translator'] = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Translation\Translator")->disableOriginalConstructor()->getMock();
@@ -33,7 +33,7 @@ private function getMockSetup($sendCallback)
$this->getMockBuilder("Azine\EmailBundle\Services\AzineTemplateProvider")->disableOriginalConstructor()->getMock();
$mocks['entityManager'] = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
- $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$mocks['managerRegistry']->expects($this->any())->method('getManager')->will($this->returnValue($mocks['entityManager']));
$mocks['parameters'] = array(AzineEmailExtension::NO_REPLY => array(
@@ -74,10 +74,10 @@ public function returnOneValidateCampaignUrls($message, &$failedRecipients = nul
$body = $message->getBody();
// has a email-tracking-image at the end
- $this->assertContains("
assertStringContainsString("
assertContains('&utm_medium=email', $body, 'Email links are expected to have tracking parameters attached.');
+ $this->assertStringContainsString('&utm_medium=email', $body, 'Email links are expected to have tracking parameters attached.');
return 1;
}
@@ -155,7 +155,7 @@ public function testSendSingleEmailFails()
$mocks['mailer']->expects($this->once())->method('send')->will($this->returnCallback(array($this, 'returnZeroWithFailedAddress')));
$mocks['router'] = $this->getMockBuilder("Symfony\Component\Routing\Generator\UrlGeneratorInterface")->disableOriginalConstructor()->getMock();
$mocks['twig'] = $this->getMockBuilder("\Twig_Environment")->disableOriginalConstructor()->getMock();
- $mocks['baseTemplateMock'] = $this->getMockBuilder("\Twig_Template")->disableOriginalConstructor()->setMethods(array('renderBlock'))->getMockForAbstractClass();
+ $mocks['baseTemplateMock'] = $this->getMockBuilder("\Twig\Template")->disableOriginalConstructor()->setMethods(array('renderBlock'))->getMockForAbstractClass();
$mocks['twig']->expects($this->once())->method('loadTemplate')->will($this->returnValue($mocks['baseTemplateMock']));
$mocks['translator'] = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Translation\Translator")->disableOriginalConstructor()->getMock();
@@ -173,7 +173,7 @@ public function testSendSingleEmailFails()
$this->getMockBuilder("Azine\EmailBundle\Services\AzineTemplateProvider")->disableOriginalConstructor()->getMock();
$mocks['entityManager'] = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
- $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$mocks['managerRegistry']->expects($this->any())->method('getManager')->will($this->returnValue($mocks['entityManager']));
$mocks['parameters'] = array(AzineEmailExtension::NO_REPLY => array(
@@ -267,7 +267,7 @@ public function testSendEmailWithEmailLocaleAndInexistentAttachment()
$mocks['router'] = $this->getMockBuilder("Symfony\Component\Routing\Generator\UrlGeneratorInterface")->disableOriginalConstructor()->getMock();
$mocks['twig'] = $this->getMockBuilder("\Twig_Environment")->disableOriginalConstructor()->getMock();
- $mocks['baseTemplateMock'] = $this->getMockBuilder("\Twig_Template")->disableOriginalConstructor()->setMethods(array('renderBlock'))->getMockForAbstractClass();
+ $mocks['baseTemplateMock'] = $this->getMockBuilder("\Twig\Template")->disableOriginalConstructor()->setMethods(array('renderBlock'))->getMockForAbstractClass();
$mocks['twig']->expects($this->once())->method('loadTemplate')->will($this->returnValue($mocks['baseTemplateMock']));
$mocks['translator'] = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Translation\Translator")->disableOriginalConstructor()->getMock();
@@ -285,7 +285,7 @@ public function testSendEmailWithEmailLocaleAndInexistentAttachment()
$this->getMockBuilder("Azine\EmailBundle\Services\AzineTemplateProvider")->disableOriginalConstructor()->getMock();
$mocks['entityManager'] = $this->getMockBuilder("Doctrine\ORM\EntityManager")->disableOriginalConstructor()->getMock();
- $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Common\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
+ $mocks['managerRegistry'] = $this->getMockBuilder("Doctrine\Persistence\ManagerRegistry")->disableOriginalConstructor()->getMock();
$mocks['managerRegistry']->expects($this->any())->method('getManager')->will($this->returnValue($mocks['entityManager']));
$mocks['parameters'] = array(AzineEmailExtension::NO_REPLY => array(
diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php
index 7ff641f4..a69f4014 100644
--- a/Tests/bootstrap.php
+++ b/Tests/bootstrap.php
@@ -12,3 +12,11 @@ class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
} elseif (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase')) {
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
}
+
+if (!class_exists('Symfony\\Bundle\\TwigBundle\\TwigEngine')) {
+ class_alias('Azine\\EmailBundle\\Tests\\Compat\\TwigEngineCompat', 'Symfony\\Bundle\\TwigBundle\\TwigEngine');
+}
+
+if (!class_exists('Doctrine\\Common\\Persistence\\ManagerRegistry') && class_exists('Doctrine\\Persistence\\ManagerRegistry')) {
+ class_alias('Doctrine\\Persistence\\ManagerRegistry', 'Doctrine\\Common\\Persistence\\ManagerRegistry');
+}
diff --git a/UPGRADE.md b/UPGRADE.md
index c7567a6d..9712e210 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -121,4 +121,18 @@ To support the full tracking functionality of google analytics the tracking para
### Optional changes
-- if you use piwik to do the tracking, then install https://plugins.piwik.org/AdvancedCampaignReporting to get the best out of it.
\ No newline at end of file
+- if you use piwik to do the tracking, then install https://plugins.piwik.org/AdvancedCampaignReporting to get the best out of it.
+
+## Upgrade to PHP 8.5 / Symfony 7.4
+
+### Dependency changes
+- Minimum PHP is now `8.5`.
+- Symfony components are now constrained to `^7.4`.
+- PHPUnit was upgraded to `^11.5` and `phpunit.xml.dist` now uses the PHPUnit 11 schema.
+- Legacy hard dependency on `friendsofsymfony/user-bundle` was removed (it is now optional in `suggest`).
+- `twig/extensions` was replaced by `twig/extra-bundle`.
+
+### CI changes
+- Travis CI configuration was removed.
+- GitHub Actions now runs composer validation and the PHPUnit suite on every push and pull request.
+
diff --git a/composer.json b/composer.json
index 1b5624a6..4539c2c0 100644
--- a/composer.json
+++ b/composer.json
@@ -1,8 +1,16 @@
{
"name": "azine/email-bundle",
"type": "symfony-bundle",
- "description": "Symfony3 Bundle to send html- & txt-emails (notification about events on your web-app or newsletters etc. scheduled/aggregated) to your users.",
- "keywords": ["email", "newsletter", "notification", "updates", "email web view", "mailgun", "email open tracking"],
+ "description": "Symfony bundle to send HTML/text emails (notifications, newsletters, web-view archives).",
+ "keywords": [
+ "email",
+ "newsletter",
+ "notification",
+ "updates",
+ "email web view",
+ "mailgun",
+ "email open tracking"
+ ],
"homepage": "https://github.com/azine/email-bundle",
"license": "MIT",
"authors": [
@@ -13,34 +21,41 @@
],
"config": {
"process-timeout": 590,
- "github-protocols": ["https", "git", "ssh"],
- "github-domains": ["github.com"]
+ "sort-packages": true,
+ "allow-plugins": {
+ "php-http/discovery": true
+ }
},
"require": {
- "php": ">=5.6.0",
- "symfony/framework-bundle": "~2.7|^3.0|^4.0",
- "symfony/console": "~2.7|^3.0|^4.0",
- "symfony/finder": "~2.7|^3.0|^4.0",
- "symfony/twig-bundle": "~2.7|^3.0|^4.0",
- "symfony/filesystem": "~2.7|^3.0|^4.0",
- "symfony/yaml": "~2.7|^3.0|^4.0",
- "swiftmailer/swiftmailer": ">=5.4.5,~5.0|^6.0",
- "doctrine/orm": "~2.0,>=2.2",
- "monolog/monolog": "~1.6,>=1.6.0",
- "friendsofsymfony/user-bundle": "~2.0",
- "twig/extensions": "~1.0",
- "ramsey/uuid": "~3.2",
- "knplabs/knp-paginator-bundle": "^2.6",
- "azine/emailupdateconfirmation-bundle": "~1.0",
- "symfony/lock": ">=3.4"
+ "php": "^8.5",
+ "doctrine/orm": "^2.20 || ^3.0",
+ "knplabs/knp-paginator-bundle": "^6.0",
+ "monolog/monolog": "^2.9 || ^3.0",
+ "ramsey/uuid": "^4.7",
+ "swiftmailer/swiftmailer": "^6.3",
+ "symfony/console": "^7.4",
+ "symfony/filesystem": "^7.4",
+ "symfony/finder": "^7.4",
+ "symfony/framework-bundle": "^7.4",
+ "symfony/lock": "^7.4",
+ "symfony/twig-bundle": "^7.4",
+ "symfony/yaml": "^7.4",
+ "twig/extra-bundle": "^3.0"
},
"require-dev": {
- "symfony/translation": "~2.7|^3.0|^4.0",
- "phpunit/phpunit": "~5.7.27|^6.0|^7.0",
- "friendsofphp/php-cs-fixer": "^2.2"
+ "friendsofphp/php-cs-fixer": "^3.59",
+ "phpunit/phpunit": "^9.6",
+ "symfony/phpunit-bridge": "^7.4",
+ "symfony/translation": "^7.4"
+ },
+ "suggest": {
+ "friendsofsymfony/user-bundle": "Optional: integrate bundle helpers with FOSUser templates and user model.",
+ "azine/emailupdateconfirmation-bundle": "Optional legacy integration; current releases are tied to Symfony <=4 and are not compatible with Symfony 7.4."
},
"autoload": {
- "psr-4": { "Azine\\EmailBundle\\": "" }
+ "psr-4": {
+ "Azine\\EmailBundle\\": ""
+ }
},
"minimum-stability": "stable"
-}
+}
\ No newline at end of file
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0818b689..85880e4a 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,5 +1,4 @@
-
-
diff --git a/travis.php.ini b/travis.php.ini
deleted file mode 100644
index 7999e961..00000000
--- a/travis.php.ini
+++ /dev/null
@@ -1 +0,0 @@
-memory_limit = -1