From: Joe Nahmias <jello@debian.org>
Date: Thu, 11 Sep 2025 22:46:38 -0400
Subject: switch to using createMock()

---
 .../ByteStream/FileByteStreamAcceptanceTest.php    |  2 +-
 .../AbstractStreamBufferAcceptanceTest.php         |  4 +-
 .../Transport/StreamBuffer/SocketTimeoutTest.php   |  2 +-
 .../unit/Swift/ByteStream/ArrayByteStreamTest.php  | 12 +++---
 tests/unit/Swift/Events/CommandEventTest.php       |  2 +-
 tests/unit/Swift/Events/ResponseEventTest.php      |  2 +-
 tests/unit/Swift/Events/SendEventTest.php          |  4 +-
 .../Swift/Events/SimpleEventDispatcherTest.php     | 44 +++++++++++-----------
 .../unit/Swift/Events/TransportChangeEventTest.php |  2 +-
 .../Swift/Events/TransportExceptionEventTest.php   |  2 +-
 tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php    |  6 +--
 .../KeyCache/SimpleKeyCacheInputStreamTest.php     |  6 +--
 tests/unit/Swift/Mime/AbstractMimeEntityTest.php   |  4 +-
 tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php  |  4 +-
 tests/unit/Swift/Mime/SimpleHeaderSetTest.php      |  4 +-
 tests/unit/Swift/Plugins/AntiFloodPluginTest.php   |  8 ++--
 .../Swift/Plugins/BandwidthMonitorPluginTest.php   | 14 ++-----
 tests/unit/Swift/Plugins/LoggerPluginTest.php      | 20 +++-------
 .../unit/Swift/Plugins/PopBeforeSmtpPluginTest.php |  8 ++--
 tests/unit/Swift/Plugins/RedirectingPluginTest.php |  4 +-
 .../Swift/Plugins/Reporters/HitReporterTest.php    |  2 +-
 .../Swift/Plugins/Reporters/HtmlReporterTest.php   |  2 +-
 tests/unit/Swift/Transport/StreamBufferTest.php    |  4 +-
 23 files changed, 71 insertions(+), 91 deletions(-)

diff --git a/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php b/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php
index 5480e55..cb07c91 100644
--- a/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php
+++ b/tests/acceptance/Swift/ByteStream/FileByteStreamAcceptanceTest.php
@@ -164,7 +164,7 @@ class Swift_ByteStream_FileByteStreamAcceptanceTest extends \PHPUnit\Framework\T
 
     private function createMockInputStream()
     {
-        return $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        return $this->createMock('Swift_InputByteStream');
     }
 
     private function createFileStream($file, $writable = false)
diff --git a/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php b/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php
index 5feb9d3..6b91b9b 100644
--- a/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php
+++ b/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php
@@ -16,7 +16,7 @@ abstract class Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest e
         }
 
         $this->buffer = new Swift_Transport_StreamBuffer(
-            $this->getMockBuilder('Swift_ReplacementFilterFactory')->getMock()
+            $this->createMock('Swift_ReplacementFilterFactory')
         );
     }
 
@@ -138,6 +138,6 @@ abstract class Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest e
 
     private function createMockInputStream()
     {
-        return $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        return $this->createMock('Swift_InputByteStream');
     }
 }
diff --git a/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php b/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php
index 1f96700..559fa4c 100644
--- a/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php
+++ b/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php
@@ -25,7 +25,7 @@ class Swift_Transport_StreamBuffer_SocketTimeoutTest extends \PHPUnit\Framework\
         }
 
         $this->buffer = new Swift_Transport_StreamBuffer(
-            $this->getMockBuilder('Swift_ReplacementFilterFactory')->getMock()
+            $this->createMock('Swift_ReplacementFilterFactory')
         );
     }
 
