[BUGFIX] Adapt SendEmailCommandTest for symfony/mailer 33/61233/2
authorBenjamin Franzke <bfr@qbus.de>
Fri, 5 Jul 2019 11:25:51 +0000 (13:25 +0200)
committerBenjamin Franzke <bfr@qbus.de>
Fri, 5 Jul 2019 12:22:42 +0000 (14:22 +0200)
The tests produced a warning which didn't cause CI to abort,
but the test was actually skipped:

1) TYPO3\CMS\Core\Tests\Unit\Command\SendEmailCommandTest
     ::executeWillFlushTheQueue
   Trying to configure method "flushQueue" which cannot be configured
   because it does not exist, has not been specified, is final, or is
   static

Resolves: #88692
Related: #88643
Releases: master
Change-Id: I3077a011e19050986585e9c788f5db03d18595d3
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61233
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Alexander Schnitzler <review.typo3.org@alexanderschnitzler.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Alexander Schnitzler <review.typo3.org@alexanderschnitzler.de>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
typo3/sysext/core/Tests/Unit/Command/SendEmailCommandTest.php

index 4f789a2..1d293f3 100644 (file)
@@ -15,8 +15,11 @@ namespace TYPO3\CMS\Core\Tests\Unit\Command;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
 use Symfony\Component\Console\Tester\CommandTester;
+use Symfony\Component\Mailer\Transport\TransportInterface;
 use TYPO3\CMS\Core\Command\SendEmailCommand;
+use TYPO3\CMS\Core\Mail\DelayedTransportInterface;
 use TYPO3\CMS\Core\Mail\Mailer;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -30,16 +33,9 @@ class SendEmailCommandTest extends UnitTestCase
      */
     public function executeWillFlushTheQueue()
     {
-        $realTransport = $this->getMockBuilder(\Swift_Transport::class)->getMock();
-
-        $spool = $this->getMockBuilder(\Swift_Spool::class)->getMock();
-        $spool
-            ->expects($this->once())
-            ->method('flushQueue')
-            ->with($realTransport)
-            ->will($this->returnValue(5))
-        ;
-        $spoolTransport = new \Swift_Transport_SpoolTransport(new \Swift_Events_SimpleEventDispatcher(), $spool);
+        $delayedTransportProphecy = $this->prophesize(DelayedTransportInterface::class);
+        $delayedTransportProphecy->flushQueue(Argument::any())->willReturn(5);
+        $realTransportProphecy = $this->prophesize(TransportInterface::class);
 
         $mailer = $this->getMockBuilder(Mailer::class)
             ->disableOriginalConstructor()
@@ -49,16 +45,16 @@ class SendEmailCommandTest extends UnitTestCase
         $mailer
             ->expects($this->any())
             ->method('getTransport')
-            ->will($this->returnValue($spoolTransport));
+            ->will($this->returnValue($delayedTransportProphecy->reveal()));
 
         $mailer
             ->expects($this->any())
             ->method('getRealTransport')
-            ->will($this->returnValue($realTransport));
+            ->will($this->returnValue($realTransportProphecy->reveal()));
 
         /** @var SendEmailCommand|\PHPUnit_Framework_MockObject_MockObject $command */
         $command = $this->getMockBuilder(SendEmailCommand::class)
-            ->setConstructorArgs(['swiftmailer:spool:send'])
+            ->setConstructorArgs(['mailer:spool:send'])
             ->setMethods(['getMailer'])
             ->getMock();