diff --git a/.php_cs.dist b/.php_cs.dist index d5294a39..d62705e6 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,13 +1,12 @@ 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) ; diff --git a/Command/DebugCommand.php b/Command/DebugCommand.php index 320de536..5d602d7e 100644 --- a/Command/DebugCommand.php +++ b/Command/DebugCommand.php @@ -50,6 +50,9 @@ protected function configure() ; } + /** + * @return int + */ protected function execute(InputInterface $input, OutputInterface $output) { $this->io = new SymfonyStyle($input, $output); @@ -60,6 +63,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $this->outputMailers(); } + + return 0; } protected function outputMailers($routes = null) diff --git a/Command/NewEmailCommand.php b/Command/NewEmailCommand.php index b53a2a0b..99981c09 100644 --- a/Command/NewEmailCommand.php +++ b/Command/NewEmailCommand.php @@ -67,7 +67,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) } /** - * {@inheritdoc} + * @return int */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -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; } /** diff --git a/Command/SendEmailCommand.php b/Command/SendEmailCommand.php index e8c3e638..5646d95a 100644 --- a/Command/SendEmailCommand.php +++ b/Command/SendEmailCommand.php @@ -51,6 +51,9 @@ protected function configure() ; } + /** + * @return int + */ protected function execute(InputInterface $input, OutputInterface $output) { $this->io = new SymfonyStyle($input, $output); @@ -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) diff --git a/Tests/Command/SendEmailCommandTest.php b/Tests/Command/SendEmailCommandTest.php index 14ce2a0d..a22849ce 100644 --- a/Tests/Command/SendEmailCommandTest.php +++ b/Tests/Command/SendEmailCommandTest.php @@ -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); @@ -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); diff --git a/Tests/DependencyInjection/SwiftmailerExtensionTest.php b/Tests/DependencyInjection/SwiftmailerExtensionTest.php index 36fb721e..f9cdb657 100644 --- a/Tests/DependencyInjection/SwiftmailerExtensionTest.php +++ b/Tests/DependencyInjection/SwiftmailerExtensionTest.php @@ -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); @@ -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); @@ -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); } diff --git a/Tests/DependencyInjection/SwiftmailerTransportFactoryTest.php b/Tests/DependencyInjection/SwiftmailerTransportFactoryTest.php index 95de98d4..56f7864b 100644 --- a/Tests/DependencyInjection/SwiftmailerTransportFactoryTest.php +++ b/Tests/DependencyInjection/SwiftmailerTransportFactoryTest.php @@ -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', @@ -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', @@ -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', diff --git a/composer.json b/composer.json index 609b16c7..bbe796e5 100644 --- a/composer.json +++ b/composer.json @@ -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"