diff --git a/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php b/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php
index 0dd8e7f..b87b5b0 100644
--- a/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php
+++ b/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php
@@ -129,8 +129,8 @@ class Swift_ByteStream_ArrayByteStreamTest extends \PHPUnit\Framework\TestCase
     public function testBindingOtherStreamsMirrorsWriteOperations()
     {
         $bs = $this->createArrayStream('');
-        $is1 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
-        $is2 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        $is1 = $this->createMock('Swift_InputByteStream');
+        $is2 = $this->createMock('Swift_InputByteStream');
         $matcher = $this->exactly(2);
 
         $is1->expects($matcher)
@@ -163,8 +163,8 @@ class Swift_ByteStream_ArrayByteStreamTest extends \PHPUnit\Framework\TestCase
     public function testBindingOtherStreamsMirrorsFlushOperations()
     {
         $bs = $this->createArrayStream('');
-        $is1 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
-        $is2 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        $is1 = $this->createMock('Swift_InputByteStream');
+        $is2 = $this->createMock('Swift_InputByteStream');
 
         $is1->expects($this->once())
             ->method('flushBuffers');
@@ -180,8 +180,8 @@ class Swift_ByteStream_ArrayByteStreamTest extends \PHPUnit\Framework\TestCase
     public function testUnbindingStreamPreventsFurtherWrites()
     {
         $bs = $this->createArrayStream('');
-        $is1 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
-        $is2 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        $is1 = $this->createMock('Swift_InputByteStream');
+        $is2 = $this->createMock('Swift_InputByteStream');
         $matcher = $this->exactly(2);
 
         $is1->expects($matcher)
diff --git a/tests/unit/Swift/Events/CommandEventTest.php b/tests/unit/Swift/Events/CommandEventTest.php
index 2915870..e1ef75e 100644
--- a/tests/unit/Swift/Events/CommandEventTest.php
+++ b/tests/unit/Swift/Events/CommandEventTest.php
@@ -29,6 +29,6 @@ class Swift_Events_CommandEventTest extends \PHPUnit\Framework\TestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 }
diff --git a/tests/unit/Swift/Events/ResponseEventTest.php b/tests/unit/Swift/Events/ResponseEventTest.php
index ba5c191..90e61b3 100644
--- a/tests/unit/Swift/Events/ResponseEventTest.php
+++ b/tests/unit/Swift/Events/ResponseEventTest.php
@@ -33,6 +33,6 @@ class Swift_Events_ResponseEventTest extends \PHPUnit\Framework\TestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 }
diff --git a/tests/unit/Swift/Events/SendEventTest.php b/tests/unit/Swift/Events/SendEventTest.php
index 9f55589..898fe06 100644
--- a/tests/unit/Swift/Events/SendEventTest.php
+++ b/tests/unit/Swift/Events/SendEventTest.php
@@ -86,11 +86,11 @@ class Swift_Events_SendEventTest extends \PHPUnit\Framework\TestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 
     private function createMessage()
     {
-        return $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        return $this->createMock('Swift_Mime_SimpleMessage');
     }
 }
diff --git a/tests/unit/Swift/Events/SimpleEventDispatcherTest.php b/tests/unit/Swift/Events/SimpleEventDispatcherTest.php
index 5888aeb..4272bb3 100644
--- a/tests/unit/Swift/Events/SimpleEventDispatcherTest.php
+++ b/tests/unit/Swift/Events/SimpleEventDispatcherTest.php
@@ -11,8 +11,8 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testSendEventCanBeCreated()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
-        $message = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $transport = $this->createMock('Swift_Transport');
+        $message = $this->createMock('Swift_Mime_SimpleMessage');
         $evt = $this->dispatcher->createSendEvent($transport, $message);
         $this->assertInstanceOf('Swift_Events_SendEvent', $evt);
         $this->assertSame($message, $evt->getMessage());
