Skip to content
This repository has been archived by the owner on Feb 6, 2022. It is now read-only.

Commit

Permalink
Allow Symfony 5
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Oct 20, 2019
1 parent aaae8dc commit 44587b5
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 29 deletions.
7 changes: 3 additions & 4 deletions .php_cs.dist
@@ -1,13 +1,12 @@
<?php

return PhpCsFixer\Config::create()
->setRules(array(
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'@PHPUnit48Migration:risky' => true,
'php_unit_no_expectation_annotation' => false, // part of `PHPUnitXYMigration:risky` ruleset, to be enabled when PHPUnit 4.x support will be dropped, as we don't want to rewrite exceptions handling twice
'@PHPUnit75Migration:risky' => true,
'array_syntax' => array('syntax' => 'short'),
'protected_to_private' => false,
))
])
->setRiskyAllowed(true)
;
5 changes: 5 additions & 0 deletions Command/DebugCommand.php
Expand Up @@ -50,6 +50,9 @@ protected function configure()
;
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
Expand All @@ -60,6 +63,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$this->outputMailers();
}

return 0;
}

protected function outputMailers($routes = null)
Expand Down
4 changes: 3 additions & 1 deletion Command/NewEmailCommand.php
Expand Up @@ -67,7 +67,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
}

/**
* {@inheritdoc}
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand Down Expand Up @@ -96,6 +96,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$sentMessages = $mailer->send($message);

$this->io->success(sprintf('%s emails were successfully sent.', $sentMessages));

return 0;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions Command/SendEmailCommand.php
Expand Up @@ -51,6 +51,9 @@ protected function configure()
;
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
Expand All @@ -64,6 +67,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->processMailer($name, $input, $output);
}
}

return 0;
}

private function processMailer($name, InputInterface $input, OutputInterface $output)
Expand Down
4 changes: 2 additions & 2 deletions Tests/Command/SendEmailCommandTest.php
Expand Up @@ -20,7 +20,7 @@ public function testRecoverSpoolTransport()
->expects($this->once())
->method('flushQueue')
->with($realTransport)
->will($this->returnValue(5))
->willReturn(5)
;

$spoolTransport = new \Swift_Transport_SpoolTransport(new \Swift_Events_SimpleEventDispatcher(), $spool);
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testRecoverLoadbalancedTransportWithSpool()
->expects($this->once())
->method('flushQueue')
->with($realTransport)
->will($this->returnValue(7))
->willReturn(7)
;

$spoolTransport = new \Swift_Transport_SpoolTransport(new \Swift_Events_SimpleEventDispatcher(), $spool);
Expand Down
7 changes: 4 additions & 3 deletions Tests/DependencyInjection/SwiftmailerExtensionTest.php
Expand Up @@ -52,7 +52,7 @@ public function getConfigTypes()
public function testDefaultConfig($type)
{
$requestContext = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->setMethods(['getHost'])->getMock();
$requestContext->expects($this->once())->method('getHost')->will($this->returnValue('example.org'));
$requestContext->expects($this->once())->method('getHost')->willReturn('example.org');
$services = ['router.request_context' => $requestContext];

$container = $this->loadContainerFromFile('empty', $type, $services);
Expand Down Expand Up @@ -83,7 +83,7 @@ public function testSendmailConfig($type)
{
// Local domain is specified explicitly, so the request context host is ignored.
$requestContext = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->setMethods(['getHost'])->getMock();
$requestContext->expects($this->any())->method('getHost')->will($this->returnValue('example.org'));
$requestContext->expects($this->any())->method('getHost')->willReturn('example.org');
$services = ['router.request_context' => $requestContext];

$container = $this->loadContainerFromFile('sendmail', $type, $services);
Expand Down Expand Up @@ -286,10 +286,11 @@ public function testServiceSpool($type)

/**
* @dataProvider getConfigTypes
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function testInvalidServiceSpool($type)
{
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);

$this->loadContainerFromFile('spool_service_invalid', $type);
}

Expand Down
21 changes: 9 additions & 12 deletions Tests/DependencyInjection/SwiftmailerTransportFactoryTest.php
Expand Up @@ -79,12 +79,11 @@ public function testCreateTransportWithNull()
$this->assertInstanceOf('Swift_Transport_NullTransport', $transport);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The fake_encryption encryption is not supported
*/
public function testCreateTransportWithWrongEncryption()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The fake_encryption encryption is not supported');

SwiftmailerTransportFactory::createTransport(
[
'transport' => 'smtp',
Expand All @@ -103,12 +102,11 @@ public function testCreateTransportWithWrongEncryption()
);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The fake_auth authentication mode is not supported
*/
public function testCreateTransportWithWrongAuthMode()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The fake_auth authentication mode is not supported');

SwiftmailerTransportFactory::createTransport(
[
'transport' => 'smtp',
Expand Down Expand Up @@ -161,12 +159,11 @@ public function testCreateTransportWithSmtpAndWithoutRequestContext()
$this->assertSame($authHandler->getAuthMode(), $options['auth_mode']);
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The Swiftmailer URL "smtp://localhost:25&auth_mode=cra-md5" is not valid.
*/
public function testCreateTransportWithBadURLFormat()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The Swiftmailer URL "smtp://localhost:25&auth_mode=cra-md5" is not valid.');

$options = [
'url' => 'smtp://localhost:25&auth_mode=cra-md5',
'transport' => 'smtp',
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Expand Up @@ -18,15 +18,15 @@
"require": {
"php": ">=7.0.0",
"swiftmailer/swiftmailer": "^6.1.3",
"symfony/dependency-injection": "~2.7|~3.3|~4.0",
"symfony/http-kernel": "~2.7|~3.3|~4.0",
"symfony/config": "~2.8|~3.3|~4.0"
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/http-kernel": "^3.4|^4.0|^5.0",
"symfony/config": "^3.4|^4.0|^5.0"
},
"require-dev": {
"symfony/console": "~2.7|~3.3|~4.0",
"symfony/framework-bundle": "~2.7|~3.3|~4.0",
"symfony/phpunit-bridge": "^3.4.32|^4.3.5",
"symfony/yaml": "~2.7|~3.3|~4.0"
"symfony/console": "^3.4|^4.0|^5.0",
"symfony/framework-bundle": "^3.4|^4.0|^5.0",
"symfony/phpunit-bridge": "^3.4.32|^4.3.5|^5.0",
"symfony/yaml": "^3.4|^4.0|^5.0"
},
"conflict": {
"twig/twig": "<1.41|<2.10"
Expand Down

0 comments on commit 44587b5

Please sign in to comment.