@@ -21,7 +21,7 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testCommandEventCanBeCreated()
     {
-        $buf = $this->getMockBuilder('Swift_Transport')->getMock();
+        $buf = $this->createMock('Swift_Transport');
         $evt = $this->dispatcher->createCommandEvent($buf, "FOO\r\n", [250]);
         $this->assertInstanceOf('Swift_Events_CommandEvent', $evt);
         $this->assertSame($buf, $evt->getSource());
@@ -31,7 +31,7 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testResponseEventCanBeCreated()
     {
-        $buf = $this->getMockBuilder('Swift_Transport')->getMock();
+        $buf = $this->createMock('Swift_Transport');
         $evt = $this->dispatcher->createResponseEvent($buf, "250 Ok\r\n", true);
         $this->assertInstanceOf('Swift_Events_ResponseEvent', $evt);
         $this->assertSame($buf, $evt->getSource());
@@ -41,7 +41,7 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testTransportChangeEventCanBeCreated()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
+        $transport = $this->createMock('Swift_Transport');
         $evt = $this->dispatcher->createTransportChangeEvent($transport);
         $this->assertInstanceOf('Swift_Events_TransportChangeEvent', $evt);
         $this->assertSame($transport, $evt->getSource());
@@ -49,7 +49,7 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testTransportExceptionEventCanBeCreated()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
+        $transport = $this->createMock('Swift_Transport');
         $ex = new Swift_TransportException('');
         $evt = $this->dispatcher->createTransportExceptionEvent($transport, $ex);
         $this->assertInstanceOf('Swift_Events_TransportExceptionEvent', $evt);
@@ -59,12 +59,12 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testListenersAreNotifiedOfDispatchedEvent()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
+        $transport = $this->createMock('Swift_Transport');
 
         $evt = $this->dispatcher->createTransportChangeEvent($transport);
 
-        $listenerA = $this->getMockBuilder('Swift_Events_TransportChangeListener')->getMock();
-        $listenerB = $this->getMockBuilder('Swift_Events_TransportChangeListener')->getMock();
+        $listenerA = $this->createMock('Swift_Events_TransportChangeListener');
+        $listenerB = $this->createMock('Swift_Events_TransportChangeListener');
 
         $this->dispatcher->bindEventListener($listenerA);
         $this->dispatcher->bindEventListener($listenerB);
@@ -81,13 +81,13 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testListenersAreOnlyCalledIfImplementingCorrectInterface()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
-        $message = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $transport = $this->createMock('Swift_Transport');
+        $message = $this->createMock('Swift_Mime_SimpleMessage');
 
         $evt = $this->dispatcher->createSendEvent($transport, $message);
 
-        $targetListener = $this->getMockBuilder('Swift_Events_SendListener')->getMock();
-        $otherListener = $this->getMockBuilder('DummyListener')->getMock();
+        $targetListener = $this->createMock('Swift_Events_SendListener');
+        $otherListener = $this->createMock('DummyListener');
 
         $this->dispatcher->bindEventListener($targetListener);
         $this->dispatcher->bindEventListener($otherListener);
@@ -103,13 +103,13 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testListenersCanCancelBubblingOfEvent()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
-        $message = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $transport = $this->createMock('Swift_Transport');
+        $message = $this->createMock('Swift_Mime_SimpleMessage');
 
         $evt = $this->dispatcher->createSendEvent($transport, $message);
 
-        $listenerA = $this->getMockBuilder('Swift_Events_SendListener')->getMock();
-        $listenerB = $this->getMockBuilder('Swift_Events_SendListener')->getMock();
+        $listenerA = $this->createMock('Swift_Events_SendListener');
+        $listenerB = $this->createMock('Swift_Events_SendListener');
 
         $this->dispatcher->bindEventListener($listenerA);
         $this->dispatcher->bindEventListener($listenerB);
@@ -130,19 +130,19 @@ class Swift_Events_SimpleEventDispatcherTest extends \PHPUnit\Framework\TestCase
 
     public function testPreventFlushingQueueBubbleOnInternalEventsRising()
     {
-        $transport = $this->getMockBuilder('Swift_Transport')->getMock();
-        $message = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $transport = $this->createMock('Swift_Transport');
+        $message = $this->createMock('Swift_Mime_SimpleMessage');
 
         $evtA = $this->dispatcher->createSendEvent($transport, $message);
 
         $evtB = $this->dispatcher->createTransportChangeEvent($transport);
 
-        $listenerB = $this->getMockBuilder('Swift_Events_TransportChangeListener')->getMock();
+        $listenerB = $this->createMock('Swift_Events_TransportChangeListener');
 
         $this->dispatcher->bindEventListener($listenerB);
 
-        $listenerA1 = $this->getMockBuilder('Swift_Events_SendListener')->getMock();
-        $listenerA2 = $this->getMockBuilder('Swift_Events_SendListener')->getMock();
+        $listenerA1 = $this->createMock('Swift_Events_SendListener');
+        $listenerA2 = $this->createMock('Swift_Events_SendListener');
 
         $this->dispatcher->bindEventListener($listenerA1);
         $this->dispatcher->bindEventListener($listenerA2);
diff --git a/tests/unit/Swift/Events/TransportChangeEventTest.php b/tests/unit/Swift/Events/TransportChangeEventTest.php
index 625b96c..3dc6e8a 100644
--- a/tests/unit/Swift/Events/TransportChangeEventTest.php
+++ b/tests/unit/Swift/Events/TransportChangeEventTest.php
@@ -25,6 +25,6 @@ class Swift_Events_TransportChangeEventTest extends \PHPUnit\Framework\TestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 }
diff --git a/tests/unit/Swift/Events/TransportExceptionEventTest.php b/tests/unit/Swift/Events/TransportExceptionEventTest.php
index 033b0e5..6dd3d2d 100644
--- a/tests/unit/Swift/Events/TransportExceptionEventTest.php
+++ b/tests/unit/Swift/Events/TransportExceptionEventTest.php
@@ -31,7 +31,7 @@ class Swift_Events_TransportExceptionEventTest extends \PHPUnit\Framework\TestCa
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 
     private function createException()
diff --git a/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php b/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php
index 9edb95b..bec6a60 100644
--- a/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php
+++ b/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php
@@ -201,16 +201,16 @@ class Swift_KeyCache_ArrayKeyCacheTest extends \PHPUnit\Framework\TestCase
 
     private function createKeyCacheInputStream()
     {
-        return $this->getMockBuilder('Swift_KeyCache_KeyCacheInputStream')->getMock();
+        return $this->createMock('Swift_KeyCache_KeyCacheInputStream');
     }
 
     private function createOutputStream()
     {
-        return $this->getMockBuilder('Swift_OutputByteStream')->getMock();
+        return $this->createMock('Swift_OutputByteStream');
     }
 
     private function createInputStream()
     {
-        return $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        return $this->createMock('Swift_InputByteStream');
     }
 }
diff --git a/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php b/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php
index e36eafc..ad2ae2f 100644
--- a/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php
+++ b/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php
@@ -6,7 +6,7 @@ class Swift_KeyCache_SimpleKeyCacheInputStreamTest extends \PHPUnit\Framework\Te
 
     public function testStreamWritesToCacheInAppendMode()
     {
-        $cache = $this->getMockBuilder('Swift_KeyCache')->getMock();
+        $cache = $this->createMock('Swift_KeyCache');
         $matcher = $this->exactly(3);
         $cache->expects($matcher)
               ->method('setString')->willReturnCallback(function (...$parameters) use ($matcher) {
@@ -42,7 +42,7 @@ class Swift_KeyCache_SimpleKeyCacheInputStreamTest extends \PHPUnit\Framework\Te
 
     public function testFlushContentClearsKey()
     {
-        $cache = $this->getMockBuilder('Swift_KeyCache')->getMock();
+        $cache = $this->createMock('Swift_KeyCache');
         $cache->expects($this->once())
               ->method('clearKey')
               ->with($this->nsKey, 'foo');
@@ -57,7 +57,7 @@ class Swift_KeyCache_SimpleKeyCacheInputStreamTest extends \PHPUnit\Framework\Te
 
     public function testClonedStreamStillReferencesSameCache()
     {
-        $cache = $this->getMockBuilder('Swift_KeyCache')->getMock();
+        $cache = $this->createMock('Swift_KeyCache');
         $matcher = $this->exactly(3);
         $cache->expects($matcher)
               ->method('setString')->willReturnCallback(function (...$parameters) use ($matcher) {
diff --git a/tests/unit/Swift/Mime/AbstractMimeEntityTest.php b/tests/unit/Swift/Mime/AbstractMimeEntityTest.php
index ad80553..d9a86fa 100644
--- a/tests/unit/Swift/Mime/AbstractMimeEntityTest.php
+++ b/tests/unit/Swift/Mime/AbstractMimeEntityTest.php
@@ -1007,7 +1007,7 @@ abstract class Swift_Mime_AbstractMimeEntityTest extends \SwiftMailerTestCase
 
     protected function createEncoder($name = 'quoted-printable', $stub = true)
     {
-        $encoder = $this->getMockBuilder('Swift_Mime_ContentEncoder')->getMock();
+        $encoder = $this->createMock('Swift_Mime_ContentEncoder');
         $encoder->expects($this->any())
                 ->method('getName')
                 ->willReturn($name);
@@ -1087,6 +1087,6 @@ abstract class Swift_Mime_AbstractMimeEntityTest extends \SwiftMailerTestCase
 
     protected function createInputStream($stub = true)
     {
-        return $this->getMockBuilder('Swift_InputByteStream')->getMock();
+        return $this->createMock('Swift_InputByteStream');
     }
 }
diff --git a/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php b/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php
index fd56415..bda2635 100644
--- a/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php
+++ b/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php
@@ -159,11 +159,11 @@ class Swift_Mime_SimpleHeaderFactoryTest extends \PHPUnit\Framework\TestCase
 
     private function createHeaderEncoder()
     {
-        return $this->getMockBuilder('Swift_Mime_HeaderEncoder')->getMock();
+        return $this->createMock('Swift_Mime_HeaderEncoder');
     }
 
     private function createParamEncoder()
     {
-        return $this->getMockBuilder('Swift_Encoder')->getMock();
+        return $this->createMock('Swift_Encoder');
     }
 }
diff --git a/tests/unit/Swift/Mime/SimpleHeaderSetTest.php b/tests/unit/Swift/Mime/SimpleHeaderSetTest.php
index c62a06e..6377458 100644
--- a/tests/unit/Swift/Mime/SimpleHeaderSetTest.php
+++ b/tests/unit/Swift/Mime/SimpleHeaderSetTest.php
@@ -804,12 +804,12 @@ class Swift_Mime_SimpleHeaderSetTest extends \PHPUnit\Framework\TestCase
 
     private function createFactory()
     {
-        return $this->getMockBuilder('Swift_Mime_SimpleHeaderFactory')->disableOriginalConstructor()->getMock();
+        return $this->createMock('Swift_Mime_SimpleHeaderFactory');
     }
 
     private function createHeader($name, $body = '')
     {
-        $header = $this->getMockBuilder('Swift_Mime_Header')->getMock();
+        $header = $this->createMock('Swift_Mime_Header');
         $header->expects($this->any())
                ->method('getFieldName')
                ->willReturn($name);
diff --git a/tests/unit/Swift/Plugins/AntiFloodPluginTest.php b/tests/unit/Swift/Plugins/AntiFloodPluginTest.php
index 2c1e33a..0bf4d83 100644
--- a/tests/unit/Swift/Plugins/AntiFloodPluginTest.php
+++ b/tests/unit/Swift/Plugins/AntiFloodPluginTest.php
@@ -52,7 +52,7 @@ class Swift_Plugins_AntiFloodPluginTest extends \PHPUnit\Framework\TestCase
 
     public function testPluginCanSleepDuringRestart()
     {
-        $sleeper = $this->getMockBuilder('Swift_Plugins_Sleeper')->getMock();
+        $sleeper = $this->createMock('Swift_Plugins_Sleeper');
         $sleeper->expects($this->once())
                 ->method('sleep')
                 ->with(10);
@@ -73,14 +73,12 @@ class Swift_Plugins_AntiFloodPluginTest extends \PHPUnit\Framework\TestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 
     private function createSendEvent($transport)
     {
-        $evt = $this->getMockBuilder('Swift_Events_SendEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_SendEvent');
         $evt->expects($this->any())
             ->method('getSource')
             ->willReturn($transport);
diff --git a/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php b/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php
index 836ae53..2c81cee 100644
--- a/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php
+++ b/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php
@@ -71,9 +71,7 @@ class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit\Framework\TestCa
 
     private function createSendEvent($message)
     {
-        $evt = $this->getMockBuilder('Swift_Events_SendEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_SendEvent');
         $evt->expects($this->any())
             ->method('getMessage')
             ->willReturn($message);
@@ -83,9 +81,7 @@ class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit\Framework\TestCa
 
     private function createCommandEvent($command)
     {
-        $evt = $this->getMockBuilder('Swift_Events_CommandEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_CommandEvent');
         $evt->expects($this->any())
             ->method('getCommand')
             ->willReturn($command);
@@ -95,9 +91,7 @@ class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit\Framework\TestCa
 
     private function createResponseEvent($response)
     {
-        $evt = $this->getMockBuilder('Swift_Events_ResponseEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_ResponseEvent');
         $evt->expects($this->any())
             ->method('getResponse')
             ->willReturn($response);
@@ -108,7 +102,7 @@ class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit\Framework\TestCa
     private function createMessageWithByteCount($bytes)
     {
         $this->bytes = $bytes;
-        $msg = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $msg = $this->createMock('Swift_Mime_SimpleMessage');
         $msg->expects($this->any())
             ->method('toByteStream')
             ->willReturnCallback([$this, 'write']);
diff --git a/tests/unit/Swift/Plugins/LoggerPluginTest.php b/tests/unit/Swift/Plugins/LoggerPluginTest.php
index 0bedb65..ae5112b 100644
--- a/tests/unit/Swift/Plugins/LoggerPluginTest.php
+++ b/tests/unit/Swift/Plugins/LoggerPluginTest.php
@@ -125,7 +125,7 @@ class Swift_Plugins_LoggerPluginTest extends \SwiftMailerTestCase
 
     private function createLogger()
     {
-        return $this->getMockBuilder('Swift_Plugins_Logger')->getMock();
+        return $this->createMock('Swift_Plugins_Logger');
     }
 
     private function createPlugin($logger)
@@ -135,9 +135,7 @@ class Swift_Plugins_LoggerPluginTest extends \SwiftMailerTestCase
 
     private function createCommandEvent($command)
     {
-        $evt = $this->getMockBuilder('Swift_Events_CommandEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_CommandEvent');
         $evt->expects($this->any())
             ->method('getCommand')
             ->willReturn($command);
@@ -147,9 +145,7 @@ class Swift_Plugins_LoggerPluginTest extends \SwiftMailerTestCase
 
     private function createResponseEvent($response)
     {
-        $evt = $this->getMockBuilder('Swift_Events_ResponseEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_ResponseEvent');
         $evt->expects($this->any())
             ->method('getResponse')
             ->willReturn($response);
@@ -159,14 +155,12 @@ class Swift_Plugins_LoggerPluginTest extends \SwiftMailerTestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 
     private function createTransportChangeEvent()
     {
-        $evt = $this->getMockBuilder('Swift_Events_TransportChangeEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_TransportChangeEvent');
         $evt->expects($this->any())
             ->method('getSource')
             ->willReturn($this->createTransport());
@@ -176,9 +170,7 @@ class Swift_Plugins_LoggerPluginTest extends \SwiftMailerTestCase
 
     public function createTransportExceptionEvent()
     {
-        $evt = $this->getMockBuilder('Swift_Events_TransportExceptionEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_TransportExceptionEvent');
         $evt->expects($this->any())
             ->method('getException')
             ->willReturn(new Swift_TransportException(''));
diff --git a/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php b/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php
index 16931bb..a6b987d 100644
--- a/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php
+++ b/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php
@@ -71,14 +71,12 @@ class Swift_Plugins_PopBeforeSmtpPluginTest extends \PHPUnit\Framework\TestCase
 
     private function createTransport()
     {
-        return $this->getMockBuilder('Swift_Transport')->getMock();
+        return $this->createMock('Swift_Transport');
     }
 
     private function createTransportChangeEvent($transport)
     {
-        $evt = $this->getMockBuilder('Swift_Events_TransportChangeEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_TransportChangeEvent');
         $evt->expects($this->any())
             ->method('getSource')
             ->willReturn($transport);
@@ -91,7 +89,7 @@ class Swift_Plugins_PopBeforeSmtpPluginTest extends \PHPUnit\Framework\TestCase
 
     public function createConnection()
     {
-        return $this->getMockBuilder('Swift_Plugins_Pop_Pop3Connection')->getMock();
+        return $this->createMock('Swift_Plugins_Pop_Pop3Connection');
     }
 
     public function createPlugin($host, $port, $crypto = null)
diff --git a/tests/unit/Swift/Plugins/RedirectingPluginTest.php b/tests/unit/Swift/Plugins/RedirectingPluginTest.php
index 721ff9b..7334010 100644
--- a/tests/unit/Swift/Plugins/RedirectingPluginTest.php
+++ b/tests/unit/Swift/Plugins/RedirectingPluginTest.php
@@ -171,9 +171,7 @@ class Swift_Plugins_RedirectingPluginTest extends \PHPUnit\Framework\TestCase
 
     private function createSendEvent(Swift_Mime_SimpleMessage $message)
     {
-        $evt = $this->getMockBuilder('Swift_Events_SendEvent')
-                    ->disableOriginalConstructor()
-                    ->getMock();
+        $evt = $this->createMock('Swift_Events_SendEvent');
         $evt->expects($this->any())
             ->method('getMessage')
             ->willReturn($message);
diff --git a/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php b/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php
index cf94617..1cc69b1 100644
--- a/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php
+++ b/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php
@@ -8,7 +8,7 @@ class Swift_Plugins_Reporters_HitReporterTest extends \PHPUnit\Framework\TestCas
     protected function setUp(): void
     {
         $this->hitReporter = new Swift_Plugins_Reporters_HitReporter();
-        $this->message = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $this->message = $this->createMock('Swift_Mime_SimpleMessage');
     }
 
     public function testReportingFail()
diff --git a/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php b/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php
index 4aa64f5..79ea1f3 100644
--- a/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php
+++ b/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php
@@ -8,7 +8,7 @@ class Swift_Plugins_Reporters_HtmlReporterTest extends \PHPUnit\Framework\TestCa
     protected function setUp(): void
     {
         $this->html = new Swift_Plugins_Reporters_HtmlReporter();
-        $this->message = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock();
+        $this->message = $this->createMock('Swift_Mime_SimpleMessage');
     }
 
     public function testReportingPass()
diff --git a/tests/unit/Swift/Transport/StreamBufferTest.php b/tests/unit/Swift/Transport/StreamBufferTest.php
index 7a9d228..2ea0d3a 100644
--- a/tests/unit/Swift/Transport/StreamBufferTest.php
+++ b/tests/unit/Swift/Transport/StreamBufferTest.php
@@ -33,11 +33,11 @@ class Swift_Transport_StreamBufferTest extends \PHPUnit\Framework\TestCase
 
     private function createFactory()
     {
-        return $this->getMockBuilder('Swift_ReplacementFilterFactory')->getMock();
+        return $this->createMock('Swift_ReplacementFilterFactory');
     }
 
     public function createFilter()
     {
-        return $this->getMockBuilder('Swift_StreamFilter')->getMock();
+        return $this->createMock('Swift_StreamFilter');
     }
 }
