From: Guilhem Moulin <guilhem@debian.org>
Date: Fri, 9 Aug 2024 18:00:37 +0200
Subject: Fix FTBFS with phpunit 11

Origin: https://github.com/roundcube/roundcubemail/commit/f4272804d6b8877ffa9402b0a58d9f092bfced5d
Bug: https://github.com/roundcube/roundcubemail/pull/9477
Bug-Debian: https://bugs.debian.org/1039853
Origin: https://github.com/roundcube/roundcubemail/commit/6377477eb294389dd8a17ccff299b5f20d080bf7
Bug: https://github.com/roundcube/roundcubemail/pull/9480
Bug-Debian: https://bugs.debian.org/1070637
---
 plugins/acl/tests/Acl.php                          |  14 +-
 .../tests/AdditionalMessageHeaders.php             |  16 +-
 plugins/archive/tests/Archive.php                  |  22 ++-
 .../tests/AttachmentReminder.php                   |  22 ++-
 plugins/autologon/tests/Autologon.php              |  14 +-
 plugins/autologout/tests/Autologout.php            |  14 +-
 .../tests/DatabaseAttachments.php                  |  14 +-
 plugins/debug_logger/tests/DebugLogger.php         |  14 +-
 plugins/emoticons/tests/Emoticons.php              |  14 +-
 plugins/enigma/tests/Enigma.php                    |  14 +-
 plugins/enigma/tests/EnigmaDriverGnupg.php         |  12 +-
 plugins/enigma/tests/EnigmaEngine.php              |  12 +-
 plugins/enigma/tests/EnigmaError.php               |  12 +-
 plugins/enigma/tests/EnigmaKey.php                 |  14 +-
 plugins/enigma/tests/EnigmaMimeMessage.php         |  40 ++--
 plugins/enigma/tests/EnigmaSignature.php           |  10 +-
 plugins/enigma/tests/EnigmaSubkey.php              |  10 +-
 plugins/enigma/tests/EnigmaUserid.php              |  10 +-
 .../tests/ExampleAddressbook.php                   |  18 +-
 .../tests/FilesystemAttachments.php                |  14 +-
 plugins/help/tests/Help.php                        |  18 +-
 plugins/hide_blockquote/tests/HideBlockquote.php   |  22 ++-
 .../tests/HttpAuthentication.php                   |  14 +-
 plugins/identicon/tests/Identicon.php              |  14 +-
 plugins/identicon/tests/IdenticonEngine.php        |   8 +-
 plugins/identity_select/tests/IdentitySelect.php   |  14 +-
 plugins/jqueryui/tests/Jqueryui.php                |  14 +-
 .../krb_authentication/tests/KrbAuthentication.php |  14 +-
 plugins/managesieve/tests/Engine.php               |  33 ++--
 plugins/managesieve/tests/Forward.php              |  16 +-
 plugins/managesieve/tests/Managesieve.php          |  14 +-
 plugins/managesieve/tests/Script.php               |  17 +-
 plugins/managesieve/tests/Vacation.php             |  21 +-
 plugins/markasjunk/tests/Markasjunk.php            |  22 ++-
 plugins/new_user_dialog/tests/NewUserDialog.php    |  14 +-
 .../new_user_identity/tests/NewUserIdentity.php    |  14 +-
 plugins/newmail_notifier/tests/NewmailNotifier.php |  14 +-
 plugins/password/tests/Password.php                |  26 +--
 .../tests/RedundantAttachments.php                 |  14 +-
 .../tests/ShowAdditionalHeaders.php                |  14 +-
 .../tests/SquirrelmailUsercopy.php                 |  14 +-
 .../tests/SubscriptionsOption.php                  |  24 ++-
 plugins/userinfo/tests/Userinfo.php                |  14 +-
 .../vcard_attachments/tests/VcardAttachments.php   |  22 ++-
 plugins/virtuser_file/tests/VirtuserFile.php       |  14 +-
 plugins/virtuser_query/tests/VirtuserQuery.php     |  14 +-
 plugins/zipdownload/tests/Zipdownload.php          |  14 +-
 tests/ActionTestCase.php                           |  40 ++--
 tests/Actions/Contacts/Copy.php                    |  27 +--
 tests/Actions/Contacts/Delete.php                  |  15 +-
 tests/Actions/Contacts/Edit.php                    |  23 ++-
 tests/Actions/Contacts/Export.php                  |  23 ++-
 tests/Actions/Contacts/GroupAddmembers.php         |  23 ++-
 tests/Actions/Contacts/GroupCreate.php             |  23 ++-
 tests/Actions/Contacts/GroupDelete.php             |  23 ++-
 tests/Actions/Contacts/GroupDelmembers.php         |  23 ++-
 tests/Actions/Contacts/GroupRename.php             |  23 ++-
 tests/Actions/Contacts/Import.php                  |  13 +-
 tests/Actions/Contacts/Index.php                   |  28 +--
 tests/Actions/Contacts/List.php                    |  13 +-
 tests/Actions/Contacts/Mailto.php                  |  15 +-
 tests/Actions/Contacts/Move.php                    |  17 +-
 tests/Actions/Contacts/Photo.php                   |  15 +-
 tests/Actions/Contacts/Print.php                   |  15 +-
 tests/Actions/Contacts/Qrcode.php                  |  17 +-
 tests/Actions/Contacts/Save.php                    |  27 +--
 tests/Actions/Contacts/Search.php                  |  18 +-
 tests/Actions/Contacts/SearchCreate.php            |  21 +-
 tests/Actions/Contacts/SearchDelete.php            |  21 +-
 tests/Actions/Contacts/Show.php                    |  21 +-
 tests/Actions/Contacts/Undo.php                    |  15 +-
 tests/Actions/Contacts/UploadPhoto.php             |  19 +-
 tests/Actions/Login/Oauth.php                      |  14 +-
 tests/Actions/Mail/Addcontact.php                  |  10 +-
 tests/Actions/Mail/AttachmentDelete.php            |  10 +-
 tests/Actions/Mail/AttachmentDisplay.php           |  10 +-
 tests/Actions/Mail/AttachmentRename.php            |  10 +-
 tests/Actions/Mail/AttachmentUpload.php            |  10 +-
 tests/Actions/Mail/Autocomplete.php                |  10 +-
 tests/Actions/Mail/Bounce.php                      |  10 +-
 tests/Actions/Mail/CheckRecent.php                 |  10 +-
 tests/Actions/Mail/Compose.php                     |  12 +-
 tests/Actions/Mail/Copy.php                        |  25 +--
 tests/Actions/Mail/Delete.php                      |  10 +-
 tests/Actions/Mail/FolderExpunge.php               |  33 ++--
 tests/Actions/Mail/FolderPurge.php                 |  10 +-
 tests/Actions/Mail/Get.php                         |  10 +-
 tests/Actions/Mail/Getunread.php                   |  10 +-
 tests/Actions/Mail/GroupExpand.php                 |  10 +-
 tests/Actions/Mail/Headers.php                     |  10 +-
 tests/Actions/Mail/Index.php                       | 106 ++++++-----
 tests/Actions/Mail/List.php                        |  10 +-
 tests/Actions/Mail/ListContacts.php                |  10 +-
 tests/Actions/Mail/Mark.php                        |  10 +-
 tests/Actions/Mail/Move.php                        |  10 +-
 tests/Actions/Mail/Pagenav.php                     |  10 +-
 tests/Actions/Mail/Search.php                      |  65 ++++---
 tests/Actions/Mail/SearchContacts.php              |  10 +-
 tests/Actions/Mail/Send.php                        |  10 +-
 tests/Actions/Mail/Sendmdn.php                     |  10 +-
 tests/Actions/Mail/Show.php                        |  10 +-
 tests/Actions/Mail/Viewsource.php                  |  10 +-
 tests/Actions/Settings/About.php                   |  13 +-
 tests/Actions/Settings/FolderCreate.php            |  15 +-
 tests/Actions/Settings/FolderDelete.php            |  23 ++-
 tests/Actions/Settings/FolderEdit.php              |  15 +-
 tests/Actions/Settings/FolderPurge.php             |  31 +--
 tests/Actions/Settings/FolderRename.php            |  23 ++-
 tests/Actions/Settings/FolderSave.php              |  15 +-
 tests/Actions/Settings/FolderSize.php              |  23 ++-
 tests/Actions/Settings/FolderSubscribe.php         |  25 +--
 tests/Actions/Settings/FolderUnsubscribe.php       |  23 ++-
 tests/Actions/Settings/Folders.php                 |  15 +-
 tests/Actions/Settings/Identities.php              |  17 +-
 tests/Actions/Settings/IdentityCreate.php          |  13 +-
 tests/Actions/Settings/IdentityDelete.php          |  19 +-
 tests/Actions/Settings/IdentityEdit.php            |  19 +-
 tests/Actions/Settings/IdentitySave.php            |  16 +-
 tests/Actions/Settings/Index.php                   |  31 +--
 tests/Actions/Settings/PrefsEdit.php               |  13 +-
 tests/Actions/Settings/PrefsSave.php               |  18 +-
 tests/Actions/Settings/ResponseCreate.php          |  13 +-
 tests/Actions/Settings/ResponseDelete.php          |  15 +-
 tests/Actions/Settings/ResponseEdit.php            |  17 +-
 tests/Actions/Settings/ResponseGet.php             |  15 +-
 tests/Actions/Settings/ResponseSave.php            |  20 +-
 tests/Actions/Settings/Responses.php               |  19 +-
 tests/Actions/Settings/Upload.php                  |  10 +-
 tests/Actions/Settings/UploadDisplay.php           |  10 +-
 tests/Actions/Utils/Error.php                      |  20 +-
 tests/Actions/Utils/Html2text.php                  |  13 +-
 tests/Actions/Utils/Killcache.php                  |  10 +-
 tests/Actions/Utils/Modcss.php                     |  15 +-
 tests/Actions/Utils/SavePref.php                   |  17 +-
 tests/Actions/Utils/Spell.php                      |  10 +-
 tests/Actions/Utils/SpellHtml.php                  |  10 +-
 tests/Actions/Utils/Text2html.php                  |  15 +-
 tests/ExitException.php                            |   6 +-
 tests/Framework/Addressbook.php                    |  40 ++--
 tests/Framework/Addresses.php                      |  16 +-
 tests/Framework/BaseReplacer.php                   |  21 +-
 tests/Framework/Bootstrap.php                      |   8 +-
 tests/Framework/Browser.php                        |  34 ++--
 tests/Framework/Cache.php                          |  18 +-
 tests/Framework/CacheDB.php                        |  16 +-
 tests/Framework/Charset.php                        |  60 +++---
 tests/Framework/Config.php                         |  24 ++-
 tests/Framework/Contacts.php                       |  14 +-
 tests/Framework/ContentFilter.php                  |  12 +-
 tests/Framework/Csv2vcard.php                      |  18 +-
 tests/Framework/DB.php                             |  27 +--
 tests/Framework/DBMssql.php                        |  14 +-
 tests/Framework/DBMysql.php                        |  14 +-
 tests/Framework/DBOracle.php                       |  14 +-
 tests/Framework/DBPgsql.php                        |  22 ++-
 tests/Framework/DBSqlite.php                       |  14 +-
 tests/Framework/DBSqlsrv.php                       |  14 +-
 tests/Framework/Enriched.php                       |  20 +-
 tests/Framework/Html.php                           |  28 +--
 tests/Framework/Html2text.php                      |  50 ++---
 tests/Framework/HtmlCheckbox.php                   |  10 +-
 tests/Framework/Image.php                          |  24 +--
 tests/Framework/Imap.php                           |  28 +--
 tests/Framework/ImapCache.php                      |  12 +-
 tests/Framework/ImapGeneric.php                    |  60 +++---
 tests/Framework/ImapSearch.php                     |  12 +-
 tests/Framework/Ldap.php                           |  17 +-
 tests/Framework/LdapGeneric.php                    |  14 +-
 tests/Framework/Message.php                        |  24 +--
 tests/Framework/MessageHeader.php                  |  12 +-
 tests/Framework/MessagePart.php                    |  12 +-
 tests/Framework/Mime.php                           |  56 +++---
 tests/Framework/MimeDecode.php                     |  12 +-
 tests/Framework/Output.php                         |  30 +--
 tests/Framework/PluginApi.php                      |  14 +-
 tests/Framework/Rcube.php                          |  18 +-
 tests/Framework/ResultIndex.php                    |  20 +-
 tests/Framework/ResultMultifolder.php              |  12 +-
 tests/Framework/ResultSet.php                      |  12 +-
 tests/Framework/ResultThread.php                   |  16 +-
 tests/Framework/Session.php                        |  18 +-
 tests/Framework/Smtp.php                           |  18 +-
 tests/Framework/Spellchecker.php                   |  10 +-
 tests/Framework/SpellcheckerAtd.php                |  14 +-
 tests/Framework/SpellcheckerEnchant.php            |  30 +--
 tests/Framework/SpellcheckerGoogie.php             |  14 +-
 tests/Framework/SpellcheckerPspell.php             |  30 +--
 tests/Framework/Spoofchecker.php                   |  14 +-
 tests/Framework/StringReplacer.php                 |  20 +-
 tests/Framework/Text2Html.php                      |  22 ++-
 tests/Framework/TnefDecoder.php                    |  16 +-
 tests/Framework/User.php                           |  30 +--
 tests/Framework/Utils.php                          | 211 +++++++++++----------
 tests/Framework/VCard.php                          |  40 ++--
 tests/Framework/Washtml.php                        |  85 +++++----
 tests/OutputHtmlMock.php                           |   6 +-
 tests/OutputJsonMock.php                           |   6 +-
 tests/Rcmail/Action.php                            |  40 ++--
 tests/Rcmail/AttachmentHandler.php                 |  10 +-
 tests/Rcmail/HtmlPage.php                          |  10 +-
 tests/Rcmail/Install.php                           |  34 ++--
 tests/Rcmail/Oauth.php                             |  20 +-
 tests/Rcmail/OutputCli.php                         |  12 +-
 tests/Rcmail/OutputHtml.php                        |  60 +++---
 tests/Rcmail/OutputJson.php                        |  14 +-
 tests/Rcmail/Rcmail.php                            |  41 ++--
 tests/Rcmail/ResendMail.php                        |  10 +-
 tests/Rcmail/Sendmail.php                          | 100 +++++-----
 tests/Rcmail/StringReplacer.php                    |  12 +-
 tests/Rcmail/Utils.php                             |  22 ++-
 tests/StderrMock.php                               |  15 +-
 tests/StorageMock.php                              |   4 +-
 tests/bootstrap.php                                |  21 +-
 213 files changed, 2503 insertions(+), 1797 deletions(-)

diff --git a/plugins/acl/tests/Acl.php b/plugins/acl/tests/Acl.php
index 94e0bd4..0ad987f 100644
--- a/plugins/acl/tests/Acl.php
+++ b/plugins/acl/tests/Acl.php
@@ -1,6 +1,10 @@
 <?php
 
-class Acl_Plugin extends ActionTestCase
+namespace Roundcube\Plugins\Tests;
+
+use Roundcube\Tests\ActionTestCase;
+
+class Tests_Acl extends ActionTestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Acl_Plugin extends ActionTestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new acl($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \acl($rcube->plugins);
 
-        $this->assertInstanceOf('acl', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\acl::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         $plugin->init();
     }
diff --git a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
index d77c968..e902556 100644
--- a/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
+++ b/plugins/additional_message_headers/tests/AdditionalMessageHeaders.php
@@ -1,6 +1,10 @@
 <?php
 
-class AdditionalMessageHeaders_Plugin extends ActionTestCase
+namespace Roundcube\Plugins\Tests;
+
+use Roundcube\Tests\ActionTestCase;
+
+class Tests_AdditionalMessageHeaders extends ActionTestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,15 +16,15 @@ class AdditionalMessageHeaders_Plugin extends ActionTestCase
      */
     function test_plugin()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new additional_message_headers($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \additional_message_headers($rcube->plugins);
 
-        $this->assertInstanceOf('additional_message_headers', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\additional_message_headers::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         $plugin->init();
 
-        $args = ['message' => new Mail_mime()];
+        $args = ['message' => new \Mail_mime()];
 
         $result = $plugin->message_headers($args);
 
diff --git a/plugins/archive/tests/Archive.php b/plugins/archive/tests/Archive.php
index 7f0b9b2..c1f9ec9 100644
--- a/plugins/archive/tests/Archive.php
+++ b/plugins/archive/tests/Archive.php
@@ -1,6 +1,10 @@
 <?php
 
-class Archive_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Archive extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Archive_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new archive($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \archive($rcube->plugins);
 
-        $this->assertInstanceOf('archive', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\archive::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         $plugin->init();
     }
@@ -26,8 +30,8 @@ class Archive_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_prefs_table()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new archive($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \archive($rcube->plugins);
 
         $args = ['section' => 'server', 'blocks' => ['main' => ['options' => []]]];
 
@@ -51,8 +55,8 @@ class Archive_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_prefs_save()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new archive($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \archive($rcube->plugins);
 
         $_POST = [];
         $args  = ['section' => 'folders', 'prefs' => []];
diff --git a/plugins/attachment_reminder/tests/AttachmentReminder.php b/plugins/attachment_reminder/tests/AttachmentReminder.php
index 523fa98..c88de16 100644
--- a/plugins/attachment_reminder/tests/AttachmentReminder.php
+++ b/plugins/attachment_reminder/tests/AttachmentReminder.php
@@ -1,6 +1,10 @@
 <?php
 
-class AttachmentReminder_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_AttachmentReminder extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class AttachmentReminder_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new attachment_reminder($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \attachment_reminder($rcube->plugins);
 
-        $this->assertInstanceOf('attachment_reminder', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\attachment_reminder::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         $plugin->init();
     }
@@ -26,8 +30,8 @@ class AttachmentReminder_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_prefs_list()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new attachment_reminder($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \attachment_reminder($rcube->plugins);
 
         $args = ['section' => 'compose', 'blocks' => ['main' => ['options' => []]]];
 
@@ -48,8 +52,8 @@ class AttachmentReminder_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_prefs_save()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new attachment_reminder($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \attachment_reminder($rcube->plugins);
 
         $_POST = [];
         $args  = ['section' => 'compose', 'prefs' => []];
diff --git a/plugins/autologon/tests/Autologon.php b/plugins/autologon/tests/Autologon.php
index 7d4135d..781d32d 100644
--- a/plugins/autologon/tests/Autologon.php
+++ b/plugins/autologon/tests/Autologon.php
@@ -1,6 +1,10 @@
 <?php
 
-class Autologon_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Autologon extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Autologon_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new autologon($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \autologon($rcube->plugins);
 
-        $this->assertInstanceOf('autologon', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\autologon::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         // TODO
         $plugin->startup([]);
diff --git a/plugins/autologout/tests/Autologout.php b/plugins/autologout/tests/Autologout.php
index a4c633a..8ab86c0 100644
--- a/plugins/autologout/tests/Autologout.php
+++ b/plugins/autologout/tests/Autologout.php
@@ -1,6 +1,10 @@
 <?php
 
-class Autologout_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Autologout extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Autologout_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new autologout($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \autologout($rcube->plugins);
 
-        $this->assertInstanceOf('autologout', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\autologout::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         // TODO
         $plugin->startup([]);
diff --git a/plugins/database_attachments/tests/DatabaseAttachments.php b/plugins/database_attachments/tests/DatabaseAttachments.php
index 76d633b..26451d7 100644
--- a/plugins/database_attachments/tests/DatabaseAttachments.php
+++ b/plugins/database_attachments/tests/DatabaseAttachments.php
@@ -1,6 +1,10 @@
 <?php
 
-class DatabaseAttachments_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_DatabaseAttachments extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class DatabaseAttachments_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new database_attachments($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \database_attachments($rcube->plugins);
 
-        $this->assertInstanceOf('database_attachments', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\database_attachments::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/debug_logger/tests/DebugLogger.php b/plugins/debug_logger/tests/DebugLogger.php
index d80bcbd..b542c0a 100644
--- a/plugins/debug_logger/tests/DebugLogger.php
+++ b/plugins/debug_logger/tests/DebugLogger.php
@@ -1,6 +1,10 @@
 <?php
 
-class DebugLogger_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_DebugLogger extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class DebugLogger_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new debug_logger($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \debug_logger($rcube->plugins);
 
-        $this->assertInstanceOf('debug_logger', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\debug_logger::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/emoticons/tests/Emoticons.php b/plugins/emoticons/tests/Emoticons.php
index 31b4568..731f9fb 100644
--- a/plugins/emoticons/tests/Emoticons.php
+++ b/plugins/emoticons/tests/Emoticons.php
@@ -1,6 +1,10 @@
 <?php
 
-class Emoticons_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Emoticons extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class Emoticons_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new emoticons($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \emoticons($rcube->plugins);
 
-        $this->assertInstanceOf('emoticons', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\emoticons::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/enigma/tests/Enigma.php b/plugins/enigma/tests/Enigma.php
index b2eb78f..7aa9160 100644
--- a/plugins/enigma/tests/Enigma.php
+++ b/plugins/enigma/tests/Enigma.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Enigma extends TestCase
 {
 
     function setUp(): void
@@ -13,11 +17,11 @@ class Enigma_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new enigma($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \enigma($rcube->plugins);
 
-        $this->assertInstanceOf('enigma', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\enigma::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/enigma/tests/EnigmaDriverGnupg.php b/plugins/enigma/tests/EnigmaDriverGnupg.php
index be7c527..6e9ea0f 100644
--- a/plugins/enigma/tests/EnigmaDriverGnupg.php
+++ b/plugins/enigma/tests/EnigmaDriverGnupg.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaDriverGnupg extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaDriverGnupg extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -13,10 +17,10 @@ class Enigma_EnigmaDriverGnupg extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new enigma_driver_gnupg($rcube->user);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \enigma_driver_gnupg($rcube->user);
 
-        $this->assertInstanceOf('enigma_driver', $plugin);
+        $this->assertInstanceOf(\enigma_driver::class, $plugin);
     }
 }
 
diff --git a/plugins/enigma/tests/EnigmaEngine.php b/plugins/enigma/tests/EnigmaEngine.php
index 1c80b79..4098c70 100644
--- a/plugins/enigma/tests/EnigmaEngine.php
+++ b/plugins/enigma/tests/EnigmaEngine.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaEngine extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaEngine extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -13,9 +17,9 @@ class Enigma_EnigmaEngine extends PHPUnit\Framework\TestCase
      */
     function test_password_handler()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new enigma($rcube->plugins);
-        $engine = new enigma_engine($plugin);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \enigma($rcube->plugins);
+        $engine = new \enigma_engine($plugin);
 
         unset($_SESSION['enigma_pass']);
 
diff --git a/plugins/enigma/tests/EnigmaError.php b/plugins/enigma/tests/EnigmaError.php
index 1b226be..cbbf44d 100644
--- a/plugins/enigma/tests/EnigmaError.php
+++ b/plugins/enigma/tests/EnigmaError.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaError extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaError extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class Enigma_EnigmaError extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $error = new enigma_error(enigma_error::EXPIRED, 'message', ['test1' => 'test2']);
+        $error = new \enigma_error(\enigma_error::EXPIRED, 'message', ['test1' => 'test2']);
 
-        $this->assertInstanceOf('enigma_error', $error);
-        $this->assertSame(enigma_error::EXPIRED, $error->getCode());
+        $this->assertInstanceOf(\enigma_error::class, $error);
+        $this->assertSame(\enigma_error::EXPIRED, $error->getCode());
         $this->assertSame('message', $error->getMessage());
         $this->assertSame('test2', $error->getData('test1'));
         $this->assertSame(['test1' => 'test2'], $error->getData());
diff --git a/plugins/enigma/tests/EnigmaKey.php b/plugins/enigma/tests/EnigmaKey.php
index 4f139a5..9b41d16 100644
--- a/plugins/enigma/tests/EnigmaKey.php
+++ b/plugins/enigma/tests/EnigmaKey.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaKey extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaKey extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,14 +16,14 @@ class Enigma_EnigmaKey extends PHPUnit\Framework\TestCase
      */
     function test_empty_key()
     {
-        $key = new enigma_key();
+        $key = new \enigma_key();
 
-        $this->assertInstanceOf('enigma_key', $key);
-        $this->assertSame(enigma_key::TYPE_UNKNOWN, $key->get_type());
+        $this->assertInstanceOf(\enigma_key::class, $key);
+        $this->assertSame(\enigma_key::TYPE_UNKNOWN, $key->get_type());
         $this->assertSame(false, $key->is_revoked());
         $this->assertSame(false, $key->is_valid());
         $this->assertSame(false, $key->is_private());
-        $this->assertSame(null, $key->find_subkey('test@domain.com', enigma_key::CAN_SIGN));
+        $this->assertSame(null, $key->find_subkey('test@domain.com', \enigma_key::CAN_SIGN));
 
         $this->assertSame('89E037A5', $key::format_id('04622F2089E037A5'));
         // TODO: format_fingerprint();
diff --git a/plugins/enigma/tests/EnigmaMimeMessage.php b/plugins/enigma/tests/EnigmaMimeMessage.php
index 06c905f..c79de77 100644
--- a/plugins/enigma/tests/EnigmaMimeMessage.php
+++ b/plugins/enigma/tests/EnigmaMimeMessage.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaMimeMessage extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,17 +16,17 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
      */
     function test_is_multipart()
     {
-        $mime     = new Mail_mime();
-        $message1 = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $mime     = new \Mail_mime();
+        $message1 = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $this->assertSame(false, $message1->isMultipart());
 
         $mime->setHTMLBody('<html></html>');
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $this->assertSame(true, $message->isMultipart());
 
-        $message = new enigma_mime_message($message1, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($message1, \enigma_mime_message::PGP_SIGNED);
 
         $this->assertSame(true, $message->isMultipart());
     }
@@ -32,13 +36,13 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
      */
     function test_get_from_address()
     {
-        $mime    = new Mail_mime();
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $mime    = new \Mail_mime();
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $this->assertSame(null, $message->getFromAddress());
 
         $mime->setFrom('test@domain.com');
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $this->assertSame('test@domain.com', $message->getFromAddress());
     }
@@ -48,7 +52,7 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
      */
     function test_get_recipients()
     {
-        $mime = new Mail_mime();
+        $mime = new \Mail_mime();
         $mime->setFrom('test1@domain.com');
         $mime->addTo('<test2@domain.com>, undisclosed-recipients:');
         $mime->addCc('<test3@domain.com>');
@@ -56,7 +60,7 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
 
         $expected = ['test2@domain.com', 'test3@domain.com', 'test4@domain.com'];
 
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $this->assertSame($expected, $message->getRecipients());
     }
@@ -66,9 +70,9 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
      */
     function test_get_orig_body()
     {
-        $mime = new Mail_mime();
+        $mime = new \Mail_mime();
         $mime->setTXTBody('test body');
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $expected = "Content-Transfer-Encoding: quoted-printable\r\n"
             . "Content-Type: text/plain; charset=ISO-8859-1\r\n"
@@ -83,10 +87,10 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
      */
     function test_get()
     {
-        $mime = new Mail_mime();
+        $mime = new \Mail_mime();
         $mime->setTXTBody('test body');
 
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
 
         $expected = "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)\r\n"
             ."\r\n"
@@ -114,9 +118,9 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
             str_replace("\r\n", "\n", $message->txtHeaders())
         );
 
-        $mime = new Mail_mime();
+        $mime = new \Mail_mime();
         $mime->setTXTBody('test body');
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_SIGNED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_SIGNED);
         $message->addPGPSignature('signature', 'algorithm');
 
         $signed = "This is an OpenPGP/MIME signed message (RFC 4880 and 3156)\r\n"
@@ -155,9 +159,9 @@ class Enigma_EnigmaMimeMessage extends PHPUnit\Framework\TestCase
             str_replace("\r\n", "\n", $message->txtHeaders())
         );
 
-        $mime = new Mail_mime();
+        $mime = new \Mail_mime();
         $mime->setTXTBody('test body');
-        $message = new enigma_mime_message($mime, enigma_mime_message::PGP_ENCRYPTED);
+        $message = new \enigma_mime_message($mime, \enigma_mime_message::PGP_ENCRYPTED);
         $message->setPGPEncryptedBody('encrypted body');
 
         $encrypted = "This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)\r\n"
diff --git a/plugins/enigma/tests/EnigmaSignature.php b/plugins/enigma/tests/EnigmaSignature.php
index 1db5d61..47a5b7a 100644
--- a/plugins/enigma/tests/EnigmaSignature.php
+++ b/plugins/enigma/tests/EnigmaSignature.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaSignature extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaSignature extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,9 +16,9 @@ class Enigma_EnigmaSignature extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $error = new enigma_signature();
+        $error = new \enigma_signature();
 
-        $this->assertInstanceOf('enigma_signature', $error);
+        $this->assertInstanceOf(\enigma_signature::class, $error);
     }
 }
 
diff --git a/plugins/enigma/tests/EnigmaSubkey.php b/plugins/enigma/tests/EnigmaSubkey.php
index 9074706..d616097 100644
--- a/plugins/enigma/tests/EnigmaSubkey.php
+++ b/plugins/enigma/tests/EnigmaSubkey.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaSubkey extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaSubkey extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,9 +16,9 @@ class Enigma_EnigmaSubkey extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $error = new enigma_subkey();
+        $error = new \enigma_subkey();
 
-        $this->assertInstanceOf('enigma_subkey', $error);
+        $this->assertInstanceOf(\enigma_subkey::class, $error);
     }
 }
 
diff --git a/plugins/enigma/tests/EnigmaUserid.php b/plugins/enigma/tests/EnigmaUserid.php
index 90221bf..da4daf2 100644
--- a/plugins/enigma/tests/EnigmaUserid.php
+++ b/plugins/enigma/tests/EnigmaUserid.php
@@ -1,6 +1,10 @@
 <?php
 
-class Enigma_EnigmaUserid extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_EnigmaUserid extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,9 +16,9 @@ class Enigma_EnigmaUserid extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $error = new enigma_userid();
+        $error = new \enigma_userid();
 
-        $this->assertInstanceOf('enigma_userid', $error);
+        $this->assertInstanceOf(\enigma_userid::class, $error);
     }
 }
 
diff --git a/plugins/example_addressbook/tests/ExampleAddressbook.php b/plugins/example_addressbook/tests/ExampleAddressbook.php
index 30bb786..cb3c375 100644
--- a/plugins/example_addressbook/tests/ExampleAddressbook.php
+++ b/plugins/example_addressbook/tests/ExampleAddressbook.php
@@ -1,6 +1,10 @@
 <?php
 
-class ExampleAddressbook_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_ExampleAddressbook extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -13,11 +17,11 @@ class ExampleAddressbook_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new example_addressbook($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \example_addressbook($rcube->plugins);
 
-        $this->assertInstanceOf('example_addressbook', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\example_addressbook::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         $plugin->init();
     }
@@ -27,8 +31,8 @@ class ExampleAddressbook_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_address_sources()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new example_addressbook($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \example_addressbook($rcube->plugins);
 
         $result = $plugin->address_sources(['sources' => []]);
 
diff --git a/plugins/filesystem_attachments/tests/FilesystemAttachments.php b/plugins/filesystem_attachments/tests/FilesystemAttachments.php
index 3ff710c..61adbe9 100644
--- a/plugins/filesystem_attachments/tests/FilesystemAttachments.php
+++ b/plugins/filesystem_attachments/tests/FilesystemAttachments.php
@@ -1,6 +1,10 @@
 <?php
 
-class FilesystemAttachments_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_FilesystemAttachments extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class FilesystemAttachments_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new filesystem_attachments($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \filesystem_attachments($rcube->plugins);
 
-        $this->assertInstanceOf('filesystem_attachments', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\filesystem_attachments::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/help/tests/Help.php b/plugins/help/tests/Help.php
index 69576ae..40b14ff 100644
--- a/plugins/help/tests/Help.php
+++ b/plugins/help/tests/Help.php
@@ -1,6 +1,10 @@
 <?php
 
-class Help_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Help extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Help_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new help($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \help($rcube->plugins);
 
-        $this->assertInstanceOf('help', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\help::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 
     /**
@@ -24,8 +28,8 @@ class Help_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_help_metadata()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new help($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \help($rcube->plugins);
 
         $result = $plugin->help_metadata();
 
diff --git a/plugins/hide_blockquote/tests/HideBlockquote.php b/plugins/hide_blockquote/tests/HideBlockquote.php
index c8f2885..54a6de1 100644
--- a/plugins/hide_blockquote/tests/HideBlockquote.php
+++ b/plugins/hide_blockquote/tests/HideBlockquote.php
@@ -1,6 +1,10 @@
 <?php
 
-class HideBlockquote_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_HideBlockquote extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class HideBlockquote_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new hide_blockquote($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \hide_blockquote($rcube->plugins);
 
-        $this->assertInstanceOf('hide_blockquote', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\hide_blockquote::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
 
         $plugin->init();
     }
@@ -26,8 +30,8 @@ class HideBlockquote_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_prefs_table()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new hide_blockquote($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \hide_blockquote($rcube->plugins);
 
         $args = ['section' => 'mailview', 'blocks' => ['main' => ['options' => []]]];
 
@@ -49,8 +53,8 @@ class HideBlockquote_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_prefs_save()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new hide_blockquote($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \hide_blockquote($rcube->plugins);
 
         $_POST = [];
         $args  = ['section' => 'mailview', 'prefs' => []];
diff --git a/plugins/http_authentication/tests/HttpAuthentication.php b/plugins/http_authentication/tests/HttpAuthentication.php
index dc3aee5..adacdb5 100644
--- a/plugins/http_authentication/tests/HttpAuthentication.php
+++ b/plugins/http_authentication/tests/HttpAuthentication.php
@@ -1,6 +1,10 @@
 <?php
 
-class HttpAuthentication_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_HttpAuthentication extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class HttpAuthentication_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new http_authentication($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \http_authentication($rcube->plugins);
 
-        $this->assertInstanceOf('http_authentication', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\http_authentication::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/identicon/tests/Identicon.php b/plugins/identicon/tests/Identicon.php
index 03bf2c3..1ec0edf 100644
--- a/plugins/identicon/tests/Identicon.php
+++ b/plugins/identicon/tests/Identicon.php
@@ -1,6 +1,10 @@
 <?php
 
-class Identicon_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Identicon extends TestCase
 {
     public static function setUpBeforeCLass(): void
     {
@@ -12,10 +16,10 @@ class Identicon_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new identicon($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \identicon($rcube->plugins);
 
-        $this->assertInstanceOf('identicon', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\identicon::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/identicon/tests/IdenticonEngine.php b/plugins/identicon/tests/IdenticonEngine.php
index 810805e..a36365a 100644
--- a/plugins/identicon/tests/IdenticonEngine.php
+++ b/plugins/identicon/tests/IdenticonEngine.php
@@ -1,6 +1,10 @@
 <?php
 
-class Identicon_IdenticonEngine extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_IdenticonEngine extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -16,7 +20,7 @@ class Identicon_IdenticonEngine extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        $engine = new identicon_engine('test@domain.com', 10);
+        $engine = new \identicon_engine('test@domain.com', 10);
 
         $icon = $engine->getBinary();
 
diff --git a/plugins/identity_select/tests/IdentitySelect.php b/plugins/identity_select/tests/IdentitySelect.php
index 52038fb..8f9b670 100644
--- a/plugins/identity_select/tests/IdentitySelect.php
+++ b/plugins/identity_select/tests/IdentitySelect.php
@@ -1,6 +1,10 @@
 <?php
 
-class IdentitySelect_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_IdentitySelect extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class IdentitySelect_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new identity_select($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \identity_select($rcube->plugins);
 
-        $this->assertInstanceOf('identity_select', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\identity_select::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/jqueryui/tests/Jqueryui.php b/plugins/jqueryui/tests/Jqueryui.php
index b2361a0..fdd201f 100644
--- a/plugins/jqueryui/tests/Jqueryui.php
+++ b/plugins/jqueryui/tests/Jqueryui.php
@@ -1,6 +1,10 @@
 <?php
 
-class Jqueryui_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Jqueryui extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class Jqueryui_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new jqueryui($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \jqueryui($rcube->plugins);
 
-        $this->assertInstanceOf('jqueryui', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\jqueryui::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/krb_authentication/tests/KrbAuthentication.php b/plugins/krb_authentication/tests/KrbAuthentication.php
index 8bcff76..6c9e989 100644
--- a/plugins/krb_authentication/tests/KrbAuthentication.php
+++ b/plugins/krb_authentication/tests/KrbAuthentication.php
@@ -1,6 +1,10 @@
 <?php
 
-class KrbAuthentication_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_KrbAuthentication extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class KrbAuthentication_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new krb_authentication($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \krb_authentication($rcube->plugins);
 
-        $this->assertInstanceOf('krb_authentication', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\krb_authentication::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/managesieve/tests/Engine.php b/plugins/managesieve/tests/Engine.php
index c66c5f7..b7230a2 100644
--- a/plugins/managesieve/tests/Engine.php
+++ b/plugins/managesieve/tests/Engine.php
@@ -1,6 +1,14 @@
 <?php
 
-class Managesieve_Engine extends ActionTestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use Roundcube\Tests\ActionTestCase;
+
+use function Roundcube\Tests\invokeMethod;
+use function Roundcube\Tests\setProperty;
+
+class Tests_Engine extends ActionTestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -14,8 +22,8 @@ class Managesieve_Engine extends ActionTestCase
      */
     function test_filter_form()
     {
-        $rcube  = rcube::get_instance();
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'managesieve');
+        $rcube  = \rcube::get_instance();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'managesieve');
 
         // Set expected storage function calls/results
         $rcube->storage
@@ -27,8 +35,8 @@ class Managesieve_Engine extends ActionTestCase
             ->registerFunction('mod_folder', 'Test')
             ->registerFunction('folder_attributes', []);
 
-        $plugin = new managesieve($rcube->plugins);
-        $engine = new rcube_sieve_engine($plugin);
+        $plugin = new \managesieve($rcube->plugins);
+        $engine = new \rcube_sieve_engine($plugin);
 
         setProperty($engine, 'exts', ['copy', 'currentdate', 'date', 'duplicate',
             'editheader', 'enotify', 'envelope', 'fileinto', 'imap4flags', 'index',
@@ -49,7 +57,7 @@ class Managesieve_Engine extends ActionTestCase
     /**
      * Data sets for strip_value() test
      */
-    function data_strip_value()
+    static function data_strip_value()
     {
         return [
             ['', ['']],
@@ -67,12 +75,13 @@ class Managesieve_Engine extends ActionTestCase
      *
      * @dataProvider data_strip_value
      */
+    #[DataProvider('data_strip_value')]
     function test_strip_value($expected, $args)
     {
-        $rcube  = rcube::get_instance();
+        $rcube  = \rcube::get_instance();
 
-        $plugin = new managesieve($rcube->plugins);
-        $engine = new rcube_sieve_engine($plugin);
+        $plugin = new \managesieve($rcube->plugins);
+        $engine = new \rcube_sieve_engine($plugin);
 
         $this->assertSame($expected, invokeMethod($engine, 'strip_value', $args));
     }
@@ -82,10 +91,10 @@ class Managesieve_Engine extends ActionTestCase
      */
     function test_list_input()
     {
-        $rcube  = rcube::get_instance();
+        $rcube  = \rcube::get_instance();
 
-        $plugin = new managesieve($rcube->plugins);
-        $engine = new rcube_sieve_engine($plugin);
+        $plugin = new \managesieve($rcube->plugins);
+        $engine = new \rcube_sieve_engine($plugin);
 
         $args     = [1, 'n', '<p>'];
         $expected = '<textarea data-type="list" name="_n[1]" style="display:none" id="n1">&lt;p&gt;</textarea>';
diff --git a/plugins/managesieve/tests/Forward.php b/plugins/managesieve/tests/Forward.php
index 00d3211..6339095 100644
--- a/plugins/managesieve/tests/Forward.php
+++ b/plugins/managesieve/tests/Forward.php
@@ -1,6 +1,12 @@
 <?php
 
-class Managesieve_Forward extends ActionTestCase
+namespace Roundcube\Plugins\Tests;
+
+use Roundcube\Tests\ActionTestCase;
+
+use function Roundcube\Tests\setProperty;
+
+class Tests_Forward extends ActionTestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -14,11 +20,11 @@ class Managesieve_Forward extends ActionTestCase
      */
     function test_vacation_form()
     {
-        $rcube  = rcube::get_instance();
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'managesieve');
+        $rcube  = \rcube::get_instance();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'managesieve');
 
-        $plugin  = new managesieve($rcube->plugins);
-        $forward = new rcube_sieve_forward($plugin);
+        $plugin  = new \managesieve($rcube->plugins);
+        $forward = new \rcube_sieve_forward($plugin);
 
         setProperty($forward, 'forward', ['list' => []]);
         setProperty($forward, 'exts', ['date', 'regex', 'vacation-seconds']);
diff --git a/plugins/managesieve/tests/Managesieve.php b/plugins/managesieve/tests/Managesieve.php
index d54531b..e61cb4e 100644
--- a/plugins/managesieve/tests/Managesieve.php
+++ b/plugins/managesieve/tests/Managesieve.php
@@ -1,6 +1,10 @@
 <?php
 
-class Managesieve_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Managesieve extends TestCase
 {
 
     static function setUpBeforeClass(): void
@@ -13,10 +17,10 @@ class Managesieve_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new managesieve($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \managesieve($rcube->plugins);
 
-        $this->assertInstanceOf('managesieve', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\managesieve::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/managesieve/tests/Script.php b/plugins/managesieve/tests/Script.php
index 0c2c034..b8a6d06 100644
--- a/plugins/managesieve/tests/Script.php
+++ b/plugins/managesieve/tests/Script.php
@@ -1,6 +1,11 @@
 <?php
 
-class Managesieve_Script extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
+class Tests_Script extends TestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -12,6 +17,7 @@ class Managesieve_Script extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_parser
      */
+    #[DataProvider('data_parser')]
     function test_parser($input, $output, $message)
     {
         // get capabilities list from the script
@@ -22,7 +28,7 @@ class Managesieve_Script extends PHPUnit\Framework\TestCase
             }
         }
 
-        $script = new rcube_sieve_script($input, $caps);
+        $script = new \rcube_sieve_script($input, $caps);
         $result = $script->as_text();
 
         $this->assertEquals(trim($output), trim($result), $message);
@@ -31,7 +37,7 @@ class Managesieve_Script extends PHPUnit\Framework\TestCase
     /**
      * Data provider for test_parser()
      */
-    function data_parser()
+    static function data_parser()
     {
         $dir_path = realpath(__DIR__ . '/src');
         $dir      = opendir($dir_path);
@@ -73,7 +79,7 @@ class Managesieve_Script extends PHPUnit\Framework\TestCase
         $this->assertSame("require [\"vacation\"];\r\nvacation :subject \"a\" :from \"b\" \"a\";\r\n", $result);
     }
 
-    function data_tokenizer()
+    static function data_tokenizer()
     {
         return [
             [1, "text: #test\nThis is test ; message;\nMulti line\n.\n;\n", '"This is test ; message;\nMulti line"'],
@@ -91,9 +97,10 @@ class Managesieve_Script extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_tokenizer
      */
+    #[DataProvider('data_tokenizer')]
     function test_tokenizer($num, $input, $output)
     {
-        $res = json_encode(rcube_sieve_script::tokenize($input, $num));
+        $res = json_encode(\rcube_sieve_script::tokenize($input, $num));
 
         $this->assertEquals(trim($output), trim($res));
     }
diff --git a/plugins/managesieve/tests/Vacation.php b/plugins/managesieve/tests/Vacation.php
index 9016f64..ba3c265 100644
--- a/plugins/managesieve/tests/Vacation.php
+++ b/plugins/managesieve/tests/Vacation.php
@@ -1,6 +1,13 @@
 <?php
 
-class Managesieve_Vacation extends ActionTestCase
+namespace Roundcube\Plugins\Tests;
+
+use Roundcube\Tests\ActionTestCase;
+
+use function Roundcube\Tests\invokeMethod;
+use function Roundcube\Tests\setProperty;
+
+class Tests_Vacation extends ActionTestCase
 {
     static function setUpBeforeClass(): void
     {
@@ -14,11 +21,11 @@ class Managesieve_Vacation extends ActionTestCase
      */
     function test_vacation_form()
     {
-        $rcube  = rcube::get_instance();
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'managesieve');
+        $rcube  = \rcube::get_instance();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'managesieve');
 
-        $plugin   = new managesieve($rcube->plugins);
-        $vacation = new rcube_sieve_vacation($plugin);
+        $plugin   = new \managesieve($rcube->plugins);
+        $vacation = new \rcube_sieve_vacation($plugin);
 
         setProperty($vacation, 'vacation', ['list' => []]);
         setProperty($vacation, 'exts', ['date', 'regex', 'vacation-seconds']);
@@ -33,7 +40,7 @@ class Managesieve_Vacation extends ActionTestCase
     function test_build_regexp_tests()
     {
         $error    = null;
-        $vacation = new rcube_sieve_vacation(true);
+        $vacation = new \rcube_sieve_vacation(true);
         $tests    = invokeMethod($vacation, 'build_regexp_tests', ['2014-02-20', '2014-03-05', &$error]);
 
         $this->assertCount(2, $tests);
@@ -69,7 +76,7 @@ class Managesieve_Vacation extends ActionTestCase
             ]
         ];
 
-        $vacation = new rcube_sieve_vacation(true);
+        $vacation = new \rcube_sieve_vacation(true);
         $result   = invokeMethod($vacation, 'parse_regexp_tests', [$tests]);
 
         $this->assertCount(2, $result);
diff --git a/plugins/markasjunk/tests/Markasjunk.php b/plugins/markasjunk/tests/Markasjunk.php
index d10407e..4557ef7 100644
--- a/plugins/markasjunk/tests/Markasjunk.php
+++ b/plugins/markasjunk/tests/Markasjunk.php
@@ -1,6 +1,14 @@
 <?php
 
-class Markasjunk_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\getProperty;
+use function Roundcube\Tests\invokeMethod;
+use function Roundcube\Tests\setProperty;
+
+class Tests_Markasjunk extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +20,11 @@ class Markasjunk_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new markasjunk($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \markasjunk($rcube->plugins);
 
-        $this->assertInstanceOf('markasjunk', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\markasjunk::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 
     /**
@@ -24,8 +32,8 @@ class Markasjunk_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_init_driver()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new markasjunk($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \markasjunk($rcube->plugins);
 
         $drivers = ['amavis_blacklist', 'cmd_learn', 'dir_learn', 'edit_headers', 'email_learn',
             'jsevent', 'sa_blacklist', 'sa_detach'
diff --git a/plugins/new_user_dialog/tests/NewUserDialog.php b/plugins/new_user_dialog/tests/NewUserDialog.php
index 2e3bf1f..ba2df32 100644
--- a/plugins/new_user_dialog/tests/NewUserDialog.php
+++ b/plugins/new_user_dialog/tests/NewUserDialog.php
@@ -1,6 +1,10 @@
 <?php
 
-class NewUserDialog_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_NewUserDialog extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class NewUserDialog_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new new_user_dialog($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \new_user_dialog($rcube->plugins);
 
-        $this->assertInstanceOf('new_user_dialog', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\new_user_dialog::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/new_user_identity/tests/NewUserIdentity.php b/plugins/new_user_identity/tests/NewUserIdentity.php
index 94077a3..fb03e8d 100644
--- a/plugins/new_user_identity/tests/NewUserIdentity.php
+++ b/plugins/new_user_identity/tests/NewUserIdentity.php
@@ -1,6 +1,10 @@
 <?php
 
-class NewUserIdentity_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_NewUserIdentity extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class NewUserIdentity_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new new_user_identity($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \new_user_identity($rcube->plugins);
 
-        $this->assertInstanceOf('new_user_identity', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\new_user_identity::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/newmail_notifier/tests/NewmailNotifier.php b/plugins/newmail_notifier/tests/NewmailNotifier.php
index 6026f04..b87177c 100644
--- a/plugins/newmail_notifier/tests/NewmailNotifier.php
+++ b/plugins/newmail_notifier/tests/NewmailNotifier.php
@@ -1,6 +1,10 @@
 <?php
 
-class NewmailNotifier_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_NewmailNotifier extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class NewmailNotifier_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new newmail_notifier($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \newmail_notifier($rcube->plugins);
 
-        $this->assertInstanceOf('newmail_notifier', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\newmail_notifier::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/password/tests/Password.php b/plugins/password/tests/Password.php
index 4a37c91..4a897a3 100644
--- a/plugins/password/tests/Password.php
+++ b/plugins/password/tests/Password.php
@@ -1,6 +1,10 @@
 <?php
 
-class Password_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Password extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Password_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new password($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \password($rcube->plugins);
 
-        $this->assertInstanceOf('password', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\password::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 
     /**
@@ -93,22 +97,22 @@ class Password_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_hash_password()
     {
-        $pass = password::hash_password('test', 'clear');
+        $pass = \password::hash_password('test', 'clear');
         $this->assertSame('test', $pass);
 
-        $pass = password::hash_password('test', 'ad');
+        $pass = \password::hash_password('test', 'ad');
         $this->assertSame("\"\0t\0e\0s\0t\0\"\0", $pass);
 
-        $pass = password::hash_password('test', 'ssha');
+        $pass = \password::hash_password('test', 'ssha');
         $this->assertMatchesRegularExpression('/^\{SSHA\}[a-zA-Z0-9+\/]{32}$/', $pass);
 
-        $pass = password::hash_password('test', 'ssha256');
+        $pass = \password::hash_password('test', 'ssha256');
         $this->assertMatchesRegularExpression('/^\{SSHA256\}[a-zA-Z0-9+\/=]{48}$/', $pass);
 
-        $pass = password::hash_password('test', 'sha256-crypt');
+        $pass = \password::hash_password('test', 'sha256-crypt');
         $this->assertMatchesRegularExpression('/^\{SHA256-CRYPT\}\$5\$[a-zA-Z0-9]{16}\$[a-zA-Z0-9.\/]{43}$/', $pass);
 
-        $pass = password::hash_password('test', 'hash-bcrypt');
+        $pass = \password::hash_password('test', 'hash-bcrypt');
         $this->assertMatchesRegularExpression('/^\{BLF-CRYPT\}\$2y\$10\$[a-zA-Z0-9.\/]{53}$/', $pass);
 
         // TODO: Test all algos
diff --git a/plugins/redundant_attachments/tests/RedundantAttachments.php b/plugins/redundant_attachments/tests/RedundantAttachments.php
index 1ac6c50..cbccf5c 100644
--- a/plugins/redundant_attachments/tests/RedundantAttachments.php
+++ b/plugins/redundant_attachments/tests/RedundantAttachments.php
@@ -1,6 +1,10 @@
 <?php
 
-class RedundantAttachments_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_RedundantAttachments extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class RedundantAttachments_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new redundant_attachments($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \redundant_attachments($rcube->plugins);
 
-        $this->assertInstanceOf('redundant_attachments', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\redundant_attachments::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php
index 6374ec7..b27d5cc 100644
--- a/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php
+++ b/plugins/show_additional_headers/tests/ShowAdditionalHeaders.php
@@ -1,6 +1,10 @@
 <?php
 
-class ShowAdditionalHeaders_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_ShowAdditionalHeaders extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class ShowAdditionalHeaders_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new show_additional_headers($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \show_additional_headers($rcube->plugins);
 
-        $this->assertInstanceOf('show_additional_headers', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\show_additional_headers::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php
index 1e645dd..b5f3d8b 100644
--- a/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php
+++ b/plugins/squirrelmail_usercopy/tests/SquirrelmailUsercopy.php
@@ -1,6 +1,10 @@
 <?php
 
-class SquirrelmailUsercopy_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_SquirrelmailUsercopy extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class SquirrelmailUsercopy_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new squirrelmail_usercopy($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \squirrelmail_usercopy($rcube->plugins);
 
-        $this->assertInstanceOf('squirrelmail_usercopy', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\squirrelmail_usercopy::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/plugins/subscriptions_option/tests/SubscriptionsOption.php b/plugins/subscriptions_option/tests/SubscriptionsOption.php
index 6af745f..bd4dd6c 100644
--- a/plugins/subscriptions_option/tests/SubscriptionsOption.php
+++ b/plugins/subscriptions_option/tests/SubscriptionsOption.php
@@ -1,6 +1,10 @@
 <?php
 
-class SubscriptionsOption_Plugin extends ActionTestCase
+namespace Roundcube\Plugins\Tests;
+
+use Roundcube\Tests\ActionTestCase;
+
+class Tests_SubscriptionsOption extends ActionTestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class SubscriptionsOption_Plugin extends ActionTestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new subscriptions_option($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \subscriptions_option($rcube->plugins);
 
-        $this->assertInstanceOf('subscriptions_option', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\subscriptions_option::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 
     /**
@@ -24,10 +28,10 @@ class SubscriptionsOption_Plugin extends ActionTestCase
      */
     function test_prefs_list()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new subscriptions_option($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \subscriptions_option($rcube->plugins);
 
-        html::$doctype = 'html5';
+        \html::$doctype = 'html5';
 
         $args = ['section' => 'server', 'blocks' => ['main' => ['options' => []]]];
 
@@ -51,8 +55,8 @@ class SubscriptionsOption_Plugin extends ActionTestCase
     {
         self::initStorage();
 
-        $rcube  = rcube::get_instance();
-        $plugin = new subscriptions_option($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \subscriptions_option($rcube->plugins);
 
         $_POST = ['_use_subscriptions' => 1];
         $args  = ['section' => 'server', 'prefs' => []];
diff --git a/plugins/userinfo/tests/Userinfo.php b/plugins/userinfo/tests/Userinfo.php
index 2f6b90e..5052d08 100644
--- a/plugins/userinfo/tests/Userinfo.php
+++ b/plugins/userinfo/tests/Userinfo.php
@@ -1,6 +1,10 @@
 <?php
 
-class Userinfo_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Userinfo extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class Userinfo_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new userinfo($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \userinfo($rcube->plugins);
 
-        $this->assertInstanceOf('userinfo', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\userinfo::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/vcard_attachments/tests/VcardAttachments.php b/plugins/vcard_attachments/tests/VcardAttachments.php
index e716554..6733fd9 100644
--- a/plugins/vcard_attachments/tests/VcardAttachments.php
+++ b/plugins/vcard_attachments/tests/VcardAttachments.php
@@ -1,6 +1,12 @@
 <?php
 
-class VcardAttachments_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\invokeMethod;
+
+class Tests_VcardAttachments extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +18,11 @@ class VcardAttachments_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new vcard_attachments($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \vcard_attachments($rcube->plugins);
 
-        $this->assertInstanceOf('vcard_attachments', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\vcard_attachments::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 
     /**
@@ -24,10 +30,10 @@ class VcardAttachments_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_is_vcard()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new vcard_attachments($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \vcard_attachments($rcube->plugins);
 
-        $part = new rcube_message_part();
+        $part = new \rcube_message_part();
         $this->assertFalse(invokeMethod($plugin, 'is_vcard', [$part]));
 
         $part->mimetype = 'text/vcard';
diff --git a/plugins/virtuser_file/tests/VirtuserFile.php b/plugins/virtuser_file/tests/VirtuserFile.php
index e021b68..1d7fa98 100644
--- a/plugins/virtuser_file/tests/VirtuserFile.php
+++ b/plugins/virtuser_file/tests/VirtuserFile.php
@@ -1,6 +1,10 @@
 <?php
 
-class VirtuserFile_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_VirtuserFile extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class VirtuserFile_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new virtuser_file($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \virtuser_file($rcube->plugins);
 
-        $this->assertInstanceOf('virtuser_file', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\virtuser_file::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/virtuser_query/tests/VirtuserQuery.php b/plugins/virtuser_query/tests/VirtuserQuery.php
index c7cf10e..bbcc4b7 100644
--- a/plugins/virtuser_query/tests/VirtuserQuery.php
+++ b/plugins/virtuser_query/tests/VirtuserQuery.php
@@ -1,6 +1,10 @@
 <?php
 
-class VirtuserQuery_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_VirtuserQuery extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,11 +16,11 @@ class VirtuserQuery_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new virtuser_query($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \virtuser_query($rcube->plugins);
 
-        $this->assertInstanceOf('virtuser_query', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\virtuser_query::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
 
diff --git a/plugins/zipdownload/tests/Zipdownload.php b/plugins/zipdownload/tests/Zipdownload.php
index d355b38..1d29ab0 100644
--- a/plugins/zipdownload/tests/Zipdownload.php
+++ b/plugins/zipdownload/tests/Zipdownload.php
@@ -1,6 +1,10 @@
 <?php
 
-class Zipdownload_Plugin extends PHPUnit\Framework\TestCase
+namespace Roundcube\Plugins\Tests;
+
+use PHPUnit\Framework\TestCase;
+
+class Tests_Zipdownload extends TestCase
 {
     public static function setUpBeforeClass(): void
     {
@@ -12,10 +16,10 @@ class Zipdownload_Plugin extends PHPUnit\Framework\TestCase
      */
     function test_constructor()
     {
-        $rcube  = rcube::get_instance();
-        $plugin = new zipdownload($rcube->plugins);
+        $rcube  = \rcube::get_instance();
+        $plugin = new \zipdownload($rcube->plugins);
 
-        $this->assertInstanceOf('zipdownload', $plugin);
-        $this->assertInstanceOf('rcube_plugin', $plugin);
+        $this->assertInstanceOf(\zipdownload::class, $plugin);
+        $this->assertInstanceOf(\rcube_plugin::class, $plugin);
     }
 }
diff --git a/tests/ActionTestCase.php b/tests/ActionTestCase.php
index 4fb1288..f0f7dbb 100644
--- a/tests/ActionTestCase.php
+++ b/tests/ActionTestCase.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcmail_action_mail_index
- *
- * @package Tests
  */
-class ActionTestCase extends PHPUnit\Framework\TestCase
+class ActionTestCase extends TestCase
 {
     static $files = [];
 
@@ -15,7 +17,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
         // reset some interfering globals set in other tests
         $_SERVER['REQUEST_URI'] = '';
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->load_gui();
     }
 
@@ -27,11 +29,11 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
 
         self::$files = [];
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->shutdown();
 
         $_FILES = [];
-        rcmail::get_instance()->storage->methodCalls = [];
+        \rcmail::get_instance()->storage->methodCalls = [];
     }
 
     public function setUp(): void
@@ -57,12 +59,12 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
      */
     protected static function initOutput($mode, $task, $action, $framed = false)
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $rcmail->task = $task;
         $rcmail->action = $action;
 
-        if ($mode == rcmail_action::MODE_AJAX) {
+        if ($mode == \rcmail_action::MODE_AJAX) {
             return $rcmail->output = new OutputJsonMock();
         }
 
@@ -86,8 +88,8 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
      */
     public static function initDB($file = null)
     {
-        $rcmail = rcmail::get_instance();
-        $dsn    = rcube_db::parse_dsn($rcmail->config->get('db_dsnw'));
+        $rcmail = \rcmail::get_instance();
+        $dsn    = \rcube_db::parse_dsn($rcmail->config->get('db_dsnw'));
         $db     = $rcmail->get_dbh();
 
         if ($file) {
@@ -129,8 +131,8 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
      */
     public static function initUser()
     {
-        $rcmail = rcmail::get_instance();
-        $rcmail->set_user(new rcube_user(1));
+        $rcmail = \rcmail::get_instance();
+        $rcmail->set_user(new \rcube_user(1));
     }
 
     /**
@@ -138,8 +140,8 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
      */
     public static function initSession()
     {
-        $rcmail = rcmail::get_instance();
-        $rcmail->session = new rcube_session_php($rcmail->config);
+        $rcmail = \rcmail::get_instance();
+        $rcmail->session = new \rcube_session_php($rcmail->config);
     }
 
     /**
@@ -149,7 +151,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
      */
     public static function initStorage()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->storage = new StorageMock();
 
         return $rcmail->storage;
@@ -160,7 +162,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
      */
     protected function createTempFile($content = '')
     {
-        $file = rcube_utils::temp_filename('tests');
+        $file = \rcube_utils::temp_filename('tests');
 
         if ($content !== '') {
             file_put_contents($file, $content);
@@ -184,7 +186,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
         foreach ($sql as $query) {
             $result = $db->query($query);
             if ($db->is_error($result)) {
-                rcube::raise_error($db->is_error(), false, true);
+                \rcube::raise_error($db->is_error(), false, true);
             }
         }
     }
@@ -195,7 +197,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
     protected function runAndAssert($action, $expected_code, $args = [])
     {
         // Reset output in case we execute the method multiple times in a single test
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->output->reset(true);
 
         // reset some static props
@@ -209,7 +211,7 @@ class ActionTestCase extends PHPUnit\Framework\TestCase
         catch (ExitException $e) {
             $this->assertSame($expected_code, $e->getCode());
         }
-        catch (Exception $e) {
+        catch (\Exception $e) {
             if ($e->getMessage() == 'Error raised' && $expected_code == OutputHtmlMock::E_EXIT) {
                 return;
             }
diff --git a/tests/Actions/Contacts/Copy.php b/tests/Actions/Contacts/Copy.php
index 666bce0..9cd505a 100644
--- a/tests/Actions/Contacts/Copy.php
+++ b/tests/Actions/Contacts/Copy.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_copy
- *
- * @package Tests
  */
 class Actions_Contacts_Copy extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Contacts_Copy extends ActionTestCase
      */
     function test_copy_pre_check_errors()
     {
-        $action = new rcmail_action_contacts_copy;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'copy');
+        $action = new \rcmail_action_contacts_copy();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'copy');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Missing target addressbook
@@ -44,7 +47,7 @@ class Actions_Contacts_Copy extends ActionTestCase
         $this->assertSame('this.display_message("Could not copy any contacts.","error",0);', trim($result['exec']));
 
         // target readonly
-        $_POST['_to'] = rcube_addressbook::TYPE_RECIPIENT;
+        $_POST['_to'] = \rcube_addressbook::TYPE_RECIPIENT;
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
@@ -57,7 +60,7 @@ class Actions_Contacts_Copy extends ActionTestCase
         // Non-existing contact
         $_POST = [
             '_cid'    => 100,
-            '_source' => rcube_addressbook::TYPE_RECIPIENT,
+            '_source' => \rcube_addressbook::TYPE_RECIPIENT,
             '_to'     => '0',
         ];
 
@@ -75,21 +78,21 @@ class Actions_Contacts_Copy extends ActionTestCase
      */
     function test_copy_success()
     {
-        $action = new rcmail_action_contacts_copy;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'copy');
+        $action = new \rcmail_action_contacts_copy();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'copy');
 
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $rcmail = rcmail::get_instance();
-        $source = $rcmail->get_address_book(rcube_addressbook::TYPE_RECIPIENT);
+        $rcmail = \rcmail::get_instance();
+        $source = $rcmail->get_address_book(\rcube_addressbook::TYPE_RECIPIENT);
         $cid    = $rcmail->contact_create(['email' => 'test@recipient.com'], $source);
 
         // Missing target addressbook
         $_POST = [
             '_cid'    => $cid,
-            '_source' => rcube_addressbook::TYPE_RECIPIENT,
+            '_source' => \rcube_addressbook::TYPE_RECIPIENT,
             '_to'     => '0',
         ];
 
diff --git a/tests/Actions/Contacts/Delete.php b/tests/Actions/Contacts/Delete.php
index 75c633d..7181b1e 100644
--- a/tests/Actions/Contacts/Delete.php
+++ b/tests/Actions/Contacts/Delete.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_delete
- *
- * @package Tests
  */
 class Actions_Contacts_Delete extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Contacts_Delete extends ActionTestCase
      */
     function test_delete_single_existing_contact()
     {
-        $action = new rcmail_action_contacts_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'delete');
+        $action = new \rcmail_action_contacts_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'delete');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
         $result = $db->fetch_assoc($query);
         $cid    = $result['contact_id'];
diff --git a/tests/Actions/Contacts/Edit.php b/tests/Actions/Contacts/Edit.php
index 96ff745..8a6fb54 100644
--- a/tests/Actions/Contacts/Edit.php
+++ b/tests/Actions/Contacts/Edit.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_contacts_edit
- *
- * @package Tests
  */
 class Actions_Contacts_Edit extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Contacts_Edit extends ActionTestCase
      */
     function test_run_edit_mode()
     {
-        $action = new rcmail_action_contacts_edit;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'edit');
+        $action = new \rcmail_action_contacts_edit();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'edit');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db      = rcmail::get_instance()->get_dbh();
+        $db      = \rcmail::get_instance()->get_dbh();
         $query   = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
         $contact = $db->fetch_assoc($query);
 
@@ -85,13 +88,13 @@ class Actions_Contacts_Edit extends ActionTestCase
      */
     function test_photo_drop_area()
     {
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'edit');
-        $result = rcmail_action_contacts_edit::photo_drop_area([]);
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'edit');
+        $result = \rcmail_action_contacts_edit::photo_drop_area([]);
 
         $this->assertNull($output->get_env('filedrop'));
 
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'edit');
-        $result = rcmail_action_contacts_edit::photo_drop_area(['id' => 'test']);
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'edit');
+        $result = \rcmail_action_contacts_edit::photo_drop_area(['id' => 'test']);
 
         $scripts  = $output->getProperty('scripts');
         $filedrop = $output->get_env('filedrop');
diff --git a/tests/Actions/Contacts/Export.php b/tests/Actions/Contacts/Export.php
index 3c77f90..a6db353 100644
--- a/tests/Actions/Contacts/Export.php
+++ b/tests/Actions/Contacts/Export.php
@@ -1,9 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use PHPUnit\Framework\Attributes\Depends;
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+use Roundcube\Tests\StderrMock;
+
 /**
  * Test class to test rcmail_action_contacts_export
- *
- * @package Tests
  */
 class Actions_Contacts_Export extends ActionTestCase
 {
@@ -12,10 +17,10 @@ class Actions_Contacts_Export extends ActionTestCase
      */
     function test_export_all()
     {
-        $action = new rcmail_action_contacts_export;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'export');
+        $action = new \rcmail_action_contacts_export();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'export');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
@@ -52,15 +57,16 @@ class Actions_Contacts_Export extends ActionTestCase
      *
      * @depends test_export_all
      */
+    #[Depends('test_export_all')]
     function test_export_selected()
     {
-        $action = new rcmail_action_contacts_export;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'export');
+        $action = new \rcmail_action_contacts_export();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'export');
 
         $this->assertTrue($action->checks());
 
         $cids   = [];
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query("SELECT `contact_id` FROM `contacts` WHERE `email` IN ('j.rian@gmail.com', 'g.bush@gov.com')");
         while ($result = $db->fetch_assoc($query)) {
             $cids[] = $result['contact_id'];
@@ -95,6 +101,7 @@ class Actions_Contacts_Export extends ActionTestCase
      *
      * @depends test_export_all
      */
+    #[Depends('test_export_all')]
     function test_export_search()
     {
         $this->markTestIncomplete();
diff --git a/tests/Actions/Contacts/GroupAddmembers.php b/tests/Actions/Contacts/GroupAddmembers.php
index cd05399..50b1d1a 100644
--- a/tests/Actions/Contacts/GroupAddmembers.php
+++ b/tests/Actions/Contacts/GroupAddmembers.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_group_addmembers
- *
- * @package Tests
  */
-class Actions_Contacts_Group_Addmembers extends ActionTestCase
+class Actions_Contacts_GroupAddmembers extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_group_addmembers_errors()
     {
-        $action = new rcmail_action_contacts_group_addmembers;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'add-members');
+        $action = new \rcmail_action_contacts_group_addmembers();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'add-members');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Invalid group id
@@ -30,7 +33,7 @@ class Actions_Contacts_Group_Addmembers extends ActionTestCase
         $this->assertSame('this.display_message("No group assignments changed.","notice",0);', trim($result['exec']));
 
         // Readonly addressbook
-        $_POST = ['_source' => rcube_addressbook::TYPE_RECIPIENT, '_gid' => 'test'];
+        $_POST = ['_source' => \rcube_addressbook::TYPE_RECIPIENT, '_gid' => 'test'];
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
@@ -46,14 +49,14 @@ class Actions_Contacts_Group_Addmembers extends ActionTestCase
      */
     function test_group_addmembers_success()
     {
-        $action = new rcmail_action_contacts_group_addmembers;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'add-members');
+        $action = new \rcmail_action_contacts_group_addmembers();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'add-members');
 
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `contactgroups` WHERE `user_id` = 1 AND `name` = \'test-group\'');
         $result = $db->fetch_assoc($query);
         $gid    = $result['contactgroup_id'];
diff --git a/tests/Actions/Contacts/GroupCreate.php b/tests/Actions/Contacts/GroupCreate.php
index f94a730..cfe434f 100644
--- a/tests/Actions/Contacts/GroupCreate.php
+++ b/tests/Actions/Contacts/GroupCreate.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_group_create
- *
- * @package Tests
  */
-class Actions_Contacts_Group_Create extends ActionTestCase
+class Actions_Contacts_GroupCreate extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_group_create_errors()
     {
-        $action = new rcmail_action_contacts_group_create;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'group-create');
+        $action = new \rcmail_action_contacts_group_create();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'group-create');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Unset group name
@@ -30,7 +33,7 @@ class Actions_Contacts_Group_Create extends ActionTestCase
         $this->assertSame('this.display_message("An error occurred while saving.","error",0);', trim($result['exec']));
 
         // Readonly addressbook
-        $_POST = ['_source' => rcube_addressbook::TYPE_RECIPIENT, '_name' => 'test'];
+        $_POST = ['_source' => \rcube_addressbook::TYPE_RECIPIENT, '_name' => 'test'];
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
@@ -46,8 +49,8 @@ class Actions_Contacts_Group_Create extends ActionTestCase
      */
     function test_group_create_success()
     {
-        $action = new rcmail_action_contacts_group_create;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'group-create');
+        $action = new \rcmail_action_contacts_group_create();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'group-create');
 
         $this->assertTrue($action->checks());
 
@@ -64,7 +67,7 @@ class Actions_Contacts_Group_Create extends ActionTestCase
         $this->assertTrue(strpos($result['exec'], 'this.display_message("Group created successfully.","confirmation",0);') !== false);
         $this->assertTrue(strpos($result['exec'], 'this.insert_contact_group({"source":"0","id":"2","name":"test"});') !== false);
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `contactgroups` WHERE `user_id` = 1 AND `name` = \'test\'');
         $result = $db->fetch_assoc($query);
 
diff --git a/tests/Actions/Contacts/GroupDelete.php b/tests/Actions/Contacts/GroupDelete.php
index eefe30d..6a5adc7 100644
--- a/tests/Actions/Contacts/GroupDelete.php
+++ b/tests/Actions/Contacts/GroupDelete.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_group_delete
- *
- * @package Tests
  */
-class Actions_Contacts_Group_Delete extends ActionTestCase
+class Actions_Contacts_GroupDelete extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_group_delete_errors()
     {
-        $action = new rcmail_action_contacts_group_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'group-delete');
+        $action = new \rcmail_action_contacts_group_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'group-delete');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Invalid group id
@@ -30,7 +33,7 @@ class Actions_Contacts_Group_Delete extends ActionTestCase
         $this->assertSame('this.display_message("An error occurred while saving.","error",0);', trim($result['exec']));
 
         // Readonly addressbook
-        $_POST = ['_source' => rcube_addressbook::TYPE_RECIPIENT, '_name' => 'test'];
+        $_POST = ['_source' => \rcube_addressbook::TYPE_RECIPIENT, '_name' => 'test'];
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
@@ -46,14 +49,14 @@ class Actions_Contacts_Group_Delete extends ActionTestCase
      */
     function test_group_delete_success()
     {
-        $action = new rcmail_action_contacts_group_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'group-delete');
+        $action = new \rcmail_action_contacts_group_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'group-delete');
 
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `contactgroups` WHERE `user_id` = 1 AND `name` = \'test-group\'');
         $result = $db->fetch_assoc($query);
         $gid    = $result['contactgroup_id'];
diff --git a/tests/Actions/Contacts/GroupDelmembers.php b/tests/Actions/Contacts/GroupDelmembers.php
index d8c4a76..db40832 100644
--- a/tests/Actions/Contacts/GroupDelmembers.php
+++ b/tests/Actions/Contacts/GroupDelmembers.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_group_delmembers
- *
- * @package Tests
  */
-class Actions_Contacts_Group_Delmembers extends ActionTestCase
+class Actions_Contacts_GroupDelmembers extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_group_delmembers_errors()
     {
-        $action = new rcmail_action_contacts_group_delmembers;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'del-members');
+        $action = new \rcmail_action_contacts_group_delmembers();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'del-members');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Invalid group id
@@ -30,7 +33,7 @@ class Actions_Contacts_Group_Delmembers extends ActionTestCase
         $this->assertSame('this.display_message("An error occurred while saving.","error",0);', trim($result['exec']));
 
         // Readonly addressbook
-        $_POST = ['_source' => rcube_addressbook::TYPE_RECIPIENT, '_gid' => 'test'];
+        $_POST = ['_source' => \rcube_addressbook::TYPE_RECIPIENT, '_gid' => 'test'];
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
@@ -46,14 +49,14 @@ class Actions_Contacts_Group_Delmembers extends ActionTestCase
      */
     function test_group_delmembers_success()
     {
-        $action = new rcmail_action_contacts_group_delmembers;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'del-members');
+        $action = new \rcmail_action_contacts_group_delmembers();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'del-members');
 
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `contactgroups` WHERE `user_id` = 1 AND `name` = \'test-group\'');
         $result = $db->fetch_assoc($query);
         $gid    = $result['contactgroup_id'];
diff --git a/tests/Actions/Contacts/GroupRename.php b/tests/Actions/Contacts/GroupRename.php
index 1cdf598..f6234c1 100644
--- a/tests/Actions/Contacts/GroupRename.php
+++ b/tests/Actions/Contacts/GroupRename.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_group_rename
- *
- * @package Tests
  */
-class Actions_Contacts_Group_Rename extends ActionTestCase
+class Actions_Contacts_GroupRename extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_group_rename_errors()
     {
-        $action = new rcmail_action_contacts_group_rename;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'group-rename');
+        $action = new \rcmail_action_contacts_group_rename();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'group-rename');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Invalid group id
@@ -30,7 +33,7 @@ class Actions_Contacts_Group_Rename extends ActionTestCase
         $this->assertSame('this.display_message("An error occurred while saving.","error",0);', trim($result['exec']));
 
         // Readonly addressbook
-        $_POST = ['_source' => rcube_addressbook::TYPE_RECIPIENT, '_gid' => 'aaa', '_name' => 'new-test'];
+        $_POST = ['_source' => \rcube_addressbook::TYPE_RECIPIENT, '_gid' => 'aaa', '_name' => 'new-test'];
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
@@ -46,14 +49,14 @@ class Actions_Contacts_Group_Rename extends ActionTestCase
      */
     function test_group_rename_success()
     {
-        $action = new rcmail_action_contacts_group_rename;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'group-rename');
+        $action = new \rcmail_action_contacts_group_rename();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'group-rename');
 
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `contactgroups` WHERE `user_id` = 1 AND `name` = \'test-group\'');
         $result = $db->fetch_assoc($query);
         $gid    = $result['contactgroup_id'];
diff --git a/tests/Actions/Contacts/Import.php b/tests/Actions/Contacts/Import.php
index 431ab02..6c60394 100644
--- a/tests/Actions/Contacts/Import.php
+++ b/tests/Actions/Contacts/Import.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_contacts_import
- *
- * @package Tests
  */
 class Actions_Contacts_Import extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Contacts_Import extends ActionTestCase
      */
     function test_run_init()
     {
-        $action = new rcmail_action_contacts_import;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'import');
+        $action = new \rcmail_action_contacts_import();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'import');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
diff --git a/tests/Actions/Contacts/Index.php b/tests/Actions/Contacts/Index.php
index 9d30da8..8970d2f 100644
--- a/tests/Actions/Contacts/Index.php
+++ b/tests/Actions/Contacts/Index.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_contacts_index
- *
- * @package Tests
  */
 class Actions_Contacts_Index extends ActionTestCase
 {
@@ -12,10 +14,10 @@ class Actions_Contacts_Index extends ActionTestCase
      */
     function test_run_http()
     {
-        $action = new rcmail_action_contacts_index;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', '');
+        $action = new \rcmail_action_contacts_index();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', '');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // self::initDB('contacts');
@@ -39,8 +41,8 @@ class Actions_Contacts_Index extends ActionTestCase
      */
     function test_run_ajax()
     {
-        $action = new rcmail_action_contacts_index;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'list');
+        $action = new \rcmail_action_contacts_index();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'list');
 
         $this->assertTrue($action->checks());
 
@@ -115,8 +117,8 @@ class Actions_Contacts_Index extends ActionTestCase
      */
     function test_rowcount_display()
     {
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', '');
-        $result = rcmail_action_contacts_index::rowcount_display([]);
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', '');
+        $result = \rcmail_action_contacts_index::rowcount_display([]);
 
         $this->assertSame('<span id="rcmcountdisplay">Loading...</span>', $result);
     }
@@ -134,8 +136,8 @@ class Actions_Contacts_Index extends ActionTestCase
      */
     function test_get_type_label()
     {
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', '');
-        $result = rcmail_action_contacts_index::get_type_label('home');
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', '');
+        $result = \rcmail_action_contacts_index::get_type_label('home');
 
         $this->assertSame('Home', $result);
     }
@@ -177,9 +179,9 @@ class Actions_Contacts_Index extends ActionTestCase
      */
     function test_source_selector()
     {
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', '');
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', '');
 
-        $result   = rcmail_action_contacts_index::source_selector([]);
+        $result   = \rcmail_action_contacts_index::source_selector([]);
         $expected = '<span>Personal Addresses<input type="hidden" name="_source" value="0"></span>';
 
         $this->assertSame($expected, $result);
diff --git a/tests/Actions/Contacts/List.php b/tests/Actions/Contacts/List.php
index bd17870..568bf3f 100644
--- a/tests/Actions/Contacts/List.php
+++ b/tests/Actions/Contacts/List.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_list
- *
- * @package Tests
  */
 class Actions_Contacts_List extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Contacts_List extends ActionTestCase
      */
     function test_list()
     {
-        $action = new rcmail_action_contacts_list;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'list');
+        $action = new \rcmail_action_contacts_list();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'list');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
diff --git a/tests/Actions/Contacts/Mailto.php b/tests/Actions/Contacts/Mailto.php
index e65b2d8..bd47f24 100644
--- a/tests/Actions/Contacts/Mailto.php
+++ b/tests/Actions/Contacts/Mailto.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_mailto
- *
- * @package Tests
  */
 class Actions_Contacts_Mailto extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Contacts_Mailto extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_contacts_mailto;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'mailto');
+        $action = new \rcmail_action_contacts_mailto();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'mailto');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT `contact_id` FROM `contacts` WHERE `email` = ?', 'johndoe@example.org');
         $result = $db->fetch_assoc($query);
         $cid    = $result['contact_id'];
diff --git a/tests/Actions/Contacts/Move.php b/tests/Actions/Contacts/Move.php
index e7f99bf..598a404 100644
--- a/tests/Actions/Contacts/Move.php
+++ b/tests/Actions/Contacts/Move.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_move
- *
- * @package Tests
  */
 class Actions_Contacts_Move extends ActionTestCase
 {
@@ -12,20 +15,20 @@ class Actions_Contacts_Move extends ActionTestCase
      */
     function test_move_contact()
     {
-        $action = new rcmail_action_contacts_move;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'move');
+        $action = new \rcmail_action_contacts_move();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'move');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db      = rcmail::get_instance()->get_dbh();
+        $db      = \rcmail::get_instance()->get_dbh();
         $query   = $db->query('SELECT * FROM `collected_addresses` WHERE `email` = ?', 'test@collected.eu');
         $contact = $db->fetch_assoc($query);
         $cid     = $contact['address_id'];
 
-        $_POST = ['_cid' => $cid, '_to' => '0', '_source' => rcube_addressbook::TYPE_RECIPIENT];
+        $_POST = ['_cid' => $cid, '_to' => '0', '_source' => \rcube_addressbook::TYPE_RECIPIENT];
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
diff --git a/tests/Actions/Contacts/Photo.php b/tests/Actions/Contacts/Photo.php
index 4b7d0da..f69add0 100644
--- a/tests/Actions/Contacts/Photo.php
+++ b/tests/Actions/Contacts/Photo.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_photo
- *
- * @package Tests
  */
 class Actions_Contacts_Photo extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Contacts_Photo extends ActionTestCase
      */
     function test_no_photo()
     {
-        $action = new rcmail_action_contacts_photo;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'photo');
+        $action = new \rcmail_action_contacts_photo();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'photo');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
@@ -23,7 +26,7 @@ class Actions_Contacts_Photo extends ActionTestCase
         $result = $output->getOutput();
 
         $this->assertSame(['Content-Type: image/gif'], $output->headers);
-        $this->assertSame(base64_decode(rcmail_output::BLANK_GIF), $result);
+        $this->assertSame(base64_decode(\rcmail_output::BLANK_GIF), $result);
 
         $_GET = ['_error' => 1];
 
diff --git a/tests/Actions/Contacts/Print.php b/tests/Actions/Contacts/Print.php
index 7aba114..fc2723b 100644
--- a/tests/Actions/Contacts/Print.php
+++ b/tests/Actions/Contacts/Print.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_contacts_print
- *
- * @package Tests
  */
 class Actions_Contacts_Print extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Contacts_Print extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_contacts_print;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'print');
+        $action = new \rcmail_action_contacts_print();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'print');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db      = rcmail::get_instance()->get_dbh();
+        $db      = \rcmail::get_instance()->get_dbh();
         $query   = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
         $contact = $db->fetch_assoc($query);
 
diff --git a/tests/Actions/Contacts/Qrcode.php b/tests/Actions/Contacts/Qrcode.php
index bfb71e8..3354f7d 100644
--- a/tests/Actions/Contacts/Qrcode.php
+++ b/tests/Actions/Contacts/Qrcode.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use PHPUnit\Framework\Attributes\Group;
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_qrcode
- *
- * @package Tests
  */
 class Actions_Contacts_Qrcode extends ActionTestCase
 {
@@ -11,12 +15,13 @@ class Actions_Contacts_Qrcode extends ActionTestCase
      * Test run() method
      * @group qrcode
      */
+    #[Group('qrcode')]
     function test_run()
     {
-        $action = new rcmail_action_contacts_qrcode;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'qrcode');
+        $action = new \rcmail_action_contacts_qrcode();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'qrcode');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
@@ -32,7 +37,7 @@ class Actions_Contacts_Qrcode extends ActionTestCase
             $this->markTestSkipped();
         }
 
-        $db      = rcmail::get_instance()->get_dbh();
+        $db      = \rcmail::get_instance()->get_dbh();
         $query   = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 AND `name` = \'Jon Snow\'');
         $contact = $db->fetch_assoc($query);
 
diff --git a/tests/Actions/Contacts/Save.php b/tests/Actions/Contacts/Save.php
index 7ca1432..078989a 100644
--- a/tests/Actions/Contacts/Save.php
+++ b/tests/Actions/Contacts/Save.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_contacts_save
- *
- * @package Tests
  */
 class Actions_Contacts_Save extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Contacts_Save extends ActionTestCase
      */
     function test_run_prechecks()
     {
-        $action = new rcmail_action_contacts_save;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'save');
+        $action = new \rcmail_action_contacts_save();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'save');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // reload
@@ -25,16 +28,16 @@ class Actions_Contacts_Save extends ActionTestCase
 
         $this->assertSame(null, $output->getOutput());
         $this->assertSame(null, $output->getProperty('message'));
-        $this->assertSame('add', rcmail::get_instance()->action);
+        $this->assertSame('add', \rcmail::get_instance()->action);
 
         // readonly addressbook
-        $_GET = ['_source' => rcube_addressbook::TYPE_RECIPIENT];
+        $_GET = ['_source' => \rcube_addressbook::TYPE_RECIPIENT];
 
         $action->run();
 
         $this->assertSame(null, $output->getOutput());
         $this->assertSame('contactreadonly', $output->getProperty('message'));
-        $this->assertSame('add', rcmail::get_instance()->action);
+        $this->assertSame('add', \rcmail::get_instance()->action);
 
         // empty $_POST
         $_POST = ['_source' => '0'];
@@ -43,7 +46,7 @@ class Actions_Contacts_Save extends ActionTestCase
 
         $this->assertSame(null, $output->getOutput());
         $this->assertSame('nonamewarning', $output->getProperty('message'));
-        $this->assertSame('add', rcmail::get_instance()->action);
+        $this->assertSame('add', \rcmail::get_instance()->action);
     }
 
     /**
@@ -51,8 +54,8 @@ class Actions_Contacts_Save extends ActionTestCase
      */
     function test_run_new_contact()
     {
-        $action = new rcmail_action_contacts_save;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'save');
+        $action = new \rcmail_action_contacts_save();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'save');
 
         self::initDB('contacts');
 
@@ -72,7 +75,7 @@ class Actions_Contacts_Save extends ActionTestCase
         $this->assertSame('successfullysaved', $output->getProperty('message'));
         $this->assertTrue(stripos($result, "<!DOCTYPE html>") === 0);
 
-        $db      = rcmail::get_instance()->get_dbh();
+        $db      = \rcmail::get_instance()->get_dbh();
         $query   = $db->query('SELECT `contact_id` FROM `contacts` WHERE `email` = ?', 'test@user.com');
         $contact = $db->fetch_assoc($query);
 
diff --git a/tests/Actions/Contacts/Search.php b/tests/Actions/Contacts/Search.php
index 3b065d0..40e17b5 100644
--- a/tests/Actions/Contacts/Search.php
+++ b/tests/Actions/Contacts/Search.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_search
- *
- * @package Tests
  */
 class Actions_Contacts_Search extends ActionTestCase
 {
@@ -12,10 +16,10 @@ class Actions_Contacts_Search extends ActionTestCase
      */
     function test_run_search_form()
     {
-        $action = new rcmail_action_contacts_search;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'search');
+        $action = new \rcmail_action_contacts_search();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'search');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $_GET = ['_form' => 1];
@@ -34,8 +38,8 @@ class Actions_Contacts_Search extends ActionTestCase
      */
     function test_run_quick_search()
     {
-        $action = new rcmail_action_contacts_search;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'search');
+        $action = new \rcmail_action_contacts_search();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'search');
 
         $this->assertTrue($action->checks());
 
diff --git a/tests/Actions/Contacts/SearchCreate.php b/tests/Actions/Contacts/SearchCreate.php
index 4c5f8b6..863f77d 100644
--- a/tests/Actions/Contacts/SearchCreate.php
+++ b/tests/Actions/Contacts/SearchCreate.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_search_create
- *
- * @package Tests
  */
-class Actions_Contacts_Search_Create extends ActionTestCase
+class Actions_Contacts_SearchCreate extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_search_create_errors()
     {
-        $action = new rcmail_action_contacts_search_create;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'search-create');
+        $action = new \rcmail_action_contacts_search_create();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'search-create');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Unset group name
@@ -35,8 +38,8 @@ class Actions_Contacts_Search_Create extends ActionTestCase
      */
     function test_search_create_success()
     {
-        $action = new rcmail_action_contacts_search_create;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'search-create');
+        $action = new \rcmail_action_contacts_search_create();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'search-create');
 
         $this->assertTrue($action->checks());
 
@@ -57,7 +60,7 @@ class Actions_Contacts_Search_Create extends ActionTestCase
         $this->assertTrue(strpos($result['exec'], 'this.display_message("Saved search created successfully.","confirmation",0);') !== false);
         $this->assertTrue(strpos($result['exec'], 'this.insert_saved_search("test2",') !== false);
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `searches` WHERE `name` = \'test2\'');
         $result = $db->fetch_assoc($query);
 
diff --git a/tests/Actions/Contacts/SearchDelete.php b/tests/Actions/Contacts/SearchDelete.php
index b48a544..d3dffe2 100644
--- a/tests/Actions/Contacts/SearchDelete.php
+++ b/tests/Actions/Contacts/SearchDelete.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_search_delete
- *
- * @package Tests
  */
-class Actions_Contacts_Search_Delete extends ActionTestCase
+class Actions_Contacts_SearchDelete extends ActionTestCase
 {
     /**
      * Test error handling
      */
     function test_search_delete_errors()
     {
-        $action = new rcmail_action_contacts_search_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'search-delete');
+        $action = new \rcmail_action_contacts_search_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'search-delete');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $_POST = ['_sid' => 'unknown'];
@@ -34,14 +37,14 @@ class Actions_Contacts_Search_Delete extends ActionTestCase
      */
     function test_search_create_success()
     {
-        $action = new rcmail_action_contacts_search_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'search-delete');
+        $action = new \rcmail_action_contacts_search_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'search-delete');
 
         $this->assertTrue($action->checks());
 
         self::initDB('searches');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `searches` WHERE `name` = \'test\'');
         $result = $db->fetch_assoc($query);
         $sid    = $result['search_id'];
diff --git a/tests/Actions/Contacts/Show.php b/tests/Actions/Contacts/Show.php
index c47e74b..f3c19d9 100644
--- a/tests/Actions/Contacts/Show.php
+++ b/tests/Actions/Contacts/Show.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_contacts_show
- *
- * @package Tests
  */
 class Actions_Contacts_Show extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Contacts_Show extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_contacts_show;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'contacts', 'show');
+        $action = new \rcmail_action_contacts_show();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'contacts', 'show');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db      = rcmail::get_instance()->get_dbh();
+        $db      = \rcmail::get_instance()->get_dbh();
         $query   = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
         $contact = $db->fetch_assoc($query);
 
@@ -65,7 +68,7 @@ class Actions_Contacts_Show extends ActionTestCase
         $input = 'test@<email.tld';
         $expected = '<a href="mailto:test@&lt;email.tld" onclick="return rcmail.command(\'compose\',\'test@&lt;email.tld\',this)"'
             . ' title="Compose mail to" class="email">test@&lt;email.tld</a>';
-        $this->assertSame($expected, rcmail_action_contacts_show::render_email_value($input));
+        $this->assertSame($expected, \rcmail_action_contacts_show::render_email_value($input));
     }
 
     /**
@@ -75,7 +78,7 @@ class Actions_Contacts_Show extends ActionTestCase
     {
         $input = '+48-123<456';
         $expected = '<a href="tel:+48-123456" class="phone">+48-123&lt;456</a>';
-        $this->assertSame($expected, rcmail_action_contacts_show::render_phone_value($input));
+        $this->assertSame($expected, \rcmail_action_contacts_show::render_phone_value($input));
     }
 
     /**
@@ -85,7 +88,7 @@ class Actions_Contacts_Show extends ActionTestCase
     {
         $input = 'http://test/<123';
         $expected = '<a href="http://test/&lt;123" target="_blank" class="url">http://test/&lt;123</a>';
-        $this->assertSame($expected, rcmail_action_contacts_show::render_url_value($input));
+        $this->assertSame($expected, \rcmail_action_contacts_show::render_url_value($input));
     }
 
     /**
diff --git a/tests/Actions/Contacts/Undo.php b/tests/Actions/Contacts/Undo.php
index 13c2c8b..adae44b 100644
--- a/tests/Actions/Contacts/Undo.php
+++ b/tests/Actions/Contacts/Undo.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_undo
- *
- * @package Tests
  */
 class Actions_Contacts_Undo extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Contacts_Undo extends ActionTestCase
      */
     function test_undo()
     {
-        $action = new rcmail_action_contacts_undo;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'undo');
+        $action = new \rcmail_action_contacts_undo();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'undo');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('contacts');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT `contact_id` FROM `contacts` WHERE `user_id` = 1 LIMIT 1');
         $result = $db->fetch_assoc($query);
         $cid    = $result['contact_id'];
diff --git a/tests/Actions/Contacts/UploadPhoto.php b/tests/Actions/Contacts/UploadPhoto.php
index ffd144e..2f670b7 100644
--- a/tests/Actions/Contacts/UploadPhoto.php
+++ b/tests/Actions/Contacts/UploadPhoto.php
@@ -1,21 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_contacts_upload_photo
- *
- * @package Tests
  */
-class Actions_Contacts_Upload_Photo extends ActionTestCase
+class Actions_Contacts_UploadPhoto extends ActionTestCase
 {
     /**
      * Test photo upload
      */
     function test_run()
     {
-        $action = new rcmail_action_contacts_upload_photo;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'contacts', 'upload-photo');
+        $action = new \rcmail_action_contacts_upload_photo();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'contacts', 'upload-photo');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $_SERVER['REQUEST_METHOD'] = 'POST';
@@ -30,7 +33,7 @@ class Actions_Contacts_Upload_Photo extends ActionTestCase
         $this->assertTrue(strpos($result['exec'], 'this.photo_upload_end();') !== false);
 
         // Upload a file
-        $content = base64_decode(rcmail_output::BLANK_GIF);
+        $content = base64_decode(\rcmail_output::BLANK_GIF);
         $file    = $this->createTempFile($content);
         $_SESSION['contacts'] = null;
         $_FILES['_photo']     = [
@@ -43,7 +46,7 @@ class Actions_Contacts_Upload_Photo extends ActionTestCase
 
         // Attachments handling plugins use move_uploaded_file() which does not work
         // here. We'll add a fake hook handler for our purposes.
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->plugins->register_hook('attachment_upload', function($att) {
             $att['status'] = true;
             $att['id']     = 'fake';
diff --git a/tests/Actions/Login/Oauth.php b/tests/Actions/Login/Oauth.php
index 903f271..bdb5e38 100644
--- a/tests/Actions/Login/Oauth.php
+++ b/tests/Actions/Login/Oauth.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+use Roundcube\Tests\StderrMock;
+
 /**
  * Test class to test rcmail_action_login_oauth
- *
- * @package Tests
  */
 class Actions_Login_Oauth extends ActionTestCase
 {
@@ -12,10 +16,10 @@ class Actions_Login_Oauth extends ActionTestCase
      */
     function test_run_login_redirect()
     {
-        $action = new rcmail_action_login_oauth;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'login', '');
+        $action = new \rcmail_action_login_oauth();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'login', '');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $this->runAndAssert($action, OutputHtmlMock::E_EXIT);
diff --git a/tests/Actions/Mail/Addcontact.php b/tests/Actions/Mail/Addcontact.php
index a2ff9ae..1fa10fe 100644
--- a/tests/Actions/Mail/Addcontact.php
+++ b/tests/Actions/Mail/Addcontact.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_addcontact
- *
- * @package Tests
  */
 class Actions_Mail_Addcontact extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Addcontact extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_addcontact;
+        $object = new \rcmail_action_mail_addcontact();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/AttachmentDelete.php b/tests/Actions/Mail/AttachmentDelete.php
index 945de8f..f55afe2 100644
--- a/tests/Actions/Mail/AttachmentDelete.php
+++ b/tests/Actions/Mail/AttachmentDelete.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_attachment_delete
- *
- * @package Tests
  */
 class Actions_Mail_AttachmentDelete extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_AttachmentDelete extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_attachment_delete;
+        $object = new \rcmail_action_mail_attachment_delete();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/AttachmentDisplay.php b/tests/Actions/Mail/AttachmentDisplay.php
index 739c68a..befd8d6 100644
--- a/tests/Actions/Mail/AttachmentDisplay.php
+++ b/tests/Actions/Mail/AttachmentDisplay.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_attachment_display
- *
- * @package Tests
  */
 class Actions_Mail_AttachmentDisplay extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_AttachmentDisplay extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_attachment_display;
+        $object = new \rcmail_action_mail_attachment_display();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/AttachmentRename.php b/tests/Actions/Mail/AttachmentRename.php
index dde8593..90a2917 100644
--- a/tests/Actions/Mail/AttachmentRename.php
+++ b/tests/Actions/Mail/AttachmentRename.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_attachment_rename
- *
- * @package Tests
  */
 class Actions_Mail_AttachmentRename extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_AttachmentRename extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_attachment_rename;
+        $object = new \rcmail_action_mail_attachment_rename();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/AttachmentUpload.php b/tests/Actions/Mail/AttachmentUpload.php
index 00b65ba..698914c 100644
--- a/tests/Actions/Mail/AttachmentUpload.php
+++ b/tests/Actions/Mail/AttachmentUpload.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_attachment_upload
- *
- * @package Tests
  */
 class Actions_Mail_Attachmentupload extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Attachmentupload extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_attachment_upload;
+        $object = new \rcmail_action_mail_attachment_upload();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Autocomplete.php b/tests/Actions/Mail/Autocomplete.php
index c8aed34..2ef355c 100644
--- a/tests/Actions/Mail/Autocomplete.php
+++ b/tests/Actions/Mail/Autocomplete.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_autocomplete
- *
- * @package Tests
  */
 class Actions_Mail_Autocomplete extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Autocomplete extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_autocomplete;
+        $object = new \rcmail_action_mail_autocomplete();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Bounce.php b/tests/Actions/Mail/Bounce.php
index 9a3af4b..d091579 100644
--- a/tests/Actions/Mail/Bounce.php
+++ b/tests/Actions/Mail/Bounce.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_bounce
- *
- * @package Tests
  */
 class Actions_Mail_Bounce extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Bounce extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_bounce;
+        $object = new \rcmail_action_mail_bounce();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/CheckRecent.php b/tests/Actions/Mail/CheckRecent.php
index 9357c58..ed9caed 100644
--- a/tests/Actions/Mail/CheckRecent.php
+++ b/tests/Actions/Mail/CheckRecent.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_check_recent
- *
- * @package Tests
  */
 class Actions_Mail_CheckRecent extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_CheckRecent extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_check_recent;
+        $object = new \rcmail_action_mail_check_recent();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Compose.php b/tests/Actions/Mail/Compose.php
index c66f64d..ca681b7 100644
--- a/tests/Actions/Mail/Compose.php
+++ b/tests/Actions/Mail/Compose.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_compose
- *
- * @package Tests
  */
 class Actions_Mail_Compose extends ActionTestCase
 {
@@ -12,9 +14,9 @@ class Actions_Mail_Compose extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_compose;
+        $object = new \rcmail_action_mail_compose();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 
     /**
@@ -22,7 +24,7 @@ class Actions_Mail_Compose extends ActionTestCase
      */
     function test_quote_text()
     {
-        $action = new rcmail_action_mail_compose;
+        $action = new \rcmail_action_mail_compose();
 
         $this->assertSame('> ', $action->quote_text(''));
 
diff --git a/tests/Actions/Mail/Copy.php b/tests/Actions/Mail/Copy.php
index 92ca6ee..2709784 100644
--- a/tests/Actions/Mail/Copy.php
+++ b/tests/Actions/Mail/Copy.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_mail_copy
- *
- * @package Tests
  */
 class Actions_Mail_Copy extends ActionTestCase
 {
@@ -12,9 +15,9 @@ class Actions_Mail_Copy extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_copy;
+        $object = new \rcmail_action_mail_copy();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 
     /**
@@ -22,8 +25,8 @@ class Actions_Mail_Copy extends ActionTestCase
      */
     function test_copy_message()
     {
-        $action = new rcmail_action_mail_copy;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'copy');
+        $action = new \rcmail_action_mail_copy();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'copy');
 
         $this->assertTrue($action->checks());
 
@@ -34,7 +37,7 @@ class Actions_Mail_Copy extends ActionTestCase
         ];
 
         // Set expected storage function calls/results
-        $storage = rcmail::get_instance()->storage;
+        $storage = \rcmail::get_instance()->storage;
         $storage->registerFunction('copy_message', true);
         $storage->registerFunction('count', 30);
         $storage->registerFunction('get_quota', false);
@@ -55,8 +58,8 @@ class Actions_Mail_Copy extends ActionTestCase
      */
     function test_copy_message_error()
     {
-        $action = new rcmail_action_mail_copy;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'copy');
+        $action = new \rcmail_action_mail_copy();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'copy');
 
         $_POST = [
             '_uid'         => 1,
@@ -65,10 +68,10 @@ class Actions_Mail_Copy extends ActionTestCase
         ];
 
         // Set expected storage function calls/results
-        $storage = rcmail::get_instance()->storage;
+        $storage = \rcmail::get_instance()->storage;
         $storage->registerFunction('copy_message', false);
         $storage->registerFunction('get_error_code', -1);
-        $storage->registerFunction('get_response_code', rcube_storage::READONLY);
+        $storage->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
diff --git a/tests/Actions/Mail/Delete.php b/tests/Actions/Mail/Delete.php
index be00713..e370bc3 100644
--- a/tests/Actions/Mail/Delete.php
+++ b/tests/Actions/Mail/Delete.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_delete
- *
- * @package Tests
  */
 class Actions_Mail_Delete extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Delete extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_delete;
+        $object = new \rcmail_action_mail_delete();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/FolderExpunge.php b/tests/Actions/Mail/FolderExpunge.php
index 5ece885..5961527 100644
--- a/tests/Actions/Mail/FolderExpunge.php
+++ b/tests/Actions/Mail/FolderExpunge.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_mail_folder_expunge
- *
- * @package Tests
  */
 class Actions_Mail_FolderExpunge extends ActionTestCase
 {
@@ -12,9 +15,9 @@ class Actions_Mail_FolderExpunge extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_folder_expunge;
+        $object = new \rcmail_action_mail_folder_expunge();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 
     /**
@@ -22,15 +25,15 @@ class Actions_Mail_FolderExpunge extends ActionTestCase
      */
     function test_folder_expunge()
     {
-        $action = new rcmail_action_mail_folder_expunge;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'expunge');
+        $action = new \rcmail_action_mail_folder_expunge();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'expunge');
 
         $this->assertTrue($action->checks());
 
         $_POST = ['_mbox' => 'INBOX'];
 
         // Set expected storage function calls/results
-        $storage = rcmail::get_instance()->storage;
+        $storage = \rcmail::get_instance()->storage;
         $storage->registerFunction('expunge_folder', true);
         $storage->registerFunction('get_quota', false);
 
@@ -49,8 +52,8 @@ class Actions_Mail_FolderExpunge extends ActionTestCase
      */
     function test_folder_expunge_with_reload()
     {
-        $action = new rcmail_action_mail_folder_expunge;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'expunge');
+        $action = new \rcmail_action_mail_folder_expunge();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'expunge');
 
         $this->assertTrue($action->checks());
 
@@ -58,7 +61,7 @@ class Actions_Mail_FolderExpunge extends ActionTestCase
         $_REQUEST = ['_reload' => 1];
 
         // Set expected storage function calls/results
-        $storage = rcmail::get_instance()->storage;
+        $storage = \rcmail::get_instance()->storage;
         $storage->registerFunction('expunge_folder', true);
         $storage->registerFunction('get_quota', false);
 
@@ -67,7 +70,7 @@ class Actions_Mail_FolderExpunge extends ActionTestCase
         $commands = $output->getProperty('commands');
 
         $this->assertNull($output->getOutput());
-        $this->assertSame('list', rcmail::get_instance()->action);
+        $this->assertSame('list', \rcmail::get_instance()->action);
         $this->assertCount(3, $commands);
         $this->assertSame([
                 'display_message',
@@ -86,16 +89,16 @@ class Actions_Mail_FolderExpunge extends ActionTestCase
      */
     function test_folder_expunge_error()
     {
-        $action = new rcmail_action_mail_folder_expunge;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'expunge');
+        $action = new \rcmail_action_mail_folder_expunge();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'expunge');
 
         $_POST = ['_mbox' => 'INBOX'];
 
         // Set expected storage function calls/results
-        $storage = rcmail::get_instance()->storage;
+        $storage = \rcmail::get_instance()->storage;
         $storage->registerFunction('expunge_folder', false);
         $storage->registerFunction('get_error_code', -1);
-        $storage->registerFunction('get_response_code', rcube_storage::READONLY);
+        $storage->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $this->runAndAssert($action, OutputJsonMock::E_EXIT);
 
diff --git a/tests/Actions/Mail/FolderPurge.php b/tests/Actions/Mail/FolderPurge.php
index a0785e0..17832ea 100644
--- a/tests/Actions/Mail/FolderPurge.php
+++ b/tests/Actions/Mail/FolderPurge.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_folder_purge
- *
- * @package Tests
  */
 class Actions_Mail_FolderPurge extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_FolderPurge extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_folder_purge;
+        $object = new \rcmail_action_mail_folder_purge();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Get.php b/tests/Actions/Mail/Get.php
index d32bd75..f0e9060 100644
--- a/tests/Actions/Mail/Get.php
+++ b/tests/Actions/Mail/Get.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_get
- *
- * @package Tests
  */
 class Actions_Mail_Get extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Get extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_get;
+        $object = new \rcmail_action_mail_get();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Getunread.php b/tests/Actions/Mail/Getunread.php
index d17dfaa..e52db6a 100644
--- a/tests/Actions/Mail/Getunread.php
+++ b/tests/Actions/Mail/Getunread.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_getunread
- *
- * @package Tests
  */
 class Actions_Mail_Getunread extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Getunread extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_getunread;
+        $object = new \rcmail_action_mail_getunread();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/GroupExpand.php b/tests/Actions/Mail/GroupExpand.php
index 25243ee..10aa294 100644
--- a/tests/Actions/Mail/GroupExpand.php
+++ b/tests/Actions/Mail/GroupExpand.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_group_expand
- *
- * @package Tests
  */
 class Actions_Mail_GroupExpand extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_GroupExpand extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_group_expand;
+        $object = new \rcmail_action_mail_group_expand();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Headers.php b/tests/Actions/Mail/Headers.php
index 4121e03..a81b779 100644
--- a/tests/Actions/Mail/Headers.php
+++ b/tests/Actions/Mail/Headers.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_headers
- *
- * @package Tests
  */
 class Actions_Mail_Headers extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Headers extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_headers;
+        $object = new \rcmail_action_mail_headers();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Index.php b/tests/Actions/Mail/Index.php
index d3fcca2..e9ceca0 100644
--- a/tests/Actions/Mail/Index.php
+++ b/tests/Actions/Mail/Index.php
@@ -1,9 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use PHPUnit\Framework\Attributes\Group;
+use Roundcube\Tests\ActionTestCase;
+
+use function Roundcube\Tests\setProperty;
+
 /**
  * Test class to test rcmail_action_mail_index
- *
- * @package Tests
  */
 class Actions_Mail_Index extends ActionTestCase
 {
@@ -12,16 +17,16 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_run_http()
     {
-        $action = new rcmail_action_mail_index;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $action = new \rcmail_action_mail_index();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $_GET = ['_uid' => 10];
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('set_options')
             ->registerFunction('get_pagesize', 10)
             ->registerFunction('set_charset')
@@ -57,13 +62,13 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_run_ajax()
     {
-        $action = new rcmail_action_mail_index;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'list');
+        $action = new \rcmail_action_mail_index();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'list');
 
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('set_options')
             ->registerFunction('get_pagesize')
             ->registerFunction('set_charset')
@@ -98,8 +103,8 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_message_list_smart_column_name()
     {
-        $action = new rcmail_action_mail_index;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'list');
+        $action = new \rcmail_action_mail_index();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'list');
 
         $output->set_env('mailbox', 'INBOX');
         $this->assertSame('from', $action->message_list_smart_column_name());
@@ -122,10 +127,10 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_message_list()
     {
-        $action = new rcmail_action_mail_index;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'mail', 'list');
+        $action = new \rcmail_action_mail_index();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', 'list');
 
-        rcmail::get_instance()->storage->registerFunction('get_folder', 'INBOX');
+        \rcmail::get_instance()->storage->registerFunction('get_folder', 'INBOX');
 
         $result = $action->message_list([]);
 
@@ -139,10 +144,10 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_js_message_list()
     {
-        $action = new rcmail_action_mail_index;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'list');
+        $action = new \rcmail_action_mail_index();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'list');
 
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('get_search_set', null)
             ->registerFunction('get_threading', true)
             ->registerFunction('get_folder', 'INBOX')
@@ -161,8 +166,8 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_options_menu_link()
     {
-        $action = new rcmail_action_mail_index;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $action = new \rcmail_action_mail_index();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $link = $action->options_menu_link(['icon' => 'ico.png']);
 
@@ -217,7 +222,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_address_string()
     {
-        $action = new rcmail_action_mail_index;
+        $action = new \rcmail_action_mail_index();
 
         $this->assertSame(null, $action->address_string(''));
 
@@ -247,8 +252,8 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_attachment_name()
     {
-        $action = new rcmail_action_mail_index;
-        $part = new rcube_message_part();
+        $action = new \rcmail_action_mail_index();
+        $part = new \rcube_message_part();
         $part->mime_id = 1;
 
         $part->mimetype = 'text/html';
@@ -298,7 +303,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     protected function get_html_part($body = null)
     {
-        $part = new rcube_message_part;
+        $part = new \rcube_message_part();
         $part->ctype_primary   = 'text';
         $part->ctype_secondary = 'html';
         $part->body = $body ? file_get_contents(TESTS_DIR . $body) : null;
@@ -312,9 +317,9 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_index;
+        $object = new \rcmail_action_mail_index();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 
     /**
@@ -322,7 +327,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_html()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $part = $this->get_html_part('src/htmlbody.txt');
         $part->replaces = ['ex1.jpg' => 'part_1.2.jpg', 'ex2.jpg' => 'part_1.2.jpg'];
@@ -358,7 +363,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_html_xss()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $part   = $this->get_html_part('src/htmlxss.txt');
         $params = ['container_id' => 'foo', 'safe' => true];
@@ -377,7 +382,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_html_xss2()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $part   = $this->get_html_part('src/BID-26800.txt');
         $params = ['container_id' => 'dabody', 'safe' => true];
@@ -392,12 +397,12 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_html_xss3()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         // #1488850
         $html = '<p><a href="data:text/html,&lt;script&gt;alert(document.cookie)&lt;/script&gt;">Firefox</a>'
             .'<a href="vbscript:alert(document.cookie)">Internet Explorer</a></p>';
-        $washed = rcmail_action_mail_index::wash_html($html, ['safe' => true], []);
+        $washed = \rcmail_action_mail_index::wash_html($html, ['safe' => true], []);
 
         $this->assertDoesNotMatchRegularExpression('/data:text/', $washed, "Remove data:text/html links");
         $this->assertDoesNotMatchRegularExpression('/vbscript:/', $washed, "Remove vbscript: links");
@@ -458,12 +463,13 @@ class Actions_Mail_Index extends ActionTestCase
      * Test washtml class on non-unicode characters (#1487813)
      * @group mbstring
      */
+    #[Group('mbstring')]
     function test_washtml_utf8()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $part   = $this->get_html_part('src/invalidchars.html');
-        $washed = rcmail_action_mail_index::print_body($part->body, $part);
+        $washed = \rcmail_action_mail_index::print_body($part->body, $part);
 
         $this->assertMatchesRegularExpression('/<p>(символ|симол)<\/p>/', $washed, "Remove non-unicode characters from HTML message body");
     }
@@ -473,7 +479,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_meta_insertion()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $meta = '<meta charset="'.RCUBE_CHARSET.'" />';
         $args = [
@@ -483,27 +489,27 @@ class Actions_Mail_Index extends ActionTestCase
         ];
 
         $body   = '<html><head><meta charset="iso-8859-1_X"></head><body>Test1<br>Test2';
-        $washed = rcmail_action_mail_index::wash_html($body, $args);
+        $washed = \rcmail_action_mail_index::wash_html($body, $args);
         $this->assertStringContainsString("<html><head>$meta</head><body>Test1", $washed, "Meta tag insertion (1)");
 
         $body   = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /></head><body>Test1<br>Test2';
-        $washed = rcmail_action_mail_index::wash_html($body, $args);
+        $washed = \rcmail_action_mail_index::wash_html($body, $args);
         $this->assertStringContainsString("<html><head>$meta</head><body>Test1", $washed, "Meta tag insertion (2)");
 
         $body   = 'Test1<br>Test2';
-        $washed = rcmail_action_mail_index::wash_html($body, $args);
+        $washed = \rcmail_action_mail_index::wash_html($body, $args);
         $this->assertTrue(strpos($washed, "<html><head>$meta</head>") === 0, "Meta tag insertion (3)");
 
         $body   = '<html>Test1<br>Test2';
-        $washed = rcmail_action_mail_index::wash_html($body, $args);
+        $washed = \rcmail_action_mail_index::wash_html($body, $args);
         $this->assertTrue(strpos($washed, "<html><head>$meta</head>") === 0, "Meta tag insertion (4)");
 
         $body   = '<html><head></head>Test1<br>Test2';
-        $washed = rcmail_action_mail_index::wash_html($body, $args);
+        $washed = \rcmail_action_mail_index::wash_html($body, $args);
         $this->assertTrue(strpos($washed, "<html><head>$meta</head>") === 0, "Meta tag insertion (5)");
 
         $body   = '<html><head></head><body>Test1<br>Test2<meta charset="utf-8"></body>';
-        $washed = rcmail_action_mail_index::wash_html($body, $args);
+        $washed = \rcmail_action_mail_index::wash_html($body, $args);
         $this->assertTrue(strpos($washed, "<html><head>$meta</head>") === 0, "Meta tag insertion (6)");
         $this->assertTrue(strpos($washed, "Test2</body>") > 0, "Meta tag insertion (7)");
     }
@@ -513,13 +519,13 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_plaintext()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
-        $part = new rcube_message_part;
+        $part = new \rcube_message_part();
         $part->ctype_primary   = 'text';
         $part->ctype_secondary = 'plain';
         $part->body = quoted_printable_decode(file_get_contents(TESTS_DIR . 'src/plainbody.txt'));
-        $html = rcmail_action_mail_index::print_body($part->body, $part, ['safe' => true]);
+        $html = \rcmail_action_mail_index::print_body($part->body, $part, ['safe' => true]);
 
         $this->assertMatchesRegularExpression(
             '/<a href="mailto:nobody@roundcube.net" onclick="return rcmail.command\(\'compose\',\'nobody@roundcube.net\',this\)">nobody@roundcube.net<\/a>/',
@@ -543,7 +549,7 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_mailto()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $part   = $this->get_html_part('src/mailto.txt');
         $params = ['container_id' => 'foo', 'safe' => false];
@@ -562,10 +568,10 @@ class Actions_Mail_Index extends ActionTestCase
      */
     function test_html_comments()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $part = $this->get_html_part('src/htmlcom.txt');
-        $washed = rcmail_action_mail_index::print_body($part->body, $part, ['safe' => true]);
+        $washed = \rcmail_action_mail_index::print_body($part->body, $part, ['safe' => true]);
 
         // #1487759
         $this->assertMatchesRegularExpression('|<p>test1</p>|', $washed, "Buggy HTML comments");
@@ -578,17 +584,17 @@ class Actions_Mail_Index extends ActionTestCase
      */
     public function test_html_links()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         // disable relative links
         $html = '<a href="/">test</a>';
-        $body = rcmail_action_mail_index::print_body($html, $this->get_html_part(), ['safe' => false, 'plain' => false]);
+        $body = \rcmail_action_mail_index::print_body($html, $this->get_html_part(), ['safe' => false, 'plain' => false]);
 
         $this->assertStringNotContainsString('href="/"', $body);
         $this->assertStringContainsString('<a>', $body);
 
         $html = '<a href="https://roundcube.net">test</a>';
-        $body = rcmail_action_mail_index::print_body($html, $this->get_html_part(), ['safe' => false, 'plain' => false]);
+        $body = \rcmail_action_mail_index::print_body($html, $this->get_html_part(), ['safe' => false, 'plain' => false]);
 
         // allow external links, add target and noreferrer
         $this->assertStringContainsString('<a href="https://roundcube.net"', $body);
@@ -601,10 +607,10 @@ class Actions_Mail_Index extends ActionTestCase
      */
     public function test_html_link_xss()
     {
-        $this->initOutput(rcmail_action::MODE_HTTP, 'mail', '');
+        $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', '');
 
         $html = '<a style="x:><img src=x onerror=alert(1)//">test</a>';
-        $body = rcmail_action_mail_index::print_body($html, $this->get_html_part(), ['safe' => false, 'plain' => false]);
+        $body = \rcmail_action_mail_index::print_body($html, $this->get_html_part(), ['safe' => false, 'plain' => false]);
 
         $this->assertStringNotContainsString('onerror=alert(1)//">test', $body);
         $this->assertStringContainsString('<a style="x: &gt;"', $body);
diff --git a/tests/Actions/Mail/List.php b/tests/Actions/Mail/List.php
index eb02386..ce72bc2 100644
--- a/tests/Actions/Mail/List.php
+++ b/tests/Actions/Mail/List.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_list
- *
- * @package Tests
  */
 class Actions_Mail_List extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_List extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_list;
+        $object = new \rcmail_action_mail_list();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/ListContacts.php b/tests/Actions/Mail/ListContacts.php
index 3461279..2dc2441 100644
--- a/tests/Actions/Mail/ListContacts.php
+++ b/tests/Actions/Mail/ListContacts.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_list_contacts
- *
- * @package Tests
  */
 class Actions_Mail_ListContacts extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_ListContacts extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_list_contacts;
+        $object = new \rcmail_action_mail_list_contacts();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Mark.php b/tests/Actions/Mail/Mark.php
index ba44ca3..3c155b2 100644
--- a/tests/Actions/Mail/Mark.php
+++ b/tests/Actions/Mail/Mark.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_mark
- *
- * @package Tests
  */
 class Actions_Mail_Mark extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Mark extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_mark;
+        $object = new \rcmail_action_mail_mark();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Move.php b/tests/Actions/Mail/Move.php
index 899e2a4..ae3323f 100644
--- a/tests/Actions/Mail/Move.php
+++ b/tests/Actions/Mail/Move.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_move
- *
- * @package Tests
  */
 class Actions_Mail_Move extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Move extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_move;
+        $object = new \rcmail_action_mail_move();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Pagenav.php b/tests/Actions/Mail/Pagenav.php
index 617c9ad..d422845 100644
--- a/tests/Actions/Mail/Pagenav.php
+++ b/tests/Actions/Mail/Pagenav.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_pagenav
- *
- * @package Tests
  */
 class Actions_Mail_Pagenav extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Pagenav extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_pagenav;
+        $object = new \rcmail_action_mail_pagenav();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Search.php b/tests/Actions/Mail/Search.php
index b67a31a..b024424 100644
--- a/tests/Actions/Mail/Search.php
+++ b/tests/Actions/Mail/Search.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_mail_search
- *
- * @package Tests
  */
 class Actions_Mail_Search extends ActionTestCase
 {
@@ -12,8 +16,8 @@ class Actions_Mail_Search extends ActionTestCase
      */
     function test_search_empty_result()
     {
-        $action = new rcmail_action_mail_search;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'search');
+        $action = new \rcmail_action_mail_search();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'search');
 
         $this->assertTrue($action->checks());
 
@@ -24,10 +28,10 @@ class Actions_Mail_Search extends ActionTestCase
 
         // Set expected storage function calls/results
         self::initStorage();
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('set_page')
             ->registerFunction('set_search_set')
-            ->registerFunction('search', new rcube_result_index())
+            ->registerFunction('search', new \rcube_result_index())
             ->registerFunction('get_search_set', [])
             ->registerFunction('get_search_set', [])
             ->registerFunction('get_pagesize', 10)
@@ -58,15 +62,15 @@ class Actions_Mail_Search extends ActionTestCase
      */
     function test_search_non_empty_result()
     {
-        $action = new rcmail_action_mail_search;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'search');
+        $action = new \rcmail_action_mail_search();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'search');
 
         $_GET = [
             '_q'    => 'test',
             '_mbox' => 'INBOX',
         ];
 
-        $index = new rcube_result_index('INBOX', 'SEARCH 10');
+        $index = new \rcube_result_index('INBOX', 'SEARCH 10');
 
         // Set expected storage function calls/results
         self::initStorage()
@@ -79,7 +83,7 @@ class Actions_Mail_Search extends ActionTestCase
             ->registerFunction('get_pagesize', 10)
             ->registerFunction('get_folder', 'INBOX')
             ->registerFunction('list_messages', [
-                10 => rcube_message_header::from_array([
+                10 => \rcube_message_header::from_array([
                     'id' => 42,
                     'uid' => 10,
                     'subject' => 'test message',
@@ -118,37 +122,37 @@ class Actions_Mail_Search extends ActionTestCase
      */
     function test_search_input()
     {
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'search');
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'search');
 
-        $result = rcmail_action_mail_search::search_input('', 'subject,from', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('', 'subject,from', 'base', 'INBOX');
         $this->assertSame([], $result[0]);
         $this->assertSame('', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('test', 'subject,from', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('test', 'subject,from', 'base', 'INBOX');
         $this->assertSame(['subject' => 'HEADER SUBJECT', 'from' => 'HEADER FROM'], $result[0]);
         $this->assertSame('test', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('test', null, 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('test', null, 'base', 'INBOX');
         $this->assertSame(['subject' => 'HEADER SUBJECT'], $result[0]);
         $this->assertSame('test', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('body:test', 'subject,from', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('body:test', 'subject,from', 'base', 'INBOX');
         $this->assertSame(['body' => 'BODY'], $result[0]);
         $this->assertSame('test', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('to:test', '', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('to:test', '', 'base', 'INBOX');
         $this->assertSame(['to' => 'HEADER TO'], $result[0]);
         $this->assertSame('test', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('reply-to:test', '', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('reply-to:test', '', 'base', 'INBOX');
         $this->assertSame(['reply-to' => 'HEADER REPLY-TO'], $result[0]);
         $this->assertSame('test', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('test', 'from,invalid entry', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('test', 'from,invalid entry', 'base', 'INBOX');
         $this->assertSame(['from' => 'HEADER FROM'], $result[0]);
         $this->assertSame('test', $result[1]);
 
-        $result = rcmail_action_mail_search::search_input('test', 'replyto', 'base', 'INBOX');
+        $result = \rcmail_action_mail_search::search_input('test', 'replyto', 'base', 'INBOX');
         $this->assertSame(['reply-to' => 'HEADER REPLY-TO', 'mail-reply-to' => 'HEADER MAIL-REPLY-TO'], $result[0]);
         $this->assertSame('test', $result[1]);
     }
@@ -156,20 +160,20 @@ class Actions_Mail_Search extends ActionTestCase
     /**
      * Test data for test_search_interval_criteria()
      */
-    function data_search_interval_criteria()
+    static function data_search_interval_criteria()
     {
-        $week  = new DateInterval('P1W');
-        $month = new DateInterval('P1M');
-        $year  = new DateInterval('P1Y');
+        $week  = new \DateInterval('P1W');
+        $month = new \DateInterval('P1M');
+        $year  = new \DateInterval('P1Y');
 
         return [
             ['', null],
-            ['1W', 'SINCE ' . (new DateTime('now'))->sub($week)->format('j-M-Y')],
-            ['1M', 'SINCE ' . (new DateTime('now'))->sub($month)->format('j-M-Y')],
-            ['1Y', 'SINCE ' . (new DateTime('now'))->sub($year)->format('j-M-Y')],
-            ['-1W', 'BEFORE ' . (new DateTime('now'))->sub($week)->format('j-M-Y')],
-            ['-1M', 'BEFORE ' . (new DateTime('now'))->sub($month)->format('j-M-Y')],
-            ['-1Y', 'BEFORE ' . (new DateTime('now'))->sub($year)->format('j-M-Y')],
+            ['1W', 'SINCE ' . (new \DateTime('now'))->sub($week)->format('j-M-Y')],
+            ['1M', 'SINCE ' . (new \DateTime('now'))->sub($month)->format('j-M-Y')],
+            ['1Y', 'SINCE ' . (new \DateTime('now'))->sub($year)->format('j-M-Y')],
+            ['-1W', 'BEFORE ' . (new \DateTime('now'))->sub($week)->format('j-M-Y')],
+            ['-1M', 'BEFORE ' . (new \DateTime('now'))->sub($month)->format('j-M-Y')],
+            ['-1Y', 'BEFORE ' . (new \DateTime('now'))->sub($year)->format('j-M-Y')],
         ];
     }
 
@@ -178,9 +182,10 @@ class Actions_Mail_Search extends ActionTestCase
      *
      * @dataProvider data_search_interval_criteria
      */
+    #[DataProvider('data_search_interval_criteria')]
     function test_search_interval_criteria($input, $output)
     {
-        $result = rcmail_action_mail_search::search_interval_criteria($input);
+        $result = \rcmail_action_mail_search::search_interval_criteria($input);
         $this->assertSame($output, $result);
     }
 }
diff --git a/tests/Actions/Mail/SearchContacts.php b/tests/Actions/Mail/SearchContacts.php
index 8a20b4a..7a0dcc1 100644
--- a/tests/Actions/Mail/SearchContacts.php
+++ b/tests/Actions/Mail/SearchContacts.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_search_contacts
- *
- * @package Tests
  */
 class Actions_Mail_SearchContacts extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_SearchContacts extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_search_contacts;
+        $object = new \rcmail_action_mail_search_contacts();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Send.php b/tests/Actions/Mail/Send.php
index 6fd71e9..469c957 100644
--- a/tests/Actions/Mail/Send.php
+++ b/tests/Actions/Mail/Send.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_send
- *
- * @package Tests
  */
 class Actions_Mail_Send extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Send extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_send;
+        $object = new \rcmail_action_mail_send();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Sendmdn.php b/tests/Actions/Mail/Sendmdn.php
index 8626422..c3fabda 100644
--- a/tests/Actions/Mail/Sendmdn.php
+++ b/tests/Actions/Mail/Sendmdn.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_sendmdn
- *
- * @package Tests
  */
 class Actions_Mail_Sendmdn extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Sendmdn extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_sendmdn;
+        $object = new \rcmail_action_mail_sendmdn();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Show.php b/tests/Actions/Mail/Show.php
index dea3d1d..9f286fb 100644
--- a/tests/Actions/Mail/Show.php
+++ b/tests/Actions/Mail/Show.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_show
- *
- * @package Tests
  */
 class Actions_Mail_Show extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Show extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_show;
+        $object = new \rcmail_action_mail_show();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Mail/Viewsource.php b/tests/Actions/Mail/Viewsource.php
index 07c30d5..f56e825 100644
--- a/tests/Actions/Mail/Viewsource.php
+++ b/tests/Actions/Mail/Viewsource.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Mail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_mail_viewsource
- *
- * @package Tests
  */
 class Actions_Mail_Viewsource extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Mail_Viewsource extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_mail_viewsource;
+        $object = new \rcmail_action_mail_viewsource();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Settings/About.php b/tests/Actions/Settings/About.php
index 1b9d6a8..c20b424 100644
--- a/tests/Actions/Settings/About.php
+++ b/tests/Actions/Settings/About.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_about
- *
- * @package Tests
  */
 class Actions_Settings_About extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Settings_About extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_about;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'about');
+        $action = new \rcmail_action_settings_about();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'about');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $this->runAndAssert($action, OutputHtmlMock::E_EXIT);
diff --git a/tests/Actions/Settings/FolderCreate.php b/tests/Actions/Settings/FolderCreate.php
index 8cacffc..b7c3813 100644
--- a/tests/Actions/Settings/FolderCreate.php
+++ b/tests/Actions/Settings/FolderCreate.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_create
- *
- * @package Tests
  */
 class Actions_Settings_FolderCreate extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderCreate extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_folder_create;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'folder-create');
+        $action = new \rcmail_action_settings_folder_create();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'folder-create');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('get_capability', true)
             ->registerFunction('get_capability', true)
             ->registerFunction('folder_info', [
diff --git a/tests/Actions/Settings/FolderDelete.php b/tests/Actions/Settings/FolderDelete.php
index 1954341..8d08812 100644
--- a/tests/Actions/Settings/FolderDelete.php
+++ b/tests/Actions/Settings/FolderDelete.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_delete
- *
- * @package Tests
  */
 class Actions_Settings_FolderDelete extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderDelete extends ActionTestCase
      */
     function test_delete()
     {
-        $action = new rcmail_action_settings_folder_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-delete');
+        $action = new \rcmail_action_settings_folder_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-delete');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('delete_folder', true)
             ->registerFunction('get_quota', false);
 
@@ -42,14 +45,14 @@ class Actions_Settings_FolderDelete extends ActionTestCase
      */
     function test_delete_errors()
     {
-        $action = new rcmail_action_settings_folder_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-delete');
+        $action = new \rcmail_action_settings_folder_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-delete');
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('delete_folder', false)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY);
+            ->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $_POST = ['_mbox' => 'Test'];
 
diff --git a/tests/Actions/Settings/FolderEdit.php b/tests/Actions/Settings/FolderEdit.php
index 5be3778..df95e63 100644
--- a/tests/Actions/Settings/FolderEdit.php
+++ b/tests/Actions/Settings/FolderEdit.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_edit
- *
- * @package Tests
  */
 class Actions_Settings_FolderEdit extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderEdit extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_folder_edit;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'folder-edit');
+        $action = new \rcmail_action_settings_folder_edit();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'folder-edit');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('get_capability', true)
             ->registerFunction('get_capability', true)
             ->registerFunction('folder_info', [
diff --git a/tests/Actions/Settings/FolderPurge.php b/tests/Actions/Settings/FolderPurge.php
index 28389bf..43cb81f 100644
--- a/tests/Actions/Settings/FolderPurge.php
+++ b/tests/Actions/Settings/FolderPurge.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_purge
- *
- * @package Tests
  */
 class Actions_Settings_FolderPurge extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderPurge extends ActionTestCase
      */
     function test_purge()
     {
-        $action = new rcmail_action_settings_folder_purge;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-purge');
+        $action = new \rcmail_action_settings_folder_purge();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-purge');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('move_message', true)
             ->registerFunction('get_quota', false);
 
@@ -42,14 +45,14 @@ class Actions_Settings_FolderPurge extends ActionTestCase
      */
     function test_purge_trash()
     {
-        $action = new rcmail_action_settings_folder_purge;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-purge');
+        $action = new \rcmail_action_settings_folder_purge();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-purge');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('delete_message', true)
             ->registerFunction('get_quota', false);
 
@@ -72,14 +75,14 @@ class Actions_Settings_FolderPurge extends ActionTestCase
      */
     function test_purge_errors()
     {
-        $action = new rcmail_action_settings_folder_purge;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-purge');
+        $action = new \rcmail_action_settings_folder_purge();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-purge');
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('move_message', false)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY);
+            ->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $_POST = ['_mbox' => 'Test'];
 
diff --git a/tests/Actions/Settings/FolderRename.php b/tests/Actions/Settings/FolderRename.php
index 8dbe80f..478f52f 100644
--- a/tests/Actions/Settings/FolderRename.php
+++ b/tests/Actions/Settings/FolderRename.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_rename
- *
- * @package Tests
  */
 class Actions_Settings_FolderRename extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderRename extends ActionTestCase
      */
     function test_rename()
     {
-        $action = new rcmail_action_settings_folder_rename;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-rename');
+        $action = new \rcmail_action_settings_folder_rename();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-rename');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('rename_folder', true)
             ->registerFunction('folder_info', [])
             ->registerFunction('mod_folder', 'Test2');
@@ -40,14 +43,14 @@ class Actions_Settings_FolderRename extends ActionTestCase
      */
     function test_rename_errors()
     {
-        $action = new rcmail_action_settings_folder_rename;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-rename');
+        $action = new \rcmail_action_settings_folder_rename();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-rename');
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('rename_folder', false)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY);
+            ->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $_POST = ['_folder_oldname' => 'Test', '_folder_newname' => 'Test2'];
 
diff --git a/tests/Actions/Settings/FolderSave.php b/tests/Actions/Settings/FolderSave.php
index 967531f..858542d 100644
--- a/tests/Actions/Settings/FolderSave.php
+++ b/tests/Actions/Settings/FolderSave.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_save
- *
- * @package Tests
  */
 class Actions_Settings_FolderSave extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderSave extends ActionTestCase
      */
     function test_new_folder()
     {
-        $action = new rcmail_action_settings_folder_save;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'folder-save');
+        $action = new \rcmail_action_settings_folder_save();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'folder-save');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('get_capability', true)
             ->registerFunction('get_capability', true)
             ->registerFunction('folder_validate', true)
diff --git a/tests/Actions/Settings/FolderSize.php b/tests/Actions/Settings/FolderSize.php
index 13ac69e..6af29ad 100644
--- a/tests/Actions/Settings/FolderSize.php
+++ b/tests/Actions/Settings/FolderSize.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_size
- *
- * @package Tests
  */
 class Actions_Settings_FolderSize extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderSize extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_folder_size;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-size');
+        $action = new \rcmail_action_settings_folder_size();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-size');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('folder_size', 100);
 
         $_POST = ['_mbox' => 'Test'];
@@ -38,14 +41,14 @@ class Actions_Settings_FolderSize extends ActionTestCase
      */
     function test_run_errors()
     {
-        $action = new rcmail_action_settings_folder_size;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-size');
+        $action = new \rcmail_action_settings_folder_size();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-size');
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('folder_size', false)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY);
+            ->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $_POST = ['_mbox' => 'Test'];
 
diff --git a/tests/Actions/Settings/FolderSubscribe.php b/tests/Actions/Settings/FolderSubscribe.php
index ceae6c9..6e17c04 100644
--- a/tests/Actions/Settings/FolderSubscribe.php
+++ b/tests/Actions/Settings/FolderSubscribe.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_subscribe
- *
- * @package Tests
  */
 class Actions_Settings_FolderSubscribe extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderSubscribe extends ActionTestCase
      */
     function test_subscribe()
     {
-        $action = new rcmail_action_settings_folder_subscribe;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-subscribe');
+        $action = new \rcmail_action_settings_folder_subscribe();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-subscribe');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('subscribe', true)
             ->registerFunction('is_special_folder', false);
 
@@ -41,16 +44,16 @@ class Actions_Settings_FolderSubscribe extends ActionTestCase
      */
     function test_subscribe_errors()
     {
-        $action = new rcmail_action_settings_folder_subscribe;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-subscribe');
+        $action = new \rcmail_action_settings_folder_subscribe();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-subscribe');
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('subscribe', false)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY)
+            ->registerFunction('get_response_code', \rcube_storage::READONLY)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY);
+            ->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $_POST = ['_mbox' => 'Test'];
 
diff --git a/tests/Actions/Settings/FolderUnsubscribe.php b/tests/Actions/Settings/FolderUnsubscribe.php
index 58949ad..4f4aea8 100644
--- a/tests/Actions/Settings/FolderUnsubscribe.php
+++ b/tests/Actions/Settings/FolderUnsubscribe.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_folder_unsubscribe
- *
- * @package Tests
  */
 class Actions_Settings_FolderUnsubscribe extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_FolderUnsubscribe extends ActionTestCase
      */
     function test_unsubscribe()
     {
-        $action = new rcmail_action_settings_folder_unsubscribe;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-unsubscribe');
+        $action = new \rcmail_action_settings_folder_unsubscribe();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-unsubscribe');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('unsubscribe', true)
             ->registerFunction('is_special_folder', false);
 
@@ -39,14 +42,14 @@ class Actions_Settings_FolderUnsubscribe extends ActionTestCase
      */
     function test_unsubscribe_errors()
     {
-        $action = new rcmail_action_settings_folder_unsubscribe;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'folder-unsubscribe');
+        $action = new \rcmail_action_settings_folder_unsubscribe();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'folder-unsubscribe');
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('unsubscribe', false)
             ->registerFunction('get_error_code', -1)
-            ->registerFunction('get_response_code', rcube_storage::READONLY);
+            ->registerFunction('get_response_code', \rcube_storage::READONLY);
 
         $_POST = ['_mbox' => 'Test'];
 
diff --git a/tests/Actions/Settings/Folders.php b/tests/Actions/Settings/Folders.php
index a3358ce..bfc904b 100644
--- a/tests/Actions/Settings/Folders.php
+++ b/tests/Actions/Settings/Folders.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_folders
- *
- * @package Tests
  */
 class Actions_Settings_Folders extends ActionTestCase
 {
@@ -12,14 +15,14 @@ class Actions_Settings_Folders extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_folders;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'folders');
+        $action = new \rcmail_action_settings_folders();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'folders');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Set expected storage function calls/results
-        rcmail::get_instance()->storage
+        \rcmail::get_instance()->storage
             ->registerFunction('clear_cache', true)
             ->registerFunction('get_capability', true)
             ->registerFunction('get_capability', true)
diff --git a/tests/Actions/Settings/Identities.php b/tests/Actions/Settings/Identities.php
index 22b290d..ed8bcbd 100644
--- a/tests/Actions/Settings/Identities.php
+++ b/tests/Actions/Settings/Identities.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_identities
- *
- * @package Tests
  */
 class Actions_Settings_Identities extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Settings_Identities extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_identities;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'identities');
+        $action = new \rcmail_action_settings_identities();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'identities');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('identities');
@@ -36,8 +39,8 @@ class Actions_Settings_Identities extends ActionTestCase
      */
     function test_identities_list()
     {
-        $action = new rcmail_action_settings_identities;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'identities');
+        $action = new \rcmail_action_settings_identities();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'identities');
 
         self::initDB('identities');
 
diff --git a/tests/Actions/Settings/IdentityCreate.php b/tests/Actions/Settings/IdentityCreate.php
index 812d371..3a59dbf 100644
--- a/tests/Actions/Settings/IdentityCreate.php
+++ b/tests/Actions/Settings/IdentityCreate.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_identity_create
- *
- * @package Tests
  */
 class Actions_Settings_IdentityCreate extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Settings_IdentityCreate extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_identity_create;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'add-identity');
+        $action = new \rcmail_action_settings_identity_create();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'add-identity');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $this->runAndAssert($action, OutputHtmlMock::E_EXIT);
diff --git a/tests/Actions/Settings/IdentityDelete.php b/tests/Actions/Settings/IdentityDelete.php
index 5fec768..6150d83 100644
--- a/tests/Actions/Settings/IdentityDelete.php
+++ b/tests/Actions/Settings/IdentityDelete.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_identity_delete
- *
- * @package Tests
  */
 class Actions_Settings_IdentityDelete extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Settings_IdentityDelete extends ActionTestCase
      */
     function test_delete_identity()
     {
-        $action = new rcmail_action_settings_identity_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'delete-identity');
+        $action = new \rcmail_action_settings_identity_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'delete-identity');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('identities');
 
-        $db     = rcmail::get_instance()->get_dbh();
+        $db     = \rcmail::get_instance()->get_dbh();
         $query  = $db->query('SELECT * FROM `identities` WHERE `email` = ?', 'test@example.org');
         $result = $db->fetch_assoc($query);
         $iid    = $result['identity_id'];
@@ -42,8 +45,8 @@ class Actions_Settings_IdentityDelete extends ActionTestCase
         $this->assertTrue(!empty($result['del']));
 
         // Test error handling
-        $action = new rcmail_action_settings_identity_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'delete-identity');
+        $action = new \rcmail_action_settings_identity_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'delete-identity');
 
         $_POST = ['_iid' => 'unknown'];
 
diff --git a/tests/Actions/Settings/IdentityEdit.php b/tests/Actions/Settings/IdentityEdit.php
index aca0e8d..4e52964 100644
--- a/tests/Actions/Settings/IdentityEdit.php
+++ b/tests/Actions/Settings/IdentityEdit.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_identity_edit
- *
- * @package Tests
  */
 class Actions_Settings_IdentityEdit extends ActionTestCase
 {
@@ -12,15 +15,15 @@ class Actions_Settings_IdentityEdit extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_identity_edit;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'edit-identity');
+        $action = new \rcmail_action_settings_identity_edit();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'edit-identity');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('identities');
 
-        $db       = rcmail::get_instance()->get_dbh();
+        $db       = \rcmail::get_instance()->get_dbh();
         $query    = $db->query('SELECT * FROM `identities` WHERE `standard` = 1 LIMIT 1');
         $identity = $db->fetch_assoc($query);
 
@@ -45,8 +48,8 @@ class Actions_Settings_IdentityEdit extends ActionTestCase
      */
     function test_identity_form()
     {
-        $action = new rcmail_action_settings_identity_edit;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'edit-identity');
+        $action = new \rcmail_action_settings_identity_edit();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'edit-identity');
 
         self::initDB('identities');
 
diff --git a/tests/Actions/Settings/IdentitySave.php b/tests/Actions/Settings/IdentitySave.php
index cc084c1..cbd9b7c 100644
--- a/tests/Actions/Settings/IdentitySave.php
+++ b/tests/Actions/Settings/IdentitySave.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_settings_identity_save
- *
- * @package Tests
  */
 class Actions_Settings_IdentitySave extends ActionTestCase
 {
@@ -12,15 +14,15 @@ class Actions_Settings_IdentitySave extends ActionTestCase
      */
     function test_identity_edit()
     {
-        $action = new rcmail_action_settings_identity_save;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'save-identity');
+        $action = new \rcmail_action_settings_identity_save();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'save-identity');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('identities');
 
-        $db       = rcmail::get_instance()->get_dbh();
+        $db       = \rcmail::get_instance()->get_dbh();
         $query    = $db->query('SELECT * FROM `identities` WHERE `standard` = 1 LIMIT 1');
         $identity = $db->fetch_assoc($query);
 
@@ -36,7 +38,7 @@ class Actions_Settings_IdentitySave extends ActionTestCase
 
         $action->run();
 
-        $this->assertSame('edit-identity', rcmail::get_instance()->action);
+        $this->assertSame('edit-identity', \rcmail::get_instance()->action);
         $this->assertSame('successfullysaved', $output->getProperty('message'));
 
         $query    = $db->query('SELECT * FROM `identities` WHERE `identity_id` = ?', $identity['identity_id']);
diff --git a/tests/Actions/Settings/Index.php b/tests/Actions/Settings/Index.php
index d777a38..1933e77 100644
--- a/tests/Actions/Settings/Index.php
+++ b/tests/Actions/Settings/Index.php
@@ -1,9 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
+use function Roundcube\Tests\getHTMLNodes;
+
 /**
  * Test class to test rcmail_action_settings_index
- *
- * @package Tests
  */
 class Actions_Settings_Index extends ActionTestCase
 {
@@ -12,10 +17,10 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_index;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'preferences');
+        $action = new \rcmail_action_settings_index();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'preferences');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $action->run();
@@ -30,7 +35,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_sections_list()
     {
-        $result = rcmail_action_settings_index::sections_list([]);
+        $result = \rcmail_action_settings_index::sections_list([]);
         $this->assertTrue(strpos($result, '<table id="rcmsectionslist">') === 0);
     }
 
@@ -39,7 +44,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_user_prefs()
     {
-        $result = rcmail_action_settings_index::user_prefs('general');
+        $result = \rcmail_action_settings_index::user_prefs('general');
         $this->assertSame('general', $result[0]['general']['id']);
     }
 
@@ -48,7 +53,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_get_skins()
     {
-        $result = rcmail_action_settings_index::get_skins();
+        $result = \rcmail_action_settings_index::get_skins();
         $this->assertContains('elastic', $result);
     }
 
@@ -57,7 +62,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_settings_tabs()
     {
-        $result = rcmail_action_settings_index::settings_tabs([]);
+        $result = \rcmail_action_settings_index::settings_tabs([]);
         $nodes  = getHTMLNodes($result, "//span[@id='settingstabpreferences']");
 
         $this->assertCount(1, $nodes);
@@ -74,7 +79,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_timezone_label()
     {
-        $result = rcmail_action_settings_index::timezone_label('Europe/Warsaw');
+        $result = \rcmail_action_settings_index::timezone_label('Europe/Warsaw');
         $this->assertSame('Europe/Warsaw', $result);
     }
 
@@ -83,7 +88,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_timezone_standard_time_data()
     {
-        $result = rcmail_action_settings_index::timezone_standard_time_data('UTC');
+        $result = \rcmail_action_settings_index::timezone_standard_time_data('UTC');
         $this->assertSame('+00:00', $result['offset']);
     }
 
@@ -92,7 +97,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_attach_images()
     {
-        $result = rcmail_action_settings_index::attach_images('<p>test</p>', 'identity');
+        $result = \rcmail_action_settings_index::attach_images('<p>test</p>', 'identity');
 
         // TODO: test image replacement
 
@@ -104,7 +109,7 @@ class Actions_Settings_Index extends ActionTestCase
      */
     function test_wash_html()
     {
-        $result = rcmail_action_settings_index::wash_html('<p>test</p>');
+        $result = \rcmail_action_settings_index::wash_html('<p>test</p>');
 
         $this->assertSame('<p>test</p>', $result);
     }
diff --git a/tests/Actions/Settings/PrefsEdit.php b/tests/Actions/Settings/PrefsEdit.php
index a40a273..7f64bb8 100644
--- a/tests/Actions/Settings/PrefsEdit.php
+++ b/tests/Actions/Settings/PrefsEdit.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_prefs_edit
- *
- * @package Tests
  */
 class Actions_Settings_PrefsEdit extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Settings_PrefsEdit extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_prefs_edit;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'edit-prefs');
+        $action = new \rcmail_action_settings_prefs_edit();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'edit-prefs');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $_GET['_section'] = 'general';
diff --git a/tests/Actions/Settings/PrefsSave.php b/tests/Actions/Settings/PrefsSave.php
index 1c71173..eb91106 100644
--- a/tests/Actions/Settings/PrefsSave.php
+++ b/tests/Actions/Settings/PrefsSave.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_settings_prefs_save
- *
- * @package Tests
  */
 class Actions_Settings_PrefsSave extends ActionTestCase
 {
@@ -12,10 +14,10 @@ class Actions_Settings_PrefsSave extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_prefs_save;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'save-prefs');
+        $action = new \rcmail_action_settings_prefs_save();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'save-prefs');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // TODO: Test all sections
@@ -23,7 +25,7 @@ class Actions_Settings_PrefsSave extends ActionTestCase
 
         $action->run();
 
-        $this->assertSame('edit-prefs', rcmail::get_instance()->action);
+        $this->assertSame('edit-prefs', \rcmail::get_instance()->action);
         $this->assertSame('successfullysaved', $output->getProperty('message'));
     }
 
@@ -32,11 +34,11 @@ class Actions_Settings_PrefsSave extends ActionTestCase
      */
     function test_prefs_input()
     {
-        $action = new rcmail_action_settings_prefs_save;
+        $action = new \rcmail_action_settings_prefs_save();
 
         $_POST = ['_test' => 'test'];
 
-        rcmail::get_instance()->config->set('test', null);
+        \rcmail::get_instance()->config->set('test', null);
 
         $this->assertSame(null, $action->prefs_input('unset', '/test/'));
         $this->assertSame('test', $action->prefs_input('test', '/^test/'));
diff --git a/tests/Actions/Settings/ResponseCreate.php b/tests/Actions/Settings/ResponseCreate.php
index 5de988a..4ce5f42 100644
--- a/tests/Actions/Settings/ResponseCreate.php
+++ b/tests/Actions/Settings/ResponseCreate.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_response_create
- *
- * @package Tests
  */
 class Actions_Settings_ResponseCreate extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Settings_ResponseCreate extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_response_create;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'add-response');
+        $action = new \rcmail_action_settings_response_create();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'add-response');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         $_GET = [];
diff --git a/tests/Actions/Settings/ResponseDelete.php b/tests/Actions/Settings/ResponseDelete.php
index 30451c9..f4838ff 100644
--- a/tests/Actions/Settings/ResponseDelete.php
+++ b/tests/Actions/Settings/ResponseDelete.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_response_delete
- *
- * @package Tests
  */
 class Actions_Settings_ResponseDelete extends ActionTestCase
 {
@@ -12,13 +15,13 @@ class Actions_Settings_ResponseDelete extends ActionTestCase
      */
     function test_delete_response()
     {
-        $action = new rcmail_action_settings_response_delete;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'delete-response');
+        $action = new \rcmail_action_settings_response_delete();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'delete-response');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->user->save_prefs(['compose_responses_static' => []]);
 
         self::initDB('responses');
diff --git a/tests/Actions/Settings/ResponseEdit.php b/tests/Actions/Settings/ResponseEdit.php
index c4390ac..d0535bb 100644
--- a/tests/Actions/Settings/ResponseEdit.php
+++ b/tests/Actions/Settings/ResponseEdit.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_response_edit
- *
- * @package Tests
  */
 class Actions_Settings_ResponseEdit extends ActionTestCase
 {
@@ -12,13 +15,13 @@ class Actions_Settings_ResponseEdit extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_response_edit;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'edit-response');
+        $action = new \rcmail_action_settings_response_edit();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'edit-response');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->user->save_prefs([
             'compose_responses_static' => [
                 ['name' => 'static 1', 'text' => 'Static Response One'],
@@ -62,7 +65,7 @@ class Actions_Settings_ResponseEdit extends ActionTestCase
      */
     function test_response_form()
     {
-        $result = rcmail_action_settings_response_edit::response_form([]);
+        $result = \rcmail_action_settings_response_edit::response_form([]);
 
         $this->assertTrue(strpos(trim($result), '<table>') === 0);
     }
diff --git a/tests/Actions/Settings/ResponseGet.php b/tests/Actions/Settings/ResponseGet.php
index 13ad04c..3b81bf1 100644
--- a/tests/Actions/Settings/ResponseGet.php
+++ b/tests/Actions/Settings/ResponseGet.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_settings_response_get
- *
- * @package Tests
  */
 class Actions_Settings_ResponseGet extends ActionTestCase
 {
@@ -12,13 +15,13 @@ class Actions_Settings_ResponseGet extends ActionTestCase
      */
     function test_get_response()
     {
-        $action = new rcmail_action_settings_response_get;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'response-get');
+        $action = new \rcmail_action_settings_response_get();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'response-get');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->user->save_prefs([
             'compose_responses_static' => [
                 ['name' => 'static 1', 'text' => 'Static Response One'],
diff --git a/tests/Actions/Settings/ResponseSave.php b/tests/Actions/Settings/ResponseSave.php
index e3d5769..567f9f9 100644
--- a/tests/Actions/Settings/ResponseSave.php
+++ b/tests/Actions/Settings/ResponseSave.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_settings_response_save
- *
- * @package Tests
  */
 class Actions_Settings_ResponseSave extends ActionTestCase
 {
@@ -12,13 +14,13 @@ class Actions_Settings_ResponseSave extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_response_save;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'save-response');
+        $action = new \rcmail_action_settings_response_save();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'save-response');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->user->save_prefs(['compose_responses_static' => []]);
 
         self::initDB('responses');
@@ -34,7 +36,7 @@ class Actions_Settings_ResponseSave extends ActionTestCase
 
         $action->run();
 
-        $this->assertSame('edit-response', rcmail::get_instance()->action);
+        $this->assertSame('edit-response', \rcmail::get_instance()->action);
         $this->assertSame('successfullysaved', $output->getProperty('message'));
 
         $response = $rcmail->get_compose_response($responses[0]['id']);
@@ -53,7 +55,7 @@ class Actions_Settings_ResponseSave extends ActionTestCase
 
         $action->run();
 
-        $this->assertSame('edit-response', rcmail::get_instance()->action);
+        $this->assertSame('edit-response', \rcmail::get_instance()->action);
         $this->assertSame('successfullysaved', $output->getProperty('message'));
 
         $response = $rcmail->get_compose_response($responses[0]['id']);
@@ -71,7 +73,7 @@ class Actions_Settings_ResponseSave extends ActionTestCase
 
         $action->run();
 
-        $this->assertSame('edit-response', rcmail::get_instance()->action);
+        $this->assertSame('edit-response', \rcmail::get_instance()->action);
         $this->assertSame('successfullysaved', $output->getProperty('message'));
 
         $responses = $rcmail->get_compose_responses();
diff --git a/tests/Actions/Settings/Responses.php b/tests/Actions/Settings/Responses.php
index 83445a8..2f2bbe7 100644
--- a/tests/Actions/Settings/Responses.php
+++ b/tests/Actions/Settings/Responses.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_settings_responses
- *
- * @package Tests
  */
 class Actions_Settings_Responses extends ActionTestCase
 {
@@ -12,10 +15,10 @@ class Actions_Settings_Responses extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_settings_responses;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'responses');
+        $action = new \rcmail_action_settings_responses();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'responses');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         self::initDB('responses');
@@ -36,7 +39,7 @@ class Actions_Settings_Responses extends ActionTestCase
      */
     function test_responses_list()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->user->save_prefs([
             'compose_responses_static' => [
                 ['name' => 'static 1', 'text' => 'Static Response One'],
@@ -45,8 +48,8 @@ class Actions_Settings_Responses extends ActionTestCase
 
         self::initDB('responses');
 
-        $action = new rcmail_action_settings_responses;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'settings', 'responses');
+        $action = new \rcmail_action_settings_responses();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'settings', 'responses');
 
         $result = $action->responses_list([]);
         $expected = '<table id="rcmresponseslist"><thead><tr><th class="name">Display Name</th></tr></thead><tbody>'
diff --git a/tests/Actions/Settings/Upload.php b/tests/Actions/Settings/Upload.php
index a89ddde..55b50b1 100644
--- a/tests/Actions/Settings/Upload.php
+++ b/tests/Actions/Settings/Upload.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_settings_upload
- *
- * @package Tests
  */
 class Actions_Settings_Upload extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Settings_Upload extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_settings_upload;
+        $object = new \rcmail_action_settings_upload();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Settings/UploadDisplay.php b/tests/Actions/Settings/UploadDisplay.php
index b72ddce..6fc26a4 100644
--- a/tests/Actions/Settings/UploadDisplay.php
+++ b/tests/Actions/Settings/UploadDisplay.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Contacts;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_settings_upload_display
- *
- * @package Tests
  */
 class Actions_Settings_UploadDisplay extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Settings_UploadDisplay extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_settings_upload_display;
+        $object = new \rcmail_action_settings_upload_display();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Utils/Error.php b/tests/Actions/Utils/Error.php
index 8c10d46..55a15f6 100644
--- a/tests/Actions/Utils/Error.php
+++ b/tests/Actions/Utils/Error.php
@@ -1,9 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail_action_utils_error
- *
- * @package Tests
  */
 class Actions_Utils_Error extends ActionTestCase
 {
@@ -12,10 +16,10 @@ class Actions_Utils_Error extends ActionTestCase
      */
     function test_run_http()
     {
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'mail', 'test');
-        $action = new rcmail_action_utils_error;
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'mail', 'test');
+        $action = new \rcmail_action_utils_error();
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Default error
@@ -40,10 +44,10 @@ class Actions_Utils_Error extends ActionTestCase
         $_SERVER['REQUEST_METHOD'] = 'GET';
         $_SERVER['REQUEST_URI']    = '';
 
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'mail', 'compose');
-        $action = new rcmail_action_utils_error;
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'mail', 'compose');
+        $action = new \rcmail_action_utils_error();
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // Default error
diff --git a/tests/Actions/Utils/Html2text.php b/tests/Actions/Utils/Html2text.php
index 1bd3ae3..c19fe82 100644
--- a/tests/Actions/Utils/Html2text.php
+++ b/tests/Actions/Utils/Html2text.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_utils_html2text
- *
- * @package Tests
  */
 class Actions_Utils_Html2text extends ActionTestCase
 {
@@ -12,13 +15,13 @@ class Actions_Utils_Html2text extends ActionTestCase
      */
     function test_run()
     {
-        $object = new rcmail_action_utils_html2text;
+        $object = new \rcmail_action_utils_html2text();
         $html = "<p>test</p>";
         $object::$source = $this->createTempFile($html);
 
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'utils', 'html2text');
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'utils', 'html2text');
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
         $this->assertTrue($object->checks());
 
         $this->runAndAssert($object, OutputHtmlMock::E_EXIT);
diff --git a/tests/Actions/Utils/Killcache.php b/tests/Actions/Utils/Killcache.php
index 9f959df..98b58d0 100644
--- a/tests/Actions/Utils/Killcache.php
+++ b/tests/Actions/Utils/Killcache.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_utils_killcache
- *
- * @package Tests
  */
 class Actions_Utils_Killcache extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Utils_Killcache extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_utils_killcache;
+        $object = new \rcmail_action_utils_killcache();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Utils/Modcss.php b/tests/Actions/Utils/Modcss.php
index 1081886..2b40f55 100644
--- a/tests/Actions/Utils/Modcss.php
+++ b/tests/Actions/Utils/Modcss.php
@@ -1,9 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
+use function Roundcube\Tests\setHttpClientMock;
+
 /**
  * Test class to test rcmail_action_utils_modcss
- *
- * @package Tests
  */
 class Actions_Utils_Modcss extends ActionTestCase
 {
@@ -12,10 +17,10 @@ class Actions_Utils_Modcss extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_utils_modcss;
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'utils', 'modcss');
+        $action = new \rcmail_action_utils_modcss();
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'utils', 'modcss');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
         // No input parameters
diff --git a/tests/Actions/Utils/SavePref.php b/tests/Actions/Utils/SavePref.php
index f568267..e989a90 100644
--- a/tests/Actions/Utils/SavePref.php
+++ b/tests/Actions/Utils/SavePref.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_utils_save_pref
- *
- * @package Tests
  */
 class Actions_Utils_SavePref extends ActionTestCase
 {
@@ -12,13 +15,13 @@ class Actions_Utils_SavePref extends ActionTestCase
      */
     function test_run()
     {
-        $action = new rcmail_action_utils_save_pref;
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'utils', 'save_pref');
+        $action = new \rcmail_action_utils_save_pref();
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'utils', 'save_pref');
 
-        $this->assertInstanceOf('rcmail_action', $action);
+        $this->assertInstanceOf(\rcmail_action::class, $action);
         $this->assertTrue($action->checks());
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $rcmail->user->save_prefs(['list_cols' => []]);
 
         $_POST = [
@@ -30,7 +33,7 @@ class Actions_Utils_SavePref extends ActionTestCase
 
         $result = $output->getOutput();
 
-        $user  = new rcube_user($rcmail->user->ID);
+        $user  = new \rcube_user($rcmail->user->ID);
         $prefs = $user->get_prefs();
 
         $this->assertSame(['date'], $prefs['list_cols']);
diff --git a/tests/Actions/Utils/Spell.php b/tests/Actions/Utils/Spell.php
index 9273684..e4548ce 100644
--- a/tests/Actions/Utils/Spell.php
+++ b/tests/Actions/Utils/Spell.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_utils_spell
- *
- * @package Tests
  */
 class Actions_Utils_Spell extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Utils_Spell extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_utils_spell;
+        $object = new \rcmail_action_utils_spell();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Utils/SpellHtml.php b/tests/Actions/Utils/SpellHtml.php
index 6e92f5a..9ca2b7a 100644
--- a/tests/Actions/Utils/SpellHtml.php
+++ b/tests/Actions/Utils/SpellHtml.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action_utils_spell_html
- *
- * @package Tests
  */
 class Actions_Utils_SpellHtml extends ActionTestCase
 {
@@ -12,8 +14,8 @@ class Actions_Utils_SpellHtml extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_utils_spell_html;
+        $object = new \rcmail_action_utils_spell_html();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 }
diff --git a/tests/Actions/Utils/Text2html.php b/tests/Actions/Utils/Text2html.php
index fa88616..fa2a2b4 100644
--- a/tests/Actions/Utils/Text2html.php
+++ b/tests/Actions/Utils/Text2html.php
@@ -1,9 +1,12 @@
 <?php
 
+namespace Roundcube\Tests\Actions\Utils;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\OutputHtmlMock;
+
 /**
  * Test class to test rcmail_action_utils_text2html
- *
- * @package Tests
  */
 class Actions_Utils_Text2html extends ActionTestCase
 {
@@ -12,9 +15,9 @@ class Actions_Utils_Text2html extends ActionTestCase
      */
     function test_class()
     {
-        $object = new rcmail_action_utils_text2html;
+        $object = new \rcmail_action_utils_text2html();
 
-        $this->assertInstanceOf('rcmail_action', $object);
+        $this->assertInstanceOf(\rcmail_action::class, $object);
     }
 
     /**
@@ -22,11 +25,11 @@ class Actions_Utils_Text2html extends ActionTestCase
      */
     function test_run()
     {
-        $object = new rcmail_action_utils_text2html;
+        $object = new \rcmail_action_utils_text2html();
         $input = "test plain text input";
         $object::$source = $this->createTempFile($input);
 
-        $output = $this->initOutput(rcmail_action::MODE_HTTP, 'utils', 'text2html');
+        $output = $this->initOutput(\rcmail_action::MODE_HTTP, 'utils', 'text2html');
 
         $this->assertTrue($object->checks());
 
diff --git a/tests/ExitException.php b/tests/ExitException.php
index e092f20..fbc3dae 100644
--- a/tests/ExitException.php
+++ b/tests/ExitException.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace Roundcube\Tests;
+
 /**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
@@ -19,9 +21,7 @@
 
 /**
  * An exception thrown by output classes instead of the `exit` call
- *
- * @package Tests
  */
-class ExitException extends Exception
+class ExitException extends \Exception
 {
 }
diff --git a/tests/Framework/Addressbook.php b/tests/Framework/Addressbook.php
index 73116c3..c0525a4 100644
--- a/tests/Framework/Addressbook.php
+++ b/tests/Framework/Addressbook.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_addressbook class
- *
- * @package Tests
  */
-class Framework_Addressbook extends PHPUnit\Framework\TestCase
+class Framework_Addressbook extends TestCase
 {
     /**
      * Test for get_col_values() method
@@ -13,17 +15,17 @@ class Framework_Addressbook extends PHPUnit\Framework\TestCase
     function test_get_col_values()
     {
         $data = ['email' => 'test@test.com', 'other' => 'test'];
-        $result = rcube_addressbook::get_col_values('email', $data, true);
+        $result = \rcube_addressbook::get_col_values('email', $data, true);
 
         $this->assertSame(['test@test.com'], $result);
 
         $data = ['email:home' => 'test@test.com', 'other' => 'test'];
-        $result = rcube_addressbook::get_col_values('email', $data, true);
+        $result = \rcube_addressbook::get_col_values('email', $data, true);
 
         $this->assertSame(['test@test.com'], $result);
 
         $data = ['email:home' => 'test@test.com', 'other' => 'test'];
-        $result = rcube_addressbook::get_col_values('email', $data, false);
+        $result = \rcube_addressbook::get_col_values('email', $data, false);
 
         $this->assertSame(['home' => ['test@test.com']], $result);
     }
@@ -34,32 +36,32 @@ class Framework_Addressbook extends PHPUnit\Framework\TestCase
     function test_compose_list_name()
     {
         $contact = [];
-        $result  = rcube_addressbook::compose_list_name($contact);
+        $result  = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('', $result);
 
         $contact = ['email' => 'email@address.tld'];
-        $result  = rcube_addressbook::compose_list_name($contact);
+        $result  = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('email@address.tld', $result);
 
         $contact = ['email' => 'email@address.tld', 'organization' => 'Org'];
-        $result  = rcube_addressbook::compose_list_name($contact);
+        $result  = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('Org', $result);
 
         $contact['firstname'] = 'First';
-        $result = rcube_addressbook::compose_list_name($contact);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('First', $result);
 
         $contact['surname'] = 'Last';
-        $result = rcube_addressbook::compose_list_name($contact);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('First Last', $result);
 
         $contact['name'] = 'Name';
-        $result = rcube_addressbook::compose_list_name($contact);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('Name', $result);
 
@@ -67,24 +69,24 @@ class Framework_Addressbook extends PHPUnit\Framework\TestCase
         $contact['prefix'] = 'Dr.';
         $contact['suffix'] = 'Jr.';
         $contact['middlename'] = 'M.';
-        $result = rcube_addressbook::compose_list_name($contact);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('Dr. First M. Last Jr.', $result);
 
         // TODO: Test different modes
         /*
-        rcube::get_instance()->config->set('addressbook_name_listing', 3);
-        $result = rcube_addressbook::compose_list_name($contact);
+        \rcube::get_instance()->config->set('addressbook_name_listing', 3);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('Last, First M.', $result);
 
-        rcube::get_instance()->config->set('addressbook_name_listing', 2);
-        $result = rcube_addressbook::compose_list_name($contact);
+        \rcube::get_instance()->config->set('addressbook_name_listing', 2);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('Last First M.', $result);
 
-        rcube::get_instance()->config->set('addressbook_name_listing', 1);
-        $result = rcube_addressbook::compose_list_name($contact);
+        \rcube::get_instance()->config->set('addressbook_name_listing', 1);
+        $result = \rcube_addressbook::compose_list_name($contact);
 
         $this->assertSame('First M. Last', $result);
         */
diff --git a/tests/Framework/Addresses.php b/tests/Framework/Addresses.php
index 1a33c34..6584407 100644
--- a/tests/Framework/Addresses.php
+++ b/tests/Framework/Addresses.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_addresses class
- *
- * @package Tests
  */
-class Framework_Addresses extends PHPUnit\Framework\TestCase
+class Framework_Addresses extends TestCase
 {
 
     /**
@@ -13,10 +15,10 @@ class Framework_Addresses extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $db     = new rcube_db('test');
-        $object = new rcube_addresses($db, null, 1);
+        $db     = new \rcube_db('test');
+        $object = new \rcube_addresses($db, null, 1);
 
-        $this->assertInstanceOf('rcube_addresses', $object, "Class constructor");
-        $this->assertInstanceOf('rcube_addressbook', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_addresses::class, $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_addressbook::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/BaseReplacer.php b/tests/Framework/BaseReplacer.php
index 04cbce5..90f805b 100644
--- a/tests/Framework/BaseReplacer.php
+++ b/tests/Framework/BaseReplacer.php
@@ -1,11 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_base_replacer class
- *
- * @package Tests
  */
-class Framework_BaseReplacer extends PHPUnit\Framework\TestCase
+class Framework_BaseReplacer extends TestCase
 {
 
     /**
@@ -13,9 +16,9 @@ class Framework_BaseReplacer extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_base_replacer('test');
+        $object = new \rcube_base_replacer('test');
 
-        $this->assertInstanceOf('rcube_base_replacer', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_base_replacer::class, $object, "Class constructor");
     }
 
     /**
@@ -26,7 +29,7 @@ class Framework_BaseReplacer extends PHPUnit\Framework\TestCase
         $base = 'http://thisshouldntbetheurl.bob.com/';
         $html = '<A href=http://shouldbethislink.com>Test URL</A>';
 
-        $replacer = new rcube_base_replacer($base);
+        $replacer = new \rcube_base_replacer($base);
         $response = $replacer->replace($html);
 
         $this->assertSame('<A href="http://shouldbethislink.com">Test URL</A>', $response);
@@ -35,7 +38,7 @@ class Framework_BaseReplacer extends PHPUnit\Framework\TestCase
     /**
      * Data for absolute_url() test
      */
-    function data_absolute_url()
+    static function data_absolute_url()
     {
         return [
             ['', 'http://test', 'http://test/'],
@@ -52,9 +55,11 @@ class Framework_BaseReplacer extends PHPUnit\Framework\TestCase
      * Test absolute_url()
      * @dataProvider data_absolute_url
      */
+
+    #[DataProvider('data_absolute_url')]
     function test_absolute_url($path, $base, $expected)
     {
-        $replacer = new rcube_base_replacer('test');
+        $replacer = new \rcube_base_replacer('test');
         $result   = $replacer->absolute_url($path, $base);
 
         $this->assertSame($expected, $result);
diff --git a/tests/Framework/Bootstrap.php b/tests/Framework/Bootstrap.php
index 2d59c7c..ac6dc7e 100644
--- a/tests/Framework/Bootstrap.php
+++ b/tests/Framework/Bootstrap.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_shared functions
- *
- * @package Tests
  */
-class Framework_Bootstrap extends PHPUnit\Framework\TestCase
+class Framework_Bootstrap extends TestCase
 {
 
     /**
diff --git a/tests/Framework/Browser.php b/tests/Framework/Browser.php
index 8a9815a..7cfdebd 100644
--- a/tests/Framework/Browser.php
+++ b/tests/Framework/Browser.php
@@ -1,15 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_browser class
- *
- * @package Tests
  */
-class Framework_Browser extends PHPUnit\Framework\TestCase
+class Framework_Browser extends TestCase
 {
     /**
      * @dataProvider browsers
      */
+    #[DataProvider('browsers')]
     function test_browser($useragent, $opera, $chrome, $ie, $edge, $safari, $mz)
     {
         $object = $this->getBrowser($useragent);
@@ -25,6 +29,7 @@ class Framework_Browser extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider os
      */
+    #[DataProvider('os')]
     function test_os($useragent, $windows, $linux, $unix, $mac)
     {
         $object = $this->getBrowser($useragent);
@@ -39,23 +44,24 @@ class Framework_Browser extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider versions
      */
+    #[DataProvider('versions')]
     function test_version($useragent, $version)
     {
         $object = $this->getBrowser($useragent);
         $this->assertEquals($version, $object->ver);
     }
 
-    function versions()
+    static function versions()
     {
-        return $this->extractDataSet(['version']);
+        return static::extractDataSet(['version']);
     }
 
-    function browsers()
+    static function browsers()
     {
-        return $this->extractDataSet(['isOpera', 'isChrome', 'isIE', 'isEdge', 'isSafari', 'isMZ']);
+        return static::extractDataSet(['isOpera', 'isChrome', 'isIE', 'isEdge', 'isSafari', 'isMZ']);
     }
 
-    function useragents()
+    static function useragents()
     {
         return [
             'WIN: Mozilla Firefox ' => [
@@ -150,16 +156,16 @@ class Framework_Browser extends PHPUnit\Framework\TestCase
         ];
     }
 
-    function os()
+    static function os()
     {
-        return $this->extractDataSet(['isWin', 'isLinux', 'isUnix', 'isMac']);
+        return static::extractDataSet(['isWin', 'isLinux', 'isUnix', 'isMac']);
     }
 
-    private function extractDataSet($keys)
+    protected static function extractDataSet($keys)
     {
         $keys = array_merge(['useragent'], $keys);
 
-        $browser = $this->useragents();
+        $browser = static::useragents();
 
         $extracted = [];
 
@@ -174,13 +180,13 @@ class Framework_Browser extends PHPUnit\Framework\TestCase
 
     /**
      * @param string $useragent
-     * @return rcube_browser
+     * @return \rcube_browser
      */
     private function getBrowser($useragent)
     {
         $_SERVER['HTTP_USER_AGENT'] = $useragent;
 
-        $object = new rcube_browser();
+        $object = new \rcube_browser();
 
         return $object;
     }
diff --git a/tests/Framework/Cache.php b/tests/Framework/Cache.php
index 04ea632..00b8e28 100644
--- a/tests/Framework/Cache.php
+++ b/tests/Framework/Cache.php
@@ -1,21 +1,23 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_cache class
- *
- * @package Tests
  */
-class Framework_Cache extends PHPUnit\Framework\TestCase
+class Framework_Cache extends TestCase
 {
     /**
      * Test factory method
      */
     function test_factory()
     {
-        $object = rcube_cache::factory('db', 1);
+        $object = \rcube_cache::factory('db', 1);
 
-        $this->assertInstanceOf('rcube_cache_db', $object, "Class constructor");
-        $this->assertInstanceOf('rcube_cache', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_cache_db::class, $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_cache::class, $object, "Class constructor");
     }
 
     /**
@@ -23,9 +25,9 @@ class Framework_Cache extends PHPUnit\Framework\TestCase
      */
     function test_key_name()
     {
-        $this->assertSame('test', rcube_cache::key_name('test'));
+        $this->assertSame('test', \rcube_cache::key_name('test'));
 
         $params = ['test1' => 'test2'];
-        $this->assertSame('test.ad0234829205b9033196ba818f7a872b', rcube_cache::key_name('test', $params));
+        $this->assertSame('test.ad0234829205b9033196ba818f7a872b', \rcube_cache::key_name('test', $params));
     }
 }
diff --git a/tests/Framework/CacheDB.php b/tests/Framework/CacheDB.php
index 2e274a4..2221fb6 100644
--- a/tests/Framework/CacheDB.php
+++ b/tests/Framework/CacheDB.php
@@ -1,22 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_cache_db class
- *
- * @package Tests
  */
-class Framework_CacheDB extends PHPUnit\Framework\TestCase
+class Framework_CacheDB extends TestCase
 {
     /**
      * Test common cache functionality
      */
     function test_common_cache_operations()
     {
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
         $db    = $rcube->get_dbh();
         $db->query('DELETE FROM cache');
 
-        $cache = new rcube_cache_db(1, 'test', 60);
+        $cache = new \rcube_cache_db(1, 'test', 60);
 
         // Set and get cache record
         $data =  ['data'];
@@ -27,7 +29,7 @@ class Framework_CacheDB extends PHPUnit\Framework\TestCase
 
         $cache->close();
 
-        $cache = new rcube_cache_db(1, 'test', 60);
+        $cache = new \rcube_cache_db(1, 'test', 60);
 
         $this->assertSame($data, $cache->get('test'));
 
@@ -38,7 +40,7 @@ class Framework_CacheDB extends PHPUnit\Framework\TestCase
 
         $cache->close();
 
-        $cache = new rcube_cache_db(1, 'test', 60);
+        $cache = new \rcube_cache_db(1, 'test', 60);
 
         $this->assertSame(null, $cache->get('test'));
 
diff --git a/tests/Framework/Charset.php b/tests/Framework/Charset.php
index 2efc48f..137bbd8 100644
--- a/tests/Framework/Charset.php
+++ b/tests/Framework/Charset.php
@@ -1,17 +1,23 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_charset class
  *
- * @package Tests
  * @group mbstring
  */
-class Framework_Charset extends PHPUnit\Framework\TestCase
+#[Group('mbstring')]
+class Framework_Charset extends TestCase
 {
     /**
      * Data for test_clean()
      */
-    function data_clean()
+    static function data_clean()
     {
         return [
             ['', ''],
@@ -27,15 +33,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_clean
      */
+    #[DataProvider('data_clean')]
     function test_clean($input, $output)
     {
-        $this->assertSame($output, rcube_charset::clean($input));
+        $this->assertSame($output, \rcube_charset::clean($input));
     }
 
     /**
      * Data for test_is_valid()
      */
-    function data_is_valid()
+    static function data_is_valid()
     {
         $list = [];
         foreach (mb_list_encodings() as $charset) {
@@ -56,15 +63,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_is_valid
      */
+    #[DataProvider('data_is_valid')]
     function test_is_valid($input, $result)
     {
-        $this->assertSame($result, rcube_charset::is_valid($input));
+        $this->assertSame($result, \rcube_charset::is_valid($input));
     }
 
     /**
      * Data for test_parse_charset()
      */
-    function data_parse_charset()
+    static function data_parse_charset()
     {
         return [
             ['UTF8', 'UTF-8'],
@@ -75,15 +83,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_parse_charset
      */
+    #[DataProvider('data_parse_charset')]
     function test_parse_charset($input, $output)
     {
-        $this->assertEquals($output, rcube_charset::parse_charset($input));
+        $this->assertEquals($output, \rcube_charset::parse_charset($input));
     }
 
     /**
      * Data for test_convert()
      */
-    function data_convert()
+    static function data_convert()
     {
         $data = [
             ['ö', 'ö', 'UTF-8', 'UTF-8'],
@@ -111,15 +120,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_convert
      */
+    #[DataProvider('data_convert')]
     function test_convert($input, $output, $from, $to)
     {
-        $this->assertEquals($output, rcube_charset::convert($input, $from, $to));
+        $this->assertEquals($output, \rcube_charset::convert($input, $from, $to));
     }
 
     /**
      * Data for test_utf7_to_utf8()
      */
-    function data_utf7_to_utf8()
+    static function data_utf7_to_utf8()
     {
         return [
             ['+BCAEMARBBEEESwQ7BDoEOA-', 'Рассылки'],
@@ -129,15 +139,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_utf7_to_utf8
      */
+    #[DataProvider('data_utf7_to_utf8')]
     function test_utf7_to_utf8($input, $output)
     {
-        $this->assertEquals($output, rcube_charset::utf7_to_utf8($input));
+        $this->assertEquals($output, \rcube_charset::utf7_to_utf8($input));
     }
 
     /**
      * Data for test_utf7imap_to_utf8()
      */
-    function data_utf7imap_to_utf8()
+    static function data_utf7imap_to_utf8()
     {
         return [
             ['&BCAEMARBBEEESwQ7BDoEOA-', 'Рассылки'],
@@ -147,15 +158,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_utf7imap_to_utf8
      */
+    #[DataProvider('data_utf7imap_to_utf8')]
     function test_utf7imap_to_utf8($input, $output)
     {
-        $this->assertEquals($output, rcube_charset::utf7imap_to_utf8($input));
+        $this->assertEquals($output, \rcube_charset::utf7imap_to_utf8($input));
     }
 
     /**
      * Data for test_utf8_to_utf7imap()
      */
-    function data_utf8_to_utf7imap()
+    static function data_utf8_to_utf7imap()
     {
         return [
             ['Рассылки', '&BCAEMARBBEEESwQ7BDoEOA-'],
@@ -165,15 +177,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_utf8_to_utf7imap
      */
+    #[DataProvider('data_utf8_to_utf7imap')]
     function test_utf8_to_utf7imap($input, $output)
     {
-        $this->assertEquals($output, rcube_charset::utf8_to_utf7imap($input));
+        $this->assertEquals($output, \rcube_charset::utf8_to_utf7imap($input));
     }
 
     /**
      * Data for test_utf16_to_utf8()
      */
-    function data_utf16_to_utf8()
+    static function data_utf16_to_utf8()
     {
         return [
             [base64_decode('BCAEMARBBEEESwQ7BDoEOA=='), 'Рассылки'],
@@ -183,15 +196,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_utf16_to_utf8
      */
+    #[DataProvider('data_utf16_to_utf8')]
     function test_utf16_to_utf8($input, $output)
     {
-        $this->assertEquals($output, rcube_charset::utf16_to_utf8($input));
+        $this->assertEquals($output, \rcube_charset::utf16_to_utf8($input));
     }
 
     /**
      * Data for test_detect()
      */
-    function data_detect()
+    static function data_detect()
     {
         return [
             ['', '', 'UTF-8'],
@@ -202,15 +216,16 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_detect
      */
+    #[DataProvider('data_detect')]
     function test_detect($input, $fallback, $output)
     {
-        $this->assertEquals($output, rcube_charset::detect($input, $fallback));
+        $this->assertEquals($output, \rcube_charset::detect($input, $fallback));
     }
 
     /**
      * Data for test_detect()
      */
-    function data_detect_with_lang()
+    static function data_detect_with_lang()
     {
         return [
             [base64_decode('xeOl3KZXutkspUStbg=='), 'zh_TW', 'BIG-5'],
@@ -220,8 +235,9 @@ class Framework_Charset extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_detect_with_lang
      */
+    #[DataProvider('data_detect_with_lang')]
     function test_detect_with_lang($input, $lang, $output)
     {
-        $this->assertEquals($output, rcube_charset::detect($input, $output, $lang));
+        $this->assertEquals($output, \rcube_charset::detect($input, $output, $lang));
     }
 }
diff --git a/tests/Framework/Config.php b/tests/Framework/Config.php
index 700e8f3..c086a08 100644
--- a/tests/Framework/Config.php
+++ b/tests/Framework/Config.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\invokeMethod;
+
 /**
  * Test class to test rcube_config class
- *
- * @package Tests
  */
-class Framework_Config extends PHPUnit\Framework\TestCase
+class Framework_Config extends TestCase
 {
 
     /**
@@ -13,9 +17,9 @@ class Framework_Config extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_config();
+        $object = new \rcube_config();
 
-        $this->assertInstanceOf('rcube_config', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_config::class, $object, "Class constructor");
     }
 
     /**
@@ -23,8 +27,8 @@ class Framework_Config extends PHPUnit\Framework\TestCase
      */
     function test_resolve_timezone_alias()
     {
-        $this->assertSame('UTC', rcube_config::resolve_timezone_alias('Etc/GMT'));
-        $this->assertSame('UTC', rcube_config::resolve_timezone_alias('Etc/Zulu'));
+        $this->assertSame('UTC', \rcube_config::resolve_timezone_alias('Etc/GMT'));
+        $this->assertSame('UTC', \rcube_config::resolve_timezone_alias('Etc/Zulu'));
     }
 
     /**
@@ -32,7 +36,7 @@ class Framework_Config extends PHPUnit\Framework\TestCase
      */
     function test_get_and_set()
     {
-        $object = new rcube_config();
+        $object = new \rcube_config();
 
         $this->assertSame(null, $object->get('test'));
         $this->assertSame('def', $object->get('test', 'def'));
@@ -53,7 +57,7 @@ class Framework_Config extends PHPUnit\Framework\TestCase
      */
     function test_guess_type()
     {
-        $object = new rcube_config();
+        $object = new \rcube_config();
 
         $this->assertSame('bool', invokeMethod($object, 'guess_type', ['true']));
         $this->assertSame('bool', invokeMethod($object, 'guess_type', ['false']));
@@ -81,7 +85,7 @@ class Framework_Config extends PHPUnit\Framework\TestCase
      */
     function test_parse_env()
     {
-        $object = new rcube_config();
+        $object = new \rcube_config();
 
         $this->assertSame(true, invokeMethod($object, 'parse_env', ['true']));
         $this->assertSame(1, invokeMethod($object, 'parse_env', ['1']));
diff --git a/tests/Framework/Contacts.php b/tests/Framework/Contacts.php
index f7dc192..9192d51 100644
--- a/tests/Framework/Contacts.php
+++ b/tests/Framework/Contacts.php
@@ -1,20 +1,22 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_contacts class
- *
- * @package Tests
  */
-class Framework_Contacts extends PHPUnit\Framework\TestCase
+class Framework_Contacts extends TestCase
 {
     /**
      * Class constructor
      */
     function test_class()
     {
-        $object = new rcube_contacts(null, null);
+        $object = new \rcube_contacts(null, null);
 
-        $this->assertInstanceOf('rcube_contacts', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_contacts::class, $object, "Class constructor");
     }
 
     /**
@@ -22,7 +24,7 @@ class Framework_Contacts extends PHPUnit\Framework\TestCase
      */
     function test_validate()
     {
-        $contacts = new rcube_contacts(null, null);
+        $contacts = new \rcube_contacts(null, null);
 
         $data = [];
         $this->assertSame(false, $contacts->validate($data));
diff --git a/tests/Framework/ContentFilter.php b/tests/Framework/ContentFilter.php
index a5fb25e..7e0e10b 100644
--- a/tests/Framework/ContentFilter.php
+++ b/tests/Framework/ContentFilter.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_content_filter class
- *
- * @package Tests
  */
-class Framework_ContentFilter extends PHPUnit\Framework\TestCase
+class Framework_ContentFilter extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_ContentFilter extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_content_filter();
+        $object = new \rcube_content_filter();
 
-        $this->assertInstanceOf('rcube_content_filter', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_content_filter::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/Csv2vcard.php b/tests/Framework/Csv2vcard.php
index 2f08686..7827466 100644
--- a/tests/Framework/Csv2vcard.php
+++ b/tests/Framework/Csv2vcard.php
@@ -1,16 +1,18 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_csv2vcard class
- *
- * @package Tests
  */
-class Framework_Csv2vcard extends PHPUnit\Framework\TestCase
+class Framework_Csv2vcard extends TestCase
 {
 
     function test_import_generic()
     {
-        $csv = new rcube_csv2vcard;
+        $csv = new \rcube_csv2vcard();
 
         // empty input
         $csv->import('');
@@ -31,7 +33,7 @@ class Framework_Csv2vcard extends PHPUnit\Framework\TestCase
         $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/tb_plain.csv');
         $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/tb_plain.vcf');
 
-        $csv = new rcube_csv2vcard;
+        $csv = new \rcube_csv2vcard();
         $csv->import($csv_text);
         $result = $csv->export();
 
@@ -49,7 +51,7 @@ class Framework_Csv2vcard extends PHPUnit\Framework\TestCase
         $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/email.csv');
         $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/email.vcf');
 
-        $csv = new rcube_csv2vcard;
+        $csv = new \rcube_csv2vcard();
         $csv->import($csv_text);
         $result = $csv->export();
 
@@ -70,7 +72,7 @@ class Framework_Csv2vcard extends PHPUnit\Framework\TestCase
         $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/gmail.csv');
         $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/gmail.vcf');
 
-        $csv = new rcube_csv2vcard;
+        $csv = new \rcube_csv2vcard();
         $csv->import($csv_text);
         $result = $csv->export();
 
@@ -88,7 +90,7 @@ class Framework_Csv2vcard extends PHPUnit\Framework\TestCase
         $csv_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/outlook.csv');
         $vcf_text = file_get_contents(TESTS_DIR . '/src/Csv2vcard/outlook.vcf');
 
-        $csv = new rcube_csv2vcard;
+        $csv = new \rcube_csv2vcard();
         $csv->import($csv_text);
         $result = $csv->export();
 
diff --git a/tests/Framework/DB.php b/tests/Framework/DB.php
index 3ac4f13..853489d 100644
--- a/tests/Framework/DB.php
+++ b/tests/Framework/DB.php
@@ -1,12 +1,17 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_db class
  *
- * @package Tests
  * @group database
  */
-class Framework_DB extends PHPUnit\Framework\TestCase
+#[Group('database')]
+class Framework_DB extends TestCase
 {
     /**
      * Test script execution and table_prefix replacements
@@ -227,7 +232,7 @@ class Framework_DB extends PHPUnit\Framework\TestCase
      */
     function test_list_tables()
     {
-        $db = rcube::get_instance()->get_dbh();
+        $db = \rcube::get_instance()->get_dbh();
 
         $tables = $db->list_tables();
 
@@ -239,7 +244,7 @@ class Framework_DB extends PHPUnit\Framework\TestCase
      */
     function test_list_cols()
     {
-        $db = rcube::get_instance()->get_dbh();
+        $db = \rcube::get_instance()->get_dbh();
 
         $columns = $db->list_cols('cache');
 
@@ -251,7 +256,7 @@ class Framework_DB extends PHPUnit\Framework\TestCase
      */
     function test_array2list()
     {
-        $db = rcube::get_instance()->get_dbh();
+        $db = \rcube::get_instance()->get_dbh();
 
         $this->assertSame('', $db->array2list([]));
         $this->assertSame('\'test\'', $db->array2list(['test']));
@@ -264,7 +269,7 @@ class Framework_DB extends PHPUnit\Framework\TestCase
      */
     function test_concat()
     {
-        $db = rcube::get_instance()->get_dbh();
+        $db = \rcube::get_instance()->get_dbh();
 
         $this->assertSame('(test)', $db->concat('test'));
         $this->assertSame('(test1 || test2)', $db->concat('test1', 'test2'));
@@ -282,20 +287,20 @@ class Framework_DB extends PHPUnit\Framework\TestCase
             $str .= chr($x);
         }
 
-        $this->assertSame($str, rcube_db::decode(rcube_db::encode($str)));
-        $this->assertSame($str, rcube_db::decode(rcube_db::encode($str, true), true));
+        $this->assertSame($str, \rcube_db::decode(\rcube_db::encode($str)));
+        $this->assertSame($str, \rcube_db::decode(\rcube_db::encode($str, true), true));
 
         $str = "グーグル谷歌中信фδοκιμήóźdźрöß😁😃";
 
-        $this->assertSame($str, rcube_db::decode(rcube_db::encode($str)));
-        $this->assertSame($str, rcube_db::decode(rcube_db::encode($str, true), true));
+        $this->assertSame($str, \rcube_db::decode(\rcube_db::encode($str)));
+        $this->assertSame($str, \rcube_db::decode(\rcube_db::encode($str, true), true));
     }
 }
 
 /**
  * rcube_db wrapper to test some protected methods
  */
-class rcube_db_test_wrapper extends rcube_db
+class rcube_db_test_wrapper extends \rcube_db
 {
     public $queries = [];
 
diff --git a/tests/Framework/DBMssql.php b/tests/Framework/DBMssql.php
index a1dced1..7469bc8 100644
--- a/tests/Framework/DBMssql.php
+++ b/tests/Framework/DBMssql.php
@@ -1,13 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_db_mssql class
  *
- * @package Tests
  * @group database
  * @group mssql
  */
-class Framework_DBMssql extends PHPUnit\Framework\TestCase
+#[Group('database')]
+#[Group('mssql')]
+class Framework_DBMssql extends TestCase
 {
 
     /**
@@ -15,8 +21,8 @@ class Framework_DBMssql extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_db_mssql('test');
+        $object = new \rcube_db_mssql('test');
 
-        $this->assertInstanceOf('rcube_db_mssql', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_db_mssql::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/DBMysql.php b/tests/Framework/DBMysql.php
index 1d5a3fc..79fe7d1 100644
--- a/tests/Framework/DBMysql.php
+++ b/tests/Framework/DBMysql.php
@@ -1,13 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_db_mysql class
  *
- * @package Tests
  * @group database
  * @group mysql
  */
-class Framework_DBMysql extends PHPUnit\Framework\TestCase
+#[Group('database')]
+#[Group('mysql')]
+class Framework_DBMysql extends TestCase
 {
 
     /**
@@ -15,8 +21,8 @@ class Framework_DBMysql extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_db_mysql('test');
+        $object = new \rcube_db_mysql('test');
 
-        $this->assertInstanceOf('rcube_db_mysql', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_db_mysql::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/DBOracle.php b/tests/Framework/DBOracle.php
index 8fff546..cb2cab9 100644
--- a/tests/Framework/DBOracle.php
+++ b/tests/Framework/DBOracle.php
@@ -1,13 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_db_oracle class
  *
- * @package Tests
  * @group database
  * @group oracle
  */
-class Framework_DBOracle extends PHPUnit\Framework\TestCase
+#[Group('database')]
+#[Group('oracle')]
+class Framework_DBOracle extends TestCase
 {
 
     /**
@@ -15,8 +21,8 @@ class Framework_DBOracle extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_db_oracle('test');
+        $object = new \rcube_db_oracle('test');
 
-        $this->assertInstanceOf('rcube_db_oracle', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_db_oracle::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/DBPgsql.php b/tests/Framework/DBPgsql.php
index 86f30a8..edc7bef 100644
--- a/tests/Framework/DBPgsql.php
+++ b/tests/Framework/DBPgsql.php
@@ -1,22 +1,30 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\invokeMethod;
+
 /**
  * Test class to test rcube_db_pgsql class
  *
- * @package Tests
  * @group database
  * @group postgres
  */
-class Framework_DBPgsql extends PHPUnit\Framework\TestCase
+#[Group('database')]
+#[Group('postgres')]
+class Framework_DBPgsql extends TestCase
 {
     /**
      * Class constructor
      */
     function test_class()
     {
-        $object = new rcube_db_pgsql('test');
+        $object = new \rcube_db_pgsql('test');
 
-        $this->assertInstanceOf('rcube_db_pgsql', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_db_pgsql::class, $object, "Class constructor");
     }
 
     /**
@@ -24,7 +32,7 @@ class Framework_DBPgsql extends PHPUnit\Framework\TestCase
      */
     function test_exec_script_schema_prefix()
     {
-        $db = rcube_db::factory('pgsql:test');
+        $db = \rcube_db::factory('pgsql:test');
         $db->set_option('table_prefix', 'prefix.');
 
         $script = [
@@ -63,7 +71,7 @@ class Framework_DBPgsql extends PHPUnit\Framework\TestCase
             "ALTER SEQUENCE prefix.user_ids RENAME TO prefix.users_seq",
         ];
 
-        $method = new ReflectionMethod('rcube_db_pgsql', 'fix_table_names');
+        $method = new \ReflectionMethod('rcube_db_pgsql', 'fix_table_names');
         $method->setAccessible(true);
 
         foreach ($script as $idx => $query) {
@@ -77,7 +85,7 @@ class Framework_DBPgsql extends PHPUnit\Framework\TestCase
      */
     function test_dsn_string()
     {
-        $db = new rcube_db_pgsql('test');
+        $db = new \rcube_db_pgsql('test');
 
         $dsn = $db->parse_dsn("pgsql://USERNAME:PASSWORD@HOST:5432/DATABASE");
         $result = invokeMethod($db, 'dsn_string', [$dsn]);
diff --git a/tests/Framework/DBSqlite.php b/tests/Framework/DBSqlite.php
index 7f33cec..8bbbbfb 100644
--- a/tests/Framework/DBSqlite.php
+++ b/tests/Framework/DBSqlite.php
@@ -1,13 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_db_sqlite class
  *
- * @package Tests
  * @group database
  * @group sqlite
  */
-class Framework_DBSqlite extends PHPUnit\Framework\TestCase
+#[Group('database')]
+#[Group('sqlite')]
+class Framework_DBSqlite extends TestCase
 {
 
     /**
@@ -15,8 +21,8 @@ class Framework_DBSqlite extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_db_sqlite('test');
+        $object = new \rcube_db_sqlite('test');
 
-        $this->assertInstanceOf('rcube_db_sqlite', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_db_sqlite::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/DBSqlsrv.php b/tests/Framework/DBSqlsrv.php
index 6af3f10..370c4d1 100644
--- a/tests/Framework/DBSqlsrv.php
+++ b/tests/Framework/DBSqlsrv.php
@@ -1,13 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\Group;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_db_sqlsrv class
  *
- * @package Tests
  * @group database
  * @group sqlsrv
  */
-class Framework_DBSqlsrv extends PHPUnit\Framework\TestCase
+#[Group('database')]
+#[Group('sqlsrv')]
+class Framework_DBSqlsrv extends TestCase
 {
 
     /**
@@ -15,8 +21,8 @@ class Framework_DBSqlsrv extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_db_sqlsrv('test');
+        $object = new \rcube_db_sqlsrv('test');
 
-        $this->assertInstanceOf('rcube_db_sqlsrv', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_db_sqlsrv::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/Enriched.php b/tests/Framework/Enriched.php
index e85d47b..7894f8d 100644
--- a/tests/Framework/Enriched.php
+++ b/tests/Framework/Enriched.php
@@ -1,11 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_enriched class
- *
- * @package Tests
  */
-class Framework_Enriched extends PHPUnit\Framework\TestCase
+class Framework_Enriched extends TestCase
 {
 
     /**
@@ -13,9 +16,9 @@ class Framework_Enriched extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_enriched();
+        $object = new \rcube_enriched();
 
-        $this->assertInstanceOf('rcube_enriched', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_enriched::class, $object, "Class constructor");
     }
 
     /**
@@ -25,7 +28,7 @@ class Framework_Enriched extends PHPUnit\Framework\TestCase
     {
         $enriched = '<bold><italic>the-text</italic></bold>';
         $expected = '<b><i>the-text</i></b>';
-        $result   = rcube_enriched::to_html($enriched);
+        $result   = \rcube_enriched::to_html($enriched);
 
         $this->assertSame($expected, $result);
     }
@@ -33,7 +36,7 @@ class Framework_Enriched extends PHPUnit\Framework\TestCase
     /**
      * Data for test_formatting()
      */
-    function data_formatting()
+    static function data_formatting()
     {
         return [
             ['<bold>', '<b>'],
@@ -65,9 +68,10 @@ class Framework_Enriched extends PHPUnit\Framework\TestCase
      * Test formatting conversion
      * @dataProvider data_formatting
      */
+    #[DataProvider('data_formatting')]
     function test_formatting($enriched, $expected)
     {
-        $result = rcube_enriched::to_html($enriched);
+        $result = \rcube_enriched::to_html($enriched);
 
         $this->assertSame($expected, $result);
     }
diff --git a/tests/Framework/Html.php b/tests/Framework/Html.php
index b7bba9d..7115ae7 100644
--- a/tests/Framework/Html.php
+++ b/tests/Framework/Html.php
@@ -1,11 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test html class
- *
- * @package Tests
  */
-class Framework_Html extends PHPUnit\Framework\TestCase
+class Framework_Html extends TestCase
 {
 
     /**
@@ -13,15 +16,15 @@ class Framework_Html extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new html;
+        $object = new \html();
 
-        $this->assertInstanceOf('html', $object, "Class constructor");
+        $this->assertInstanceOf(\html::class, $object, "Class constructor");
     }
 
     /**
      * Data for test_attrib_string()
      */
-    function data_attrib_string()
+    static function data_attrib_string()
     {
         return [
             [
@@ -61,15 +64,16 @@ class Framework_Html extends PHPUnit\Framework\TestCase
      * Test for attrib_string()
      * @dataProvider data_attrib_string
      */
+    #[DataProvider('data_attrib_string')]
     function test_attrib_string($arg1, $arg2, $expected)
     {
-        $this->assertEquals($expected, html::attrib_string($arg1, $arg2));
+        $this->assertEquals($expected, \html::attrib_string($arg1, $arg2));
     }
 
     /**
      * Data for test_quote()
      */
-    function data_quote()
+    static function data_quote()
     {
         return [
             ['abc', 'abc'],
@@ -86,15 +90,16 @@ class Framework_Html extends PHPUnit\Framework\TestCase
      * Test for quote()
      * @dataProvider data_quote
      */
+    #[DataProvider('data_quote')]
     function test_quote($str, $expected)
     {
-        $this->assertEquals($expected, html::quote($str));
+        $this->assertEquals($expected, \html::quote($str));
     }
 
     /**
      * Data for test_parse_attrib_string()
      */
-    function data_parse_attrib_string()
+    static function data_parse_attrib_string()
     {
         return [
             [
@@ -128,8 +133,9 @@ class Framework_Html extends PHPUnit\Framework\TestCase
      * Test for parse_attrib_string()
      * @dataProvider data_parse_attrib_string
      */
+    #[DataProvider('data_parse_attrib_string')]
     function test_parse_attrib_string($arg1, $expected)
     {
-        $this->assertEquals($expected, html::parse_attrib_string($arg1));
+        $this->assertEquals($expected, \html::parse_attrib_string($arg1));
     }
 }
diff --git a/tests/Framework/Html2text.php b/tests/Framework/Html2text.php
index ad4fb7a..9d53a7b 100644
--- a/tests/Framework/Html2text.php
+++ b/tests/Framework/Html2text.php
@@ -1,14 +1,17 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_html2text class
- *
- * @package Tests
  */
-class rc_html2text extends PHPUnit\Framework\TestCase
+class Framework_Html2text extends TestCase
 {
 
-    function data_html2text()
+    static function data_html2text()
     {
         return [
             0 => [
@@ -96,9 +99,10 @@ class rc_html2text extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_html2text
      */
+    #[DataProvider('data_html2text')]
     function test_html2text($title, $in, $out)
     {
-        $ht = new rcube_html2text(null, false, rcube_html2text::LINKS_NONE);
+        $ht = new \rcube_html2text(null, false, \rcube_html2text::LINKS_NONE);
 
         $ht->set_html($in);
         $res = $ht->get_text();
@@ -117,7 +121,7 @@ class rc_html2text extends PHPUnit\Framework\TestCase
 <div><br></div><div>Par 3</div><div><br></div>
 <blockquote>INNER 3</blockquote>OUTER END</blockquote>
 EOF;
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_NONE);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_NONE);
         $res = $ht->get_text();
 
         $this->assertStringContainsString('>> INNER 1', $res, 'Quote inner');
@@ -134,7 +138,7 @@ Begin<br>
 <blockquote>
 NO END TAG FOUND
 EOF;
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_NONE);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_NONE);
         $res = $ht->get_text();
 
         $this->assertStringContainsString('QUOTED TEXT NO END TAG FOUND', $res, 'No quoting on invalid html');
@@ -147,7 +151,7 @@ Begin<br>
 <blockquote>INNER 2</blockquote>
 NO END TAG FOUND
 EOF;
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_NONE);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_NONE);
         $res = $ht->get_text();
 
         $this->assertStringContainsString('QUOTED TEXT INNER 1 INNER 2 NO END', $res, 'No quoting on invalid html');
@@ -166,7 +170,7 @@ Links:
 [1] http://test.com
 ';
 
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_END);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_END);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links list');
@@ -175,7 +179,7 @@ Links:
         $html     = '<a href="http://test.com">http://test.com</a>';
         $expected = 'http://test.com';
 
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_END);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_END);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Skip link with href == content');
@@ -189,7 +193,7 @@ Links:
 [1] http://test.com?test1&test2
 ';
 
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_END);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_END);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links with HTML entities');
@@ -208,7 +212,7 @@ Links:
 [1] http://test.com
 ';
 
-        $ht = new rcube_html2text($html, false, true);
+        $ht = new \rcube_html2text($html, false, true);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links list');
@@ -217,7 +221,7 @@ Links:
         $html     = '<a href="http://test.com">http://test.com</a>';
         $expected = 'http://test.com';
 
-        $ht = new rcube_html2text($html, false, true);
+        $ht = new \rcube_html2text($html, false, true);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Skip link with href == content');
@@ -231,7 +235,7 @@ Links:
         $html     = '<a href="http://test.com">content</a>';
         $expected = 'content <http://test.com>';
 
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_INLINE);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_INLINE);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links Inline');
@@ -240,7 +244,7 @@ Links:
         $html     = '<a href="http://test.com">http://test.com</a>';
         $expected = 'http://test.com';
 
-        $ht = new rcube_html2text($html, false, rcube_html2text::LINKS_INLINE);
+        $ht = new \rcube_html2text($html, false, \rcube_html2text::LINKS_INLINE);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Skip link with href == content');
@@ -251,9 +255,10 @@ Links:
      *
      * @dataProvider data_links_no_list
      */
+    #[DataProvider('data_links_no_list')]
     function test_links_no_list($input, $output)
     {
-        $h2t = new rcube_html2text($input, false, rcube_html2text::LINKS_NONE);
+        $h2t = new \rcube_html2text($input, false, \rcube_html2text::LINKS_NONE);
         $res = $h2t->get_text();
 
         $this->assertSame($output, $res, 'Links handling');
@@ -264,15 +269,16 @@ Links:
      *
      * @dataProvider data_links_no_list
      */
+    #[DataProvider('data_links_no_list')]
     function test_links_no_list_bc_with_boolean($input, $output)
     {
-        $h2t = new rcube_html2text($input, false, false);
+        $h2t = new \rcube_html2text($input, false, false);
         $res = $h2t->get_text();
 
         $this->assertSame($output, $res, 'Links handling');
     }
 
-    function data_links_no_list()
+    static function data_links_no_list()
     {
         return [
             [
@@ -307,17 +313,17 @@ Links:
 [1] http://test.com
 ';
 
-        $ht = new rcube_html2text($html, false);
+        $ht = new \rcube_html2text($html, false);
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links list as default (doLinks not set)');
 
-        $ht = new rcube_html2text($html, false, mt_rand(3, 9999));
+        $ht = new \rcube_html2text($html, false, mt_rand(3, 9999));
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links list as default (doLinks greater than 3)');
 
-        $ht = new rcube_html2text($html, false, mt_rand(-9999, -1));
+        $ht = new \rcube_html2text($html, false, mt_rand(-9999, -1));
         $res = $ht->get_text();
 
         $this->assertSame($expected, $res, 'Links list as default (doLinks lower than 0)');
@@ -332,7 +338,7 @@ Links:
         $src = 'data:image/png;base64,' . str_repeat('1234567890abcdefghijklmnopqrstuvwxyz', 50000);
         $input = 'test<body><p>test1</p><p>test2</p><img src="' . $src . '" /><p>test3</p>';
 
-        $h2t = new rcube_html2text($input, false, rcube_html2text::LINKS_NONE);
+        $h2t = new \rcube_html2text($input, false, \rcube_html2text::LINKS_NONE);
         $res = $h2t->get_text();
 
         $this->assertSame("test1\n\ntest2\n\ntest3", $res, 'Huge input');
diff --git a/tests/Framework/HtmlCheckbox.php b/tests/Framework/HtmlCheckbox.php
index e8d5b39..c10fb6f 100644
--- a/tests/Framework/HtmlCheckbox.php
+++ b/tests/Framework/HtmlCheckbox.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test html_checkbox class
- *
- * @package Tests
  */
-class Framework_HtmlCheckbox extends PHPUnit\Framework\TestCase
+class Framework_HtmlCheckbox extends TestCase
 {
 
     /**
@@ -13,7 +15,7 @@ class Framework_HtmlCheckbox extends PHPUnit\Framework\TestCase
      */
     function test_checked_state()
     {
-        $input = new html_checkbox(['value' => 1]);
+        $input = new \html_checkbox(['value' => 1]);
 
         $this->assertSame('<input value="1" type="checkbox">', $input->show(0));
         $this->assertSame('<input value="1" type="checkbox">', $input->show('0'));
diff --git a/tests/Framework/Image.php b/tests/Framework/Image.php
index 90e03e6..9b89000 100644
--- a/tests/Framework/Image.php
+++ b/tests/Framework/Image.php
@@ -1,18 +1,20 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_image class
- *
- * @package Tests
  */
-class Framework_Image extends PHPUnit\Framework\TestCase
+class Framework_Image extends TestCase
 {
     /**
      * Test props() method
      */
     function test_props()
     {
-        $object = new rcube_image(INSTALL_PATH . 'skins/elastic/thumbnail.png');
+        $object = new \rcube_image(INSTALL_PATH . 'skins/elastic/thumbnail.png');
 
         if (!function_exists('getimagesize')) {
             $this->markTestSkipped();
@@ -30,17 +32,17 @@ class Framework_Image extends PHPUnit\Framework\TestCase
      */
     function test_resize()
     {
-        $object = new rcube_image(INSTALL_PATH . 'skins/elastic/thumbnail.png');
+        $object = new \rcube_image(INSTALL_PATH . 'skins/elastic/thumbnail.png');
 
         if (!function_exists('getimagesize')) {
             $this->markTestSkipped();
         }
 
-        $file = rcube_utils::temp_filename('tests');
+        $file = \rcube_utils::temp_filename('tests');
 
         $this->assertSame('png', $object->resize(32, $file));
 
-        $object = new rcube_image($file);
+        $object = new \rcube_image($file);
         $props  = $object->props();
 
         @unlink($file);
@@ -55,17 +57,17 @@ class Framework_Image extends PHPUnit\Framework\TestCase
      */
     function test_convert()
     {
-        $object = new rcube_image(INSTALL_PATH . 'skins/elastic/thumbnail.png');
+        $object = new \rcube_image(INSTALL_PATH . 'skins/elastic/thumbnail.png');
 
         if (!function_exists('getimagesize')) {
             $this->markTestSkipped();
         }
 
-        $file = rcube_utils::temp_filename('tests');
+        $file = \rcube_utils::temp_filename('tests');
 
-        $this->assertTrue($object->convert(rcube_image::TYPE_JPG, $file));
+        $this->assertTrue($object->convert(\rcube_image::TYPE_JPG, $file));
 
-        $object = new rcube_image($file);
+        $object = new \rcube_image($file);
         $props  = $object->props();
 
         @unlink($file);
diff --git a/tests/Framework/Imap.php b/tests/Framework/Imap.php
index 858f1c7..864558a 100644
--- a/tests/Framework/Imap.php
+++ b/tests/Framework/Imap.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\invokeMethod;
+
 /**
  * Test class to test rcube_imap class
- *
- * @package Tests
  */
-class Framework_Imap extends PHPUnit\Framework\TestCase
+class Framework_Imap extends TestCase
 {
 
     /**
@@ -13,9 +17,9 @@ class Framework_Imap extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_imap;
+        $object = new \rcube_imap();
 
-        $this->assertInstanceOf('rcube_imap', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_imap::class, $object, "Class constructor");
     }
 
     /**
@@ -25,17 +29,17 @@ class Framework_Imap extends PHPUnit\Framework\TestCase
     {
         $this->assertSame(
             "FLAGGED SINCE 1-Feb-1994 NOT FROM \"Smith\"",
-            rcube_imap::convert_criteria("FLAGGED SINCE 1-Feb-1994 NOT FROM \"Smith\"", RCUBE_CHARSET)
+            \rcube_imap::convert_criteria("FLAGGED SINCE 1-Feb-1994 NOT FROM \"Smith\"", RCUBE_CHARSET)
         );
 
         $this->assertSame(
             "ALL TEXT el",
-            rcube_imap::convert_criteria("ALL TEXT {4}\r\nżel", RCUBE_CHARSET)
+            \rcube_imap::convert_criteria("ALL TEXT {4}\r\nżel", RCUBE_CHARSET)
         );
 
         $this->assertSame(
             "ALL TEXT {4}\r\nżel",
-            rcube_imap::convert_criteria("ALL TEXT {4}\r\nżel", RCUBE_CHARSET, RCUBE_CHARSET)
+            \rcube_imap::convert_criteria("ALL TEXT {4}\r\nżel", RCUBE_CHARSET, RCUBE_CHARSET)
         );
     }
 
@@ -52,10 +56,10 @@ class Framework_Imap extends PHPUnit\Framework\TestCase
         ];
 
         foreach (['drafts', 'sent', 'junk', 'trash'] as $mbox) {
-            rcube::get_instance()->config->set("{$mbox}_mbox", ucfirst($mbox));
+            \rcube::get_instance()->config->set("{$mbox}_mbox", ucfirst($mbox));
         }
 
-        $object = new rcube_imap;
+        $object = new \rcube_imap();
 
         $result = $object->sort_folder_list([]);
         $this->assertSame([], $result);
@@ -118,9 +122,9 @@ class Framework_Imap extends PHPUnit\Framework\TestCase
                 . ' ( "MIXED" ("BOUNDARY" "=_0cc01990d46dea96cd7d692970fcbf82") NIL NIL) 1 NIL ("ATTACHMENT" ("FILENAME" "Test mail.eml")))'
             . ' "REPORT" ("BOUNDARY" "=_RrjQxjLYBqTMnoYWobuYlwN") NIL NIL)';
 
-        $structure = rcube_imap_generic::tokenizeResponse($str, 1);
+        $structure = \rcube_imap_generic::tokenizeResponse($str, 1);
 
-        $imap = new rcube_imap();
+        $imap = new \rcube_imap();
 
         $result = invokeMethod($imap, 'structure_part', [$structure]);
 
diff --git a/tests/Framework/ImapCache.php b/tests/Framework/ImapCache.php
index 074ebd2..178f383 100644
--- a/tests/Framework/ImapCache.php
+++ b/tests/Framework/ImapCache.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_imap_cache class
- *
- * @package Tests
  */
-class Framework_ImapCache extends PHPUnit\Framework\TestCase
+class Framework_ImapCache extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_ImapCache extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_imap_cache(new rcube_db('test'), null, null, null);
+        $object = new \rcube_imap_cache(new \rcube_db('test'), null, null, null);
 
-        $this->assertInstanceOf('rcube_imap_cache', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_imap_cache::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/ImapGeneric.php b/tests/Framework/ImapGeneric.php
index edef8ce..81abab2 100644
--- a/tests/Framework/ImapGeneric.php
+++ b/tests/Framework/ImapGeneric.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_imap_generic class
- *
- * @package Tests
  */
-class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
+class Framework_ImapGeneric extends TestCase
 {
 
     /**
@@ -13,9 +15,9 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_imap_generic;
+        $object = new \rcube_imap_generic();
 
-        $this->assertInstanceOf('rcube_imap_generic', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_imap_generic::class, $object, "Class constructor");
     }
 
     /**
@@ -23,12 +25,12 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
      */
     function test_escape()
     {
-        $this->assertSame('NIL', rcube_imap_generic::escape(null));
-        $this->assertSame('""', rcube_imap_generic::escape(''));
-        $this->assertSame('abc', rcube_imap_generic::escape('abc'));
-        $this->assertSame('"abc"', rcube_imap_generic::escape('abc', true));
-        $this->assertSame('"abc\"def"', rcube_imap_generic::escape('abc"def'));
-        $this->assertSame("{3}\r\na\nb", rcube_imap_generic::escape("a\nb"));
+        $this->assertSame('NIL', \rcube_imap_generic::escape(null));
+        $this->assertSame('""', \rcube_imap_generic::escape(''));
+        $this->assertSame('abc', \rcube_imap_generic::escape('abc'));
+        $this->assertSame('"abc"', \rcube_imap_generic::escape('abc', true));
+        $this->assertSame('"abc\"def"', \rcube_imap_generic::escape('abc"def'));
+        $this->assertSame("{3}\r\na\nb", \rcube_imap_generic::escape("a\nb"));
     }
 
     /**
@@ -37,27 +39,27 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
     function test_sortHeaders()
     {
         $headers = [
-            rcube_message_header::from_array([
+            \rcube_message_header::from_array([
                 'subject' => 'Test1',
                 'timestamp' => time() - 100,
             ]),
-            rcube_message_header::from_array([
+            \rcube_message_header::from_array([
                 'subject' => 'Re: Test2',
                 'timestamp' => time(),
             ]),
         ];
 
-        $result = rcube_imap_generic::sortHeaders($headers, 'subject');
+        $result = \rcube_imap_generic::sortHeaders($headers, 'subject');
 
         $this->assertSame('Test1', $result[0]->subject);
         $this->assertSame('Re: Test2', $result[1]->subject);
 
-        $result = rcube_imap_generic::sortHeaders($headers, 'subject', 'DESC');
+        $result = \rcube_imap_generic::sortHeaders($headers, 'subject', 'DESC');
 
         $this->assertSame('Re: Test2', $result[0]->subject);
         $this->assertSame('Test1', $result[1]->subject);
 
-        $result = rcube_imap_generic::sortHeaders($headers, 'date', 'DESC');
+        $result = \rcube_imap_generic::sortHeaders($headers, 'date', 'DESC');
 
         $this->assertSame('Re: Test2', $result[0]->subject);
         $this->assertSame('Test1', $result[1]->subject);
@@ -68,16 +70,16 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
      */
     function test_compressMessageSet()
     {
-        $result = rcube_imap_generic::compressMessageSet([5,4,3]);
+        $result = \rcube_imap_generic::compressMessageSet([5,4,3]);
         $this->assertSame('3:5', $result);
 
-        $result = rcube_imap_generic::compressMessageSet([5,4,3,10,12,13]);
+        $result = \rcube_imap_generic::compressMessageSet([5,4,3,10,12,13]);
         $this->assertSame('3:5,10,12:13', $result);
 
-        $result = rcube_imap_generic::compressMessageSet('1');
+        $result = \rcube_imap_generic::compressMessageSet('1');
         $this->assertSame('1', $result);
 
-        $result = rcube_imap_generic::compressMessageSet('-1');
+        $result = \rcube_imap_generic::compressMessageSet('-1');
         $this->assertSame('INVALID', $result);
     }
 
@@ -86,15 +88,15 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
      */
     function test_uncompressMessageSet()
     {
-        $result = rcube_imap_generic::uncompressMessageSet(null);
+        $result = \rcube_imap_generic::uncompressMessageSet(null);
         $this->assertSame([], $result);
         $this->assertCount(0, $result);
 
-        $result = rcube_imap_generic::uncompressMessageSet('1');
+        $result = \rcube_imap_generic::uncompressMessageSet('1');
         $this->assertSame([1], $result);
         $this->assertCount(1, $result);
 
-        $result = rcube_imap_generic::uncompressMessageSet('1:3');
+        $result = \rcube_imap_generic::uncompressMessageSet('1:3');
         $this->assertSame([1, 2, 3], $result);
         $this->assertCount(3, $result);
     }
@@ -106,19 +108,19 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
     {
         $response = "test brack[et] {1}\r\na {0}\r\n (item1 item2)";
 
-        $result = rcube_imap_generic::tokenizeResponse($response, 1);
+        $result = \rcube_imap_generic::tokenizeResponse($response, 1);
         $this->assertSame("test", $result);
 
-        $result = rcube_imap_generic::tokenizeResponse($response, 1);
+        $result = \rcube_imap_generic::tokenizeResponse($response, 1);
         $this->assertSame("brack[et]", $result);
 
-        $result = rcube_imap_generic::tokenizeResponse($response, 1);
+        $result = \rcube_imap_generic::tokenizeResponse($response, 1);
         $this->assertSame("a", $result);
 
-        $result = rcube_imap_generic::tokenizeResponse($response, 1);
+        $result = \rcube_imap_generic::tokenizeResponse($response, 1);
         $this->assertSame("", $result);
 
-        $result = rcube_imap_generic::tokenizeResponse($response, 1);
+        $result = \rcube_imap_generic::tokenizeResponse($response, 1);
         $this->assertSame(['item1', 'item2'], $result);
     }
 
@@ -222,7 +224,7 @@ class Framework_ImapGeneric extends PHPUnit\Framework\TestCase
      */
     function runDecodeContent($expected, $encoded, $mode, $size = null, $formatted = false)
     {
-        $method = new ReflectionMethod('rcube_imap_generic', 'decodeContent');
+        $method = new \ReflectionMethod('rcube_imap_generic', 'decodeContent');
         $method->setAccessible(true);
 
         // Make sure the method works with any chunk size
diff --git a/tests/Framework/ImapSearch.php b/tests/Framework/ImapSearch.php
index 458fefc..c335fb8 100644
--- a/tests/Framework/ImapSearch.php
+++ b/tests/Framework/ImapSearch.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_imap_search class
- *
- * @package Tests
  */
-class Framework_ImapSearch extends PHPUnit\Framework\TestCase
+class Framework_ImapSearch extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_ImapSearch extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_imap_search([], true);
+        $object = new \rcube_imap_search([], true);
 
-        $this->assertInstanceOf('rcube_imap_search', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_imap_search::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/Ldap.php b/tests/Framework/Ldap.php
index 5034a83..f4127e1 100644
--- a/tests/Framework/Ldap.php
+++ b/tests/Framework/Ldap.php
@@ -1,11 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+use Roundcube\Tests\StderrMock;
+
 /**
  * Test class to test rcube_ldap class
- *
- * @package Tests
  */
-class Framework_Ldap extends PHPUnit\Framework\TestCase
+class Framework_Ldap extends TestCase
 {
 
     /**
@@ -23,11 +26,11 @@ class Framework_Ldap extends PHPUnit\Framework\TestCase
             $this->markTestSkipped('The ldap extension is not available.');
         }
 
-        StdErrMock::start();
-        $object = new rcube_ldap([]);
-        StdErrMock::stop();
+        StderrMock::start();
+        $object = new \rcube_ldap([]);
+        StderrMock::stop();
 
-        $this->assertInstanceOf('rcube_ldap', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_ldap::class, $object, "Class constructor");
         $this->assertSame('ERROR: Could not connect to any LDAP server', trim(StderrMock::$output));
     }
 }
diff --git a/tests/Framework/LdapGeneric.php b/tests/Framework/LdapGeneric.php
index fee5929..f57d728 100644
--- a/tests/Framework/LdapGeneric.php
+++ b/tests/Framework/LdapGeneric.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_ldap_generic class
- *
- * @package Tests
  */
-class Framework_LdapGeneric extends PHPUnit\Framework\TestCase
+class Framework_LdapGeneric extends TestCase
 {
     /**
      * Class constructor
@@ -17,9 +19,9 @@ class Framework_LdapGeneric extends PHPUnit\Framework\TestCase
             $this->markTestSkipped('The Net_LDAP3 package not available.');
         }
 
-        $object = new rcube_ldap_generic([]);
+        $object = new \rcube_ldap_generic([]);
 
-        $this->assertInstanceOf('rcube_ldap_generic', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_ldap_generic::class, $object, "Class constructor");
     }
 
     /**
@@ -27,7 +29,7 @@ class Framework_LdapGeneric extends PHPUnit\Framework\TestCase
      */
     function test_fulltext_search_filter()
     {
-        $object = new rcube_ldap_generic([]);
+        $object = new \rcube_ldap_generic([]);
 
         $result = $object->fulltext_search_filter('test', ['dn']);
 
diff --git a/tests/Framework/Message.php b/tests/Framework/Message.php
index 3e40e93..50607b7 100644
--- a/tests/Framework/Message.php
+++ b/tests/Framework/Message.php
@@ -1,20 +1,22 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_message class
- *
- * @package Tests
  */
-class Framework_Message extends PHPUnit\Framework\TestCase
+class Framework_Message extends TestCase
 {
     /**
      * Test format_part_body() method
      */
     function test_format_part_body()
     {
-        $part   = new rcube_message_part();
+        $part   = new \rcube_message_part();
         $body   = 'test';
-        $result = rcube_message::format_part_body($body, $part);
+        $result = \rcube_message::format_part_body($body, $part);
 
         $this->assertSame('test', $result);
     }
@@ -25,7 +27,7 @@ class Framework_Message extends PHPUnit\Framework\TestCase
     public function test_tnef_decode()
     {
         $message = new rcube_message_test(123);
-        $part = new rcube_message_part();
+        $part = new \rcube_message_part();
         $part->mime_id = 1;
 
         $message->set_part_body(1, '');
@@ -37,7 +39,7 @@ class Framework_Message extends PHPUnit\Framework\TestCase
         $result = $message->tnef_decode($part);
 
         $this->assertCount(1, $result);
-        $this->assertInstanceOf('rcube_message_part', $result[0]);
+        $this->assertInstanceOf(\rcube_message_part::class, $result[0]);
         $this->assertSame('winmail.1.html', $result[0]->mime_id);
         $this->assertSame('text/html', $result[0]->mimetype);
         $this->assertSame(5360, $result[0]->size);
@@ -48,7 +50,7 @@ class Framework_Message extends PHPUnit\Framework\TestCase
         $result = $message->tnef_decode($part);
 
         $this->assertCount(1, $result);
-        $this->assertInstanceOf('rcube_message_part', $result[0]);
+        $this->assertInstanceOf(\rcube_message_part::class, $result[0]);
         $this->assertSame('winmail.1.0', $result[0]->mime_id);
         $this->assertSame('application/octet-stream', $result[0]->mimetype);
         $this->assertSame(244, $result[0]->size);
@@ -62,7 +64,7 @@ class Framework_Message extends PHPUnit\Framework\TestCase
     public function test_uu_decode()
     {
         $message = new rcube_message_test(123);
-        $part = new rcube_message_part();
+        $part = new \rcube_message_part();
         $part->mime_id = 1;
 
         $message->set_part_body(1, '');
@@ -76,7 +78,7 @@ class Framework_Message extends PHPUnit\Framework\TestCase
         $result = $message->uu_decode($part);
 
         $this->assertCount(1, $result);
-        $this->assertInstanceOf('rcube_message_part', $result[0]);
+        $this->assertInstanceOf(\rcube_message_part::class, $result[0]);
         $this->assertSame('uu.1.0', $result[0]->mime_id);
         $this->assertSame('text/plain', $result[0]->mimetype);
         $this->assertSame(4, $result[0]->size);
@@ -88,7 +90,7 @@ class Framework_Message extends PHPUnit\Framework\TestCase
 /**
  * rcube_message wrapper for easier testing (without accessing IMAP)
  */
-class rcube_message_test extends rcube_message
+class rcube_message_test extends \rcube_message
 {
     private $part_bodies = [];
 
diff --git a/tests/Framework/MessageHeader.php b/tests/Framework/MessageHeader.php
index 8ba0ab2..f8785a5 100644
--- a/tests/Framework/MessageHeader.php
+++ b/tests/Framework/MessageHeader.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_message_header class
- *
- * @package Tests
  */
-class Framework_MessageHeader extends PHPUnit\Framework\TestCase
+class Framework_MessageHeader extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_MessageHeader extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_message_header;
+        $object = new \rcube_message_header();
 
-        $this->assertInstanceOf('rcube_message_header', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_message_header::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/MessagePart.php b/tests/Framework/MessagePart.php
index dc3cc75..6b68036 100644
--- a/tests/Framework/MessagePart.php
+++ b/tests/Framework/MessagePart.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_message_part class
- *
- * @package Tests
  */
-class Framework_MessagePart extends PHPUnit\Framework\TestCase
+class Framework_MessagePart extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_MessagePart extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_message_part;
+        $object = new \rcube_message_part();
 
-        $this->assertInstanceOf('rcube_message_part', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_message_part::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php
index abe9939..81d42f0 100644
--- a/tests/Framework/Mime.php
+++ b/tests/Framework/Mime.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_mime class
- *
- * @package Tests
  */
-class Framework_Mime extends PHPUnit\Framework\TestCase
+class Framework_Mime extends TestCase
 {
 
     /**
@@ -84,7 +86,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($headers as $idx => $header) {
-            $res = rcube_mime::decode_address_list($header);
+            $res = \rcube_mime::decode_address_list($header);
 
             $this->assertEquals($results[$idx][0], count($res), "Rows number in result for header: " . $header);
             $this->assertEquals($results[$idx][1], $res[1]['name'], "Name part decoding for header: " . $header);
@@ -129,7 +131,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
         // Note: For now we expect group names ignored, and members handled as independent addresses
 
         foreach ($headers as $idx => $header) {
-            $res = rcube_mime::decode_address_list($header);
+            $res = \rcube_mime::decode_address_list($header);
 
             $this->assertEquals($results[$idx], $res, "Decode address groups (#$idx)");
         }
@@ -174,7 +176,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $idx => $item) {
-            $res = rcube_mime::decode_mime_string($item['in'], 'UTF-8');
+            $res = \rcube_mime::decode_mime_string($item['in'], 'UTF-8');
             $res = quoted_printable_encode($res);
 
             $this->assertEquals($item['out'], $res, "Header decoding for: " . $idx);
@@ -186,7 +188,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
      */
     function test_parse_headers()
     {
-        $this->assertEquals([], rcube_mime::parse_headers(''));
+        $this->assertEquals([], \rcube_mime::parse_headers(''));
 
 
         $headers = "Subject: Test\r\n"
@@ -197,7 +199,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
             'to' => 'test@test1.com test@test2.com'
         ];
 
-        $this->assertEquals($expected, rcube_mime::parse_headers($headers));
+        $this->assertEquals($expected, \rcube_mime::parse_headers($headers));
     }
 
     /**
@@ -208,7 +210,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
         $raw = file_get_contents(TESTS_DIR . 'src/format-flowed-unfolded.txt');
         $flowed = file_get_contents(TESTS_DIR . 'src/format-flowed.txt');
 
-        $this->assertEquals($flowed, rcube_mime::format_flowed($raw, 80), "Test correct folding and space-stuffing");
+        $this->assertEquals($flowed, \rcube_mime::format_flowed($raw, 80), "Test correct folding and space-stuffing");
     }
 
     /**
@@ -219,7 +221,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
         $flowed = file_get_contents(TESTS_DIR . 'src/format-flowed.txt');
         $unfolded = file_get_contents(TESTS_DIR . 'src/format-flowed-unfolded.txt');
 
-        $this->assertEquals($unfolded, rcube_mime::unfold_flowed($flowed), "Test correct unfolding of quoted lines");
+        $this->assertEquals($unfolded, \rcube_mime::unfold_flowed($flowed), "Test correct unfolding of quoted lines");
     }
 
     /**
@@ -234,7 +236,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
                     ."> \r\n"
                     ."Sed ut perspiciatis unde omnis iste natus error sit voluptatem";
 
-        $this->assertEquals($unfolded, rcube_mime::unfold_flowed($flowed), "Test correct unfolding of quoted lines [2]");
+        $this->assertEquals($unfolded, \rcube_mime::unfold_flowed($flowed), "Test correct unfolding of quoted lines [2]");
     }
 
     /**
@@ -248,7 +250,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
                     ."しているのを見ました。";
         $unfolded = "そしてジョバンニはすぐうしろの天気輪の柱がいつかぼんやりした三角標の形になって、しばらく蛍のように、ぺかぺか消えたりともったりしているのを見ました。";
 
-        $this->assertEquals($unfolded, rcube_mime::unfold_flowed($flowed, null, true), "Test correct unfolding of flowed DelSp=Yes lines");
+        $this->assertEquals($unfolded, \rcube_mime::unfold_flowed($flowed, null, true), "Test correct unfolding of flowed DelSp=Yes lines");
     }
 
     /**
@@ -306,8 +308,8 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
                 "this-is-just-some-blabla-to-make-this-more-than-seventy-five-characters-in-a-row\n-- this line should\nbe wrapped",
             ],
             [
-                [rcube_charset::convert("㈱山﨑工業", 'UTF-8', 'ISO-2022-JP'), 1, "\n", true, 'ISO-2022-JP'],
-                rcube_charset::convert("㈱\n山\n﨑\n工\n業", 'UTF-8', 'ISO-2022-JP'),
+                [\rcube_charset::convert("㈱山﨑工業", 'UTF-8', 'ISO-2022-JP'), 1, "\n", true, 'ISO-2022-JP'],
+                \rcube_charset::convert("㈱\n山\n﨑\n工\n業", 'UTF-8', 'ISO-2022-JP'),
             ],
         ];
 
@@ -322,9 +324,9 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
     function test_parse_message()
     {
         $file   = file_get_contents(__DIR__ . '/../src/html.msg');
-        $result = rcube_mime::parse_message($file);
+        $result = \rcube_mime::parse_message($file);
 
-        $this->assertInstanceOf('rcube_message_part', $result);
+        $this->assertInstanceOf(\rcube_message_part::class, $result);
         $this->assertSame('multipart/alternative', $result->mimetype);
         $this->assertSame('1.0', $result->headers['mime-version']);
         $this->assertSame('=_68eeaf4ab95b5312965e45c33362338e', $result->ctype_parameters['boundary']);
@@ -355,9 +357,9 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
     function test_file_content_type()
     {
         $file = INSTALL_PATH . 'program/resources/blocked.gif';
-        $this->assertSame('image/gif', rcube_mime::file_content_type($file, 'blocked.gif'));
+        $this->assertSame('image/gif', \rcube_mime::file_content_type($file, 'blocked.gif'));
 
-        $this->assertSame('image/gif', rcube_mime::file_content_type($file, 'blocked.gif', 'application/octet-stream', false, true));
+        $this->assertSame('image/gif', \rcube_mime::file_content_type($file, 'blocked.gif', 'application/octet-stream', false, true));
     }
 
     /**
@@ -365,10 +367,10 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
      */
     function test_get_mime_extensions()
     {
-        $this->assertSame([], rcube_mime::get_mime_extensions('unknown'));
-        $this->assertSame(['gif'], rcube_mime::get_mime_extensions('image/gif'));
-        $this->assertSame(['pdf'], rcube_mime::get_mime_extensions('application/pdf'));
-        $this->assertSame(['jpg', 'jpeg', 'jpe'], rcube_mime::get_mime_extensions('image/jpg'));
+        $this->assertSame([], \rcube_mime::get_mime_extensions('unknown'));
+        $this->assertSame(['gif'], \rcube_mime::get_mime_extensions('image/gif'));
+        $this->assertSame(['pdf'], \rcube_mime::get_mime_extensions('application/pdf'));
+        $this->assertSame(['jpg', 'jpeg', 'jpe'], \rcube_mime::get_mime_extensions('image/jpg'));
     }
 
     /**
@@ -377,7 +379,7 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
     function test_image_content_type()
     {
         $file = file_get_contents(INSTALL_PATH . 'program/resources/blocked.gif');
-        $this->assertSame('image/gif', rcube_mime::image_content_type($file));
+        $this->assertSame('image/gif', \rcube_mime::image_content_type($file));
     }
 
     /**
@@ -385,9 +387,9 @@ class Framework_Mime extends PHPUnit\Framework\TestCase
      */
     function test_fix_mimetype()
     {
-        $this->assertSame('unknown', rcube_mime::fix_mimetype('unknown'));
-        $this->assertSame('application/pdf', rcube_mime::fix_mimetype('pdf'));
-        $this->assertSame('application/pdf', rcube_mime::fix_mimetype('application/pdf.123'));
-        $this->assertSame('image/jpeg', rcube_mime::fix_mimetype('image/pjpeg'));
+        $this->assertSame('unknown', \rcube_mime::fix_mimetype('unknown'));
+        $this->assertSame('application/pdf', \rcube_mime::fix_mimetype('pdf'));
+        $this->assertSame('application/pdf', \rcube_mime::fix_mimetype('application/pdf.123'));
+        $this->assertSame('image/jpeg', \rcube_mime::fix_mimetype('image/pjpeg'));
     }
 }
diff --git a/tests/Framework/MimeDecode.php b/tests/Framework/MimeDecode.php
index 7ffe52e..8acb723 100644
--- a/tests/Framework/MimeDecode.php
+++ b/tests/Framework/MimeDecode.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_mime_decode class
- *
- * @package Tests
  */
-class Framework_MimeDecode extends PHPUnit\Framework\TestCase
+class Framework_MimeDecode extends TestCase
 {
     /**
      * Test mail decode
@@ -14,11 +16,11 @@ class Framework_MimeDecode extends PHPUnit\Framework\TestCase
     {
         $mail = file_get_contents(TESTS_DIR . 'src/mail0.eml');
 
-        $decoder = new rcube_mime_decode();
+        $decoder = new \rcube_mime_decode();
 
         $result = $decoder->decode($mail);
 
-        $this->assertInstanceOf('rcube_message_part', $result);
+        $this->assertInstanceOf(\rcube_message_part::class, $result);
         $this->assertSame('multipart/mixed', $result->mimetype);
         $this->assertSame('=_8853bfb47b7da1852ac882e69cc724f3', $result->ctype_parameters['boundary']);
         $this->assertSame('8bit', $result->encoding);
diff --git a/tests/Framework/Output.php b/tests/Framework/Output.php
index f90e93d..fc3a6c5 100644
--- a/tests/Framework/Output.php
+++ b/tests/Framework/Output.php
@@ -1,41 +1,43 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_output class
- *
- * @package Tests
  */
-class Framework_Output extends PHPUnit\Framework\TestCase
+class Framework_Output extends TestCase
 {
     /**
      * Test get_edit_field()
      */
     function test_get_edit_field()
     {
-        $out = rcube_output::get_edit_field('test', 'value');
+        $out = \rcube_output::get_edit_field('test', 'value');
 
         $this->assertSame('<input name="_test" class="ff_test" type="text" value="value">', $out);
 
         $_POST['_test'] = 'testv';
-        $out = rcube_output::get_edit_field('test', 'value');
+        $out = \rcube_output::get_edit_field('test', 'value');
 
         $this->assertSame('<input name="_test" class="ff_test" type="text" value="testv">', $out);
 
-        $out = rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'checkbox');
+        $out = \rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'checkbox');
 
         $this->assertSame('<input class="a ff_test" name="_test" value="1" type="checkbox">', $out);
 
-        $out = rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'textarea');
+        $out = \rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'textarea');
 
         $this->assertSame('<textarea class="a ff_test" name="_test">testv</textarea>', $out);
 
-        $out = rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'select');
+        $out = \rcube_output::get_edit_field('test', 'value', ['class' => 'a'], 'select');
 
         $this->assertSame('<select class="a ff_test" name="_test">' . "\n" . '<option value="">---</option></select>', $out);
 
         $_POST['_test'] = 'tt';
         $attr = ['options' => ['tt' => 'oo']];
-        $out  = rcube_output::get_edit_field('test', 'value', $attr, 'select');
+        $out  = \rcube_output::get_edit_field('test', 'value', $attr, 'select');
 
         $this->assertSame('<select name="_test" class="ff_test">' . "\n"
             . '<option value="">---</option><option value="tt" selected="selected">oo</option></select>',
@@ -48,12 +50,12 @@ class Framework_Output extends PHPUnit\Framework\TestCase
      */
     function test_json_serialize()
     {
-        $this->assertSame('""', rcube_output::json_serialize(''));
-        $this->assertSame('[]', rcube_output::json_serialize([]));
-        $this->assertSame('10', rcube_output::json_serialize(10));
-        $this->assertSame('{"test":"test"}', rcube_output::json_serialize(['test' => 'test']));
+        $this->assertSame('""', \rcube_output::json_serialize(''));
+        $this->assertSame('[]', \rcube_output::json_serialize([]));
+        $this->assertSame('10', \rcube_output::json_serialize(10));
+        $this->assertSame('{"test":"test"}', \rcube_output::json_serialize(['test' => 'test']));
 
         // Test non-utf-8 input
-        $this->assertSame('{"ab":"ab"}', rcube_output::json_serialize(["a\x8cb" => "a\x8cb"]));
+        $this->assertSame('{"ab":"ab"}', \rcube_output::json_serialize(["a\x8cb" => "a\x8cb"]));
     }
 }
diff --git a/tests/Framework/PluginApi.php b/tests/Framework/PluginApi.php
index 99bd712..03dd738 100644
--- a/tests/Framework/PluginApi.php
+++ b/tests/Framework/PluginApi.php
@@ -1,18 +1,20 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_plugin_api class
- *
- * @package Tests
  */
-class Framework_PluginApi extends PHPUnit\Framework\TestCase
+class Framework_PluginApi extends TestCase
 {
     /**
      * Test get_info()
      */
     function test_get_info()
     {
-        $api = rcube_plugin_api::get_instance();
+        $api = \rcube_plugin_api::get_instance();
 
         $info = $api->get_info('acl');
 
@@ -27,7 +29,7 @@ class Framework_PluginApi extends PHPUnit\Framework\TestCase
      */
     function test_hooks()
     {
-        $api = rcube_plugin_api::get_instance();
+        $api = \rcube_plugin_api::get_instance();
 
         $var = 0;
         $hook_handler = function($args) use (&$var) { $var++; };
@@ -51,7 +53,7 @@ class Framework_PluginApi extends PHPUnit\Framework\TestCase
      */
     function test_tasks()
     {
-        $api = rcube_plugin_api::get_instance();
+        $api = \rcube_plugin_api::get_instance();
 
         $this->assertTrue($api->register_task('test', 'test'));
         $this->assertTrue($api->is_plugin_task('test'));
diff --git a/tests/Framework/Rcube.php b/tests/Framework/Rcube.php
index fa6933f..b845b21 100644
--- a/tests/Framework/Rcube.php
+++ b/tests/Framework/Rcube.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube class
- *
- * @package Tests
  */
-class Framework_Rcube extends PHPUnit\Framework\TestCase
+class Framework_Rcube extends TestCase
 {
 
     /**
@@ -13,9 +15,9 @@ class Framework_Rcube extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = rcube::get_instance();
+        $object = \rcube::get_instance();
 
-        $this->assertInstanceOf('rcube', $object, "Class singleton");
+        $this->assertInstanceOf(\rcube::class, $object, "Class singleton");
     }
 
     /**
@@ -23,7 +25,7 @@ class Framework_Rcube extends PHPUnit\Framework\TestCase
      */
     function test_read_localization()
     {
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
         $result = $rcube->read_localization(INSTALL_PATH . 'plugins/acl/localization', 'pl_PL');
 
         $this->assertSame('Zapis', $result['aclwrite']);
@@ -34,7 +36,7 @@ class Framework_Rcube extends PHPUnit\Framework\TestCase
      */
     function test_list_languages()
     {
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
         $result = $rcube->list_languages();
 
         $this->assertSame('English (US)', $result['en_US']);
@@ -45,7 +47,7 @@ class Framework_Rcube extends PHPUnit\Framework\TestCase
      */
     function test_encrypt_and_decrypt()
     {
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
 
         $result = $rcube->decrypt($rcube->encrypt('test'));
         $this->assertSame('test', $result);
diff --git a/tests/Framework/ResultIndex.php b/tests/Framework/ResultIndex.php
index 0807a53..57bed83 100644
--- a/tests/Framework/ResultIndex.php
+++ b/tests/Framework/ResultIndex.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_result_index class
- *
- * @package Tests
  */
-class Framework_ResultIndex extends PHPUnit\Framework\TestCase
+class Framework_ResultIndex extends TestCase
 {
 
     /**
@@ -13,9 +15,9 @@ class Framework_ResultIndex extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_result_index;
+        $object = new \rcube_result_index();
 
-        $this->assertInstanceOf('rcube_result_index', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_result_index::class, $object, "Class constructor");
     }
 
     /**
@@ -24,7 +26,7 @@ class Framework_ResultIndex extends PHPUnit\Framework\TestCase
     function test_parse_sort()
     {
         $text = "* SORT 2001 2002 2035 2036 2037 2038 2044 2046 2043 2045 2226 2225 2224 2223";
-        $object = new rcube_result_index('INBOX', $text);
+        $object = new \rcube_result_index('INBOX', $text);
 
         $this->assertSame(false, $object->is_empty(), "Object is empty");
         $this->assertSame(false, $object->is_error(), "Object is error");
@@ -70,7 +72,7 @@ class Framework_ResultIndex extends PHPUnit\Framework\TestCase
     function test_parse_esearch()
     {
         $text = "* ESEARCH (TAG \"A282\") MIN 2 COUNT 3 ALL 2,10:11";
-        $object = new rcube_result_index('INBOX', $text);
+        $object = new \rcube_result_index('INBOX', $text);
 
         $this->assertSame(false, $object->is_empty(), "Object is empty");
         $this->assertSame(false, $object->is_error(), "Object is error");
@@ -88,7 +90,7 @@ class Framework_ResultIndex extends PHPUnit\Framework\TestCase
 
         // A case without 'ALL' response
         $text = "* ESEARCH (TAG \"A282\") UID MAX 721 COUNT 3";
-        $object = new rcube_result_index('INBOX', $text);
+        $object = new \rcube_result_index('INBOX', $text);
 
         $this->assertSame(false, $object->is_empty(), "Object is empty");
         $this->assertSame(false, $object->is_error(), "Object is error");
@@ -110,7 +112,7 @@ class Framework_ResultIndex extends PHPUnit\Framework\TestCase
      */
     function test_parse_empty()
     {
-        $object = new rcube_result_index('INBOX', "* SORT");
+        $object = new \rcube_result_index('INBOX', "* SORT");
 
         $this->assertSame(true, $object->is_empty(), "Object is empty");
         $this->assertSame(false, $object->is_error(), "Object is error");
diff --git a/tests/Framework/ResultMultifolder.php b/tests/Framework/ResultMultifolder.php
index b7045d5..559fe76 100644
--- a/tests/Framework/ResultMultifolder.php
+++ b/tests/Framework/ResultMultifolder.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_result_multifolder class
- *
- * @package Tests
  */
-class Framework_ResultMultifolder extends PHPUnit\Framework\TestCase
+class Framework_ResultMultifolder extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_ResultMultifolder extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_result_multifolder;
+        $object = new \rcube_result_multifolder();
 
-        $this->assertInstanceOf('rcube_result_multifolder', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_result_multifolder::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/ResultSet.php b/tests/Framework/ResultSet.php
index 886c017..04fefdd 100644
--- a/tests/Framework/ResultSet.php
+++ b/tests/Framework/ResultSet.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_result_set class
- *
- * @package Tests
  */
-class Framework_ResultSet extends PHPUnit\Framework\TestCase
+class Framework_ResultSet extends TestCase
 {
 
     /**
@@ -13,8 +15,8 @@ class Framework_ResultSet extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_result_set;
+        $object = new \rcube_result_set();
 
-        $this->assertInstanceOf('rcube_result_set', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_result_set::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/ResultThread.php b/tests/Framework/ResultThread.php
index f290545..9513a73 100644
--- a/tests/Framework/ResultThread.php
+++ b/tests/Framework/ResultThread.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_result_thread class
- *
- * @package Tests
  */
-class Framework_ResultThread extends PHPUnit\Framework\TestCase
+class Framework_ResultThread extends TestCase
 {
 
     /**
@@ -13,9 +15,9 @@ class Framework_ResultThread extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_result_thread;
+        $object = new \rcube_result_thread();
 
-        $this->assertInstanceOf('rcube_result_thread', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_result_thread::class, $object, "Class constructor");
     }
 
     /**
@@ -24,7 +26,7 @@ class Framework_ResultThread extends PHPUnit\Framework\TestCase
     function test_parse_thread()
     {
         $text   = file_get_contents(__DIR__ . '/../src/imap_thread.txt');
-        $object = new rcube_result_thread('INBOX', $text);
+        $object = new \rcube_result_thread('INBOX', $text);
 
         $this->assertSame(false, $object->is_empty(), "Object is empty");
         $this->assertSame(false, $object->is_error(), "Object is error");
@@ -96,7 +98,7 @@ class Framework_ResultThread extends PHPUnit\Framework\TestCase
      */
     function test_parse_empty()
     {
-        $object = new rcube_result_thread('INBOX', "* THREAD");
+        $object = new \rcube_result_thread('INBOX', "* THREAD");
 
         $this->assertSame(true, $object->is_empty(), "Object is empty");
         $this->assertSame(false, $object->is_error(), "Object is error");
diff --git a/tests/Framework/Session.php b/tests/Framework/Session.php
index 6df2d4e..f1392f4 100644
--- a/tests/Framework/Session.php
+++ b/tests/Framework/Session.php
@@ -1,26 +1,28 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_session class
- *
- * @package Tests
  */
-class Framework_Session extends PHPUnit\Framework\TestCase
+class Framework_Session extends TestCase
 {
     /**
      * Test factory method
      */
     function test_factory()
     {
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
 
         // We cannot test DB session handler as it's initialization
         // will collide with already sent headers. Let's try php session.
         $rcube->config->set('session_storage', 'php');
 
-        $session = rcube_session::factory($rcube->config);
+        $session = \rcube_session::factory($rcube->config);
 
-        $this->assertInstanceOf('rcube_session_php', $session);
+        $this->assertInstanceOf(\rcube_session_php::class, $session);
 
         // This method should not do any harm, just call it and expect no errors
         $session->reload();
@@ -31,11 +33,11 @@ class Framework_Session extends PHPUnit\Framework\TestCase
      */
     function test_unserialize()
     {
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
 
         $rcube->config->set('session_storage', 'php');
 
-        $session = rcube_session::factory($rcube->config);
+        $session = \rcube_session::factory($rcube->config);
 
         $this->assertSame([], $session->unserialize(''));
         $this->assertSame(
diff --git a/tests/Framework/Smtp.php b/tests/Framework/Smtp.php
index cd19a7d..0cc7926 100644
--- a/tests/Framework/Smtp.php
+++ b/tests/Framework/Smtp.php
@@ -1,20 +1,24 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\invokeMethod;
+
 /**
  * Test class to test rcube_smtp class
- *
- * @package Tests
  */
-class Framework_Smtp extends PHPUnit\Framework\TestCase
+class Framework_Smtp extends TestCase
 {
     /**
      * Class constructor
      */
     function test_class()
     {
-        $object = new rcube_smtp;
+        $object = new \rcube_smtp();
 
-        $this->assertInstanceOf('rcube_smtp', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_smtp::class, $object, "Class constructor");
     }
 
     /**
@@ -22,7 +26,7 @@ class Framework_Smtp extends PHPUnit\Framework\TestCase
      */
     function test_prepare_headers()
     {
-        $smtp = new rcube_smtp;
+        $smtp = new \rcube_smtp();
 
         $headers = [
             'Subject' => 'Test',
@@ -49,7 +53,7 @@ class Framework_Smtp extends PHPUnit\Framework\TestCase
      */
     function test_parse_rfc822()
     {
-        $smtp   = new rcube_smtp;
+        $smtp   = new \rcube_smtp();
         $input  = 'test@test1.com, "test" <test@test2.pl>, "test@test3.eu" <test@test3.uk>';
         $result = invokeMethod($smtp, '_parse_rfc822', [$input]);
 
diff --git a/tests/Framework/Spellchecker.php b/tests/Framework/Spellchecker.php
index 0a023a6..99a284e 100644
--- a/tests/Framework/Spellchecker.php
+++ b/tests/Framework/Spellchecker.php
@@ -1,18 +1,20 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_spellchecker class
- *
- * @package Tests
  */
-class Framework_Spellchecker extends PHPUnit\Framework\TestCase
+class Framework_Spellchecker extends TestCase
 {
     /**
      * Test is_exception() method
      */
     function test_is_exception()
     {
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $this->assertFalse($object->is_exception('test'));
 
diff --git a/tests/Framework/SpellcheckerAtd.php b/tests/Framework/SpellcheckerAtd.php
index eb8f123..862f909 100644
--- a/tests/Framework/SpellcheckerAtd.php
+++ b/tests/Framework/SpellcheckerAtd.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_spellcheck_atd class
- *
- * @package Tests
  */
-class Framework_SpellcheckerAtd extends PHPUnit\Framework\TestCase
+class Framework_SpellcheckerAtd extends TestCase
 {
 
     /**
@@ -13,9 +15,9 @@ class Framework_SpellcheckerAtd extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_spellchecker_atd(null, 'en');
+        $object = new \rcube_spellchecker_atd(null, 'en');
 
-        $this->assertInstanceOf('rcube_spellchecker_atd', $object, "Class constructor");
-        $this->assertInstanceOf('rcube_spellchecker_engine', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_atd::class, $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_engine::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/SpellcheckerEnchant.php b/tests/Framework/SpellcheckerEnchant.php
index 4ab5295..82086f6 100644
--- a/tests/Framework/SpellcheckerEnchant.php
+++ b/tests/Framework/SpellcheckerEnchant.php
@@ -1,21 +1,23 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_spellcheck_enchant class
- *
- * @package Tests
  */
-class Framework_SpellcheckerEnchant extends PHPUnit\Framework\TestCase
+class Framework_SpellcheckerEnchant extends TestCase
 {
     /**
      * Class constructor
      */
     function test_class()
     {
-        $object = new rcube_spellchecker_enchant(null, 'en');
+        $object = new \rcube_spellchecker_enchant(null, 'en');
 
-        $this->assertInstanceOf('rcube_spellchecker_enchant', $object, "Class constructor");
-        $this->assertInstanceOf('rcube_spellchecker_engine', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_enchant::class, $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_engine::class, $object, "Class constructor");
     }
 
     /**
@@ -27,9 +29,9 @@ class Framework_SpellcheckerEnchant extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $langs = $object->languages();
 
@@ -45,9 +47,9 @@ class Framework_SpellcheckerEnchant extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $this->assertTrue($object->check('one'));
 
@@ -95,9 +97,9 @@ class Framework_SpellcheckerEnchant extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
 
-        $object = new rcube_spellchecker('en_US');
+        $object = new \rcube_spellchecker('en_US');
 
         $result = $object->get_suggestions('onlx');
 
@@ -114,9 +116,9 @@ class Framework_SpellcheckerEnchant extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'enchant');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $this->assertSame(['ony'], $object->get_words('ony'));
     }
diff --git a/tests/Framework/SpellcheckerGoogie.php b/tests/Framework/SpellcheckerGoogie.php
index 8c1f173..8e7f5b9 100644
--- a/tests/Framework/SpellcheckerGoogie.php
+++ b/tests/Framework/SpellcheckerGoogie.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_spellcheck_googie class
- *
- * @package Tests
  */
-class Framework_SpellcheckerGoogie extends PHPUnit\Framework\TestCase
+class Framework_SpellcheckerGoogie extends TestCase
 {
 
     /**
@@ -13,9 +15,9 @@ class Framework_SpellcheckerGoogie extends PHPUnit\Framework\TestCase
      */
     function test_class()
     {
-        $object = new rcube_spellchecker_googie(null, 'en');
+        $object = new \rcube_spellchecker_googie(null, 'en');
 
-        $this->assertInstanceOf('rcube_spellchecker_googie', $object, "Class constructor");
-        $this->assertInstanceOf('rcube_spellchecker_engine', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_googie::class, $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_engine::class, $object, "Class constructor");
     }
 }
diff --git a/tests/Framework/SpellcheckerPspell.php b/tests/Framework/SpellcheckerPspell.php
index e10e160..fc3d970 100644
--- a/tests/Framework/SpellcheckerPspell.php
+++ b/tests/Framework/SpellcheckerPspell.php
@@ -1,21 +1,23 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_spellcheck_pspell class
- *
- * @package Tests
  */
-class Framework_SpellcheckerPspell extends PHPUnit\Framework\TestCase
+class Framework_SpellcheckerPspell extends TestCase
 {
     /**
      * Class constructor
      */
     function test_class()
     {
-        $object = new rcube_spellchecker_pspell(null, 'en');
+        $object = new \rcube_spellchecker_pspell(null, 'en');
 
-        $this->assertInstanceOf('rcube_spellchecker_pspell', $object, "Class constructor");
-        $this->assertInstanceOf('rcube_spellchecker_engine', $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_pspell::class, $object, "Class constructor");
+        $this->assertInstanceOf(\rcube_spellchecker_engine::class, $object, "Class constructor");
     }
 
     /**
@@ -27,9 +29,9 @@ class Framework_SpellcheckerPspell extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $langs = $object->languages();
 
@@ -45,9 +47,9 @@ class Framework_SpellcheckerPspell extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $this->assertTrue($object->check('one'));
 
@@ -95,9 +97,9 @@ class Framework_SpellcheckerPspell extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $expected = ['ON','on','Ont','only','onya','NY','onyx','Ono','any','one'];
         $result   = $object->get_suggestions('ony');
@@ -117,9 +119,9 @@ class Framework_SpellcheckerPspell extends PHPUnit\Framework\TestCase
             $this->markTestSkipped();
         }
 
-        rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
+        \rcube::get_instance()->config->set('spellcheck_engine', 'pspell');
 
-        $object = new rcube_spellchecker();
+        $object = new \rcube_spellchecker();
 
         $this->assertSame(['ony'], $object->get_words('ony'));
     }
diff --git a/tests/Framework/Spoofchecker.php b/tests/Framework/Spoofchecker.php
index 416c2a3..0858596 100644
--- a/tests/Framework/Spoofchecker.php
+++ b/tests/Framework/Spoofchecker.php
@@ -1,16 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_spoofchecker class
- *
- * @package Tests
  */
-class Framework_Spoofchecker extends PHPUnit\Framework\TestCase
+class Framework_Spoofchecker extends TestCase
 {
     /**
      * Test data for test_check()
      */
-    function data_check()
+    static function data_check()
     {
         return [
             // Valid:
@@ -34,8 +37,9 @@ class Framework_Spoofchecker extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_check
      */
+    #[DataProvider('data_check')]
     function test_check($email, $expected)
     {
-        $this->assertSame($expected, rcube_spoofchecker::check($email));
+        $this->assertSame($expected, \rcube_spoofchecker::check($email));
     }
 }
diff --git a/tests/Framework/StringReplacer.php b/tests/Framework/StringReplacer.php
index bad679f..dc45252 100644
--- a/tests/Framework/StringReplacer.php
+++ b/tests/Framework/StringReplacer.php
@@ -1,26 +1,29 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_string_replacer class
- *
- * @package Tests
  */
-class Framework_StringReplacer extends PHPUnit\Framework\TestCase
+class Framework_StringReplacer extends TestCase
 {
     /**
      * Class constructor
      */
     function test_class()
     {
-        $sr = new rcube_string_replacer;
+        $sr = new \rcube_string_replacer();
 
-        $this->assertInstanceOf('rcube_string_replacer', $sr, "Class constructor");
+        $this->assertInstanceOf(\rcube_string_replacer::class, $sr, "Class constructor");
     }
 
     /**
      * Data for test_replace()
      */
-    function data_replace()
+    static function data_replace()
     {
         return [
             ['http://domain.tld/path*path2', '<a href="http://domain.tld/path*path2">http://domain.tld/path*path2</a>'],
@@ -54,9 +57,10 @@ class Framework_StringReplacer extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_replace
      */
+    #[DataProvider('data_replace')]
     function test_replace($input, $output)
     {
-        $replacer = new rcube_string_replacer;
+        $replacer = new \rcube_string_replacer();
         $result = $replacer->replace($input);
         $result = $replacer->resolve($result);
 
@@ -72,7 +76,7 @@ class Framework_StringReplacer extends PHPUnit\Framework\TestCase
             . "[1] http://en.wikipedia.org/wiki/Email\n"
             . "[ref0] www.link-ref.com\n";
 
-        $replacer = new rcube_string_replacer;
+        $replacer = new \rcube_string_replacer();
         $result = $replacer->replace($input);
         $result = $replacer->resolve($result);
 
diff --git a/tests/Framework/Text2Html.php b/tests/Framework/Text2Html.php
index 75405be..0f1ae39 100644
--- a/tests/Framework/Text2Html.php
+++ b/tests/Framework/Text2Html.php
@@ -1,16 +1,19 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_text2html class
- *
- * @package Tests
  */
-class Framework_Text2Html extends PHPUnit\Framework\TestCase
+class Framework_Text2Html extends TestCase
 {
     /**
      * Data for test_text2html()
      */
-    function data_text2html()
+    static function data_text2html()
     {
         $options = [
             'begin'  => '',
@@ -111,9 +114,10 @@ class Framework_Text2Html extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_text2html
      */
+    #[DataProvider('data_text2html')]
     function test_text2html($input, $output, $options)
     {
-        $t2h = new rcube_text2html($input, false, $options);
+        $t2h = new \rcube_text2html($input, false, $options);
 
         $html = $t2h->get_html();
 
@@ -126,7 +130,7 @@ class Framework_Text2Html extends PHPUnit\Framework\TestCase
     function test_text2html_xss()
     {
         $input = "\n[<script>evil</script>]:##str_replacement_0##\n";
-        $t2h = new rcube_text2html($input);
+        $t2h = new \rcube_text2html($input);
 
         $html = $t2h->get_html();
 
@@ -143,7 +147,7 @@ class Framework_Text2Html extends PHPUnit\Framework\TestCase
     function test_text2html_xss2()
     {
         $input = "\n[<script>evil</script>] https://google.com\n";
-        $t2h = new rcube_text2html($input);
+        $t2h = new \rcube_text2html($input);
 
         $html = $t2h->get_html();
 
@@ -168,7 +172,7 @@ class Framework_Text2Html extends PHPUnit\Framework\TestCase
             . "<br>\n<br>\n"
             . '[1] <a href="http://d2.tld">http://d2.tld</a></blockquote></div>';
 
-        $t2h = new rcube_text2html($input);
+        $t2h = new \rcube_text2html($input);
         $html = $t2h->get_html();
         $html = preg_replace('/ (rel|target)="(noreferrer|_blank)"/', '', $html);
 
@@ -208,7 +212,7 @@ class Framework_Text2Html extends PHPUnit\Framework\TestCase
             . "<span style=\"white-space:nowrap\">_</span><br>\n"
             . "End</div>";
 
-        $t2h = new rcube_text2html($input, false, ['space' => '_']);
+        $t2h = new \rcube_text2html($input, false, ['space' => '_']);
         $html = $t2h->get_html();
 
         $this->assertEquals($expected, $html);
diff --git a/tests/Framework/TnefDecoder.php b/tests/Framework/TnefDecoder.php
index 91f1677..1fa8a5b 100644
--- a/tests/Framework/TnefDecoder.php
+++ b/tests/Framework/TnefDecoder.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_tnef_decoder class
- *
- * @package Tests
  */
-class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
+class Framework_TnefDecoder extends TestCase
 {
     /**
      * Test TNEF decoding
@@ -13,7 +15,7 @@ class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
     function test_decompress()
     {
         $body   = file_get_contents(TESTS_DIR . 'src/one-file.tnef');
-        $tnef   = new rcube_tnef_decoder;
+        $tnef   = new \rcube_tnef_decoder();
         $result = $tnef->decompress($body);
 
         $this->assertSame('one-file', trim($result['message']['name']));
@@ -31,7 +33,7 @@ class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
     function test_decompress_body()
     {
         $body   = file_get_contents(TESTS_DIR . 'src/body.tnef');
-        $tnef   = new rcube_tnef_decoder;
+        $tnef   = new \rcube_tnef_decoder();
         $result = $tnef->decompress($body);
 
         $this->assertSame('Untitled.html', trim($result['message']['name']));
@@ -41,7 +43,7 @@ class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
         $this->assertSame(5360, $result['message']['size']);
         $this->assertMatchesRegularExpression('/^<\!DOCTYPE HTML/', $result['message']['stream']);
 
-        $tnef   = new rcube_tnef_decoder;
+        $tnef   = new \rcube_tnef_decoder();
         $result = $tnef->decompress($body, true);
 
         $this->assertCount(0, $result['attachments']);
@@ -55,7 +57,7 @@ class Framework_TnefDecoder extends PHPUnit\Framework\TestCase
     function test_rtf2text()
     {
         $body = file_get_contents(TESTS_DIR . 'src/sample.rtf');
-        $text = rcube_tnef_decoder::rtf2text($body);
+        $text = \rcube_tnef_decoder::rtf2text($body);
 
         $this->assertMatchesRegularExpression('/^[a-zA-Z1-6!&<,> \n\.]+$/', $text);
         $this->assertTrue(strpos($text, 'Alex Skolnick') !== false);
diff --git a/tests/Framework/User.php b/tests/Framework/User.php
index 2a83ad8..b2f2da5 100644
--- a/tests/Framework/User.php
+++ b/tests/Framework/User.php
@@ -1,9 +1,11 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcube_user class
- *
- * @package Tests
  */
 class Framework_User extends ActionTestCase
 {
@@ -14,7 +16,7 @@ class Framework_User extends ActionTestCase
     {
         self::initDB('init');
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $this->assertSame(1, $user->ID);
         $this->assertSame(null, $user->language);
@@ -27,7 +29,7 @@ class Framework_User extends ActionTestCase
     {
         self::initDB('init');
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $this->assertSame('test@example.com', $user->get_username());
         $this->assertSame('test', $user->get_username('local'));
@@ -41,13 +43,13 @@ class Framework_User extends ActionTestCase
     {
         self::initDB('init');
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $this->assertSame([], $user->get_prefs());
 
         $user->save_prefs(['test' => 'test'], true);
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $this->assertSame(['test' => 'test'], $user->get_prefs());
 
@@ -55,7 +57,7 @@ class Framework_User extends ActionTestCase
 
         $this->assertMatchesRegularExpression('/^[a-zA-Z0-9]{16}$/', $hash);
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $prefs = $user->get_prefs();
 
@@ -72,7 +74,7 @@ class Framework_User extends ActionTestCase
         self::initDB('init');
         self::initDB('identities');
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $all = $user->list_emails();
 
@@ -148,11 +150,11 @@ class Framework_User extends ActionTestCase
     {
         self::initDB('init');
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $user->failed_login();
 
-        $user = new rcube_user(1);
+        $user = new \rcube_user(1);
 
         $this->assertEquals(1, $user->data['failed_login_counter']);
 
@@ -166,9 +168,9 @@ class Framework_User extends ActionTestCase
     {
         self::initDB('init');
 
-        $this->assertNull(rcube_user::query('test', 'localhost'));
+        $this->assertNull(\rcube_user::query('test', 'localhost'));
 
-        $user = rcube_user::query('test@example.com', 'localhost');
+        $user = \rcube_user::query('test@example.com', 'localhost');
 
         $this->assertEquals(1, $user->ID);
     }
@@ -180,11 +182,11 @@ class Framework_User extends ActionTestCase
     {
         self::initDB('init');
 
-        $user = rcube_user::create('new@example.com', 'localhost');
+        $user = \rcube_user::create('new@example.com', 'localhost');
 
         $this->assertSame('new@example.com', $user->get_username());
 
-        $user = new rcube_user($user->ID);
+        $user = new \rcube_user($user->ID);
 
         $idents = $user->list_identities();
 
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index 29df81d..cf76834 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -1,11 +1,15 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+use Roundcube\Tests\StderrMock;
+
 /**
  * Test class to test rcube_utils class
- *
- * @package Tests
  */
-class Framework_Utils extends PHPUnit\Framework\TestCase
+class Framework_Utils extends TestCase
 {
     /**
      * Test for rcube_utils::date_format()
@@ -14,10 +18,10 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     {
         date_default_timezone_set('Europe/Berlin');
 
-        $this->assertSame(date('d-M-Y H:i:s O'), rcube_utils::date_format());
-        $this->assertSame(date('Y-m-d H:i:s O'), rcube_utils::date_format('Y-m-d H:i:s O'));
+        $this->assertSame(date('d-M-Y H:i:s O'), \rcube_utils::date_format());
+        $this->assertSame(date('Y-m-d H:i:s O'), \rcube_utils::date_format('Y-m-d H:i:s O'));
 
-        $result = rcube_utils::date_format('H:i:s,u O');
+        $result = \rcube_utils::date_format('H:i:s,u O');
         $regexp = '/^' . preg_quote(date('H:i:s,')) . '(?<!000000)\d{6}' . preg_quote(date(' O')) . '$/';
 
         $this->assertMatchesRegularExpression($regexp, $result);
@@ -28,15 +32,15 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      */
     function test_explode()
     {
-        $this->assertSame(['test', null], rcube_utils::explode(':', 'test'));
-        $this->assertSame(['test1', 'test2'], rcube_utils::explode(':', 'test1:test2'));
-        $this->assertSame(['', 'test1', 'test2'], rcube_utils::explode(':', ':test1:test2'));
+        $this->assertSame(['test', null], \rcube_utils::explode(':', 'test'));
+        $this->assertSame(['test1', 'test2'], \rcube_utils::explode(':', 'test1:test2'));
+        $this->assertSame(['', 'test1', 'test2'], \rcube_utils::explode(':', ':test1:test2'));
     }
 
     /**
      * Valid email addresses for test_valid_email()
      */
-    function data_valid_email()
+    static function data_valid_email()
     {
         return [
             ['email@domain.com', 'Valid email'],
@@ -63,7 +67,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     /**
      * Invalid email addresses for test_invalid_email()
      */
-    function data_invalid_email()
+    static function data_invalid_email()
     {
         return [
             ['plainaddress', 'Missing @ sign and domain'],
@@ -96,23 +100,25 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_valid_email
      */
+    #[DataProvider('data_valid_email')]
     function test_valid_email($email, $title)
     {
-        $this->assertTrue(rcube_utils::check_email($email, false), $title);
+        $this->assertTrue(\rcube_utils::check_email($email, false), $title);
     }
 
     /**
      * @dataProvider data_invalid_email
      */
+    #[DataProvider('data_invalid_email')]
     function test_invalid_email($email, $title)
     {
-        $this->assertFalse(rcube_utils::check_email($email, false), $title);
+        $this->assertFalse(\rcube_utils::check_email($email, false), $title);
     }
 
     /**
      * Valid IP addresses for test_valid_ip()
      */
-    function data_valid_ip()
+    static function data_valid_ip()
     {
         return [
             ['0.0.0.0'],
@@ -129,7 +135,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     /**
      * Invalid IP addresses for test_invalid_ip()
      */
-    function data_invalid_ip()
+    static function data_invalid_ip()
     {
         return [
             [''],
@@ -148,23 +154,25 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     /**
      * @dataProvider data_valid_ip
      */
+    #[DataProvider('data_valid_ip')]
     function test_valid_ip($ip)
     {
-        $this->assertTrue(rcube_utils::check_ip($ip));
+        $this->assertTrue(\rcube_utils::check_ip($ip));
     }
 
     /**
      * @dataProvider data_invalid_ip
      */
+    #[DataProvider('data_invalid_ip')]
     function test_invalid_ip($ip)
     {
-        $this->assertFalse(rcube_utils::check_ip($ip));
+        $this->assertFalse(\rcube_utils::check_ip($ip));
     }
 
     /**
      * Data for test_rep_specialchars_output()
      */
-    function data_rep_specialchars_output()
+    static function data_rep_specialchars_output()
     {
         return [
             ['', '', 'abc', 'abc'],
@@ -183,9 +191,10 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      * Test for rep_specialchars_output
      * @dataProvider data_rep_specialchars_output
      */
+    #[DataProvider('data_rep_specialchars_output')]
     function test_rep_specialchars_output($type, $mode, $str, $res)
     {
-        $result = rcube_utils::rep_specialchars_output(
+        $result = \rcube_utils::rep_specialchars_output(
             $str, $type ? $type : 'html', $mode ? $mode : 'strict');
 
         $this->assertEquals($result, $res);
@@ -197,7 +206,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     function test_mod_css_styles()
     {
         $css = file_get_contents(TESTS_DIR . 'src/valid.css');
-        $mod = rcube_utils::mod_css_styles($css, 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles($css, 'rcmbody');
 
         $this->assertMatchesRegularExpression('/#rcmbody\s+\{/', $mod, "Replace body style definition");
         $this->assertMatchesRegularExpression('/#rcmbody h1\s\{/', $mod, "Prefix tag styles (single)");
@@ -205,7 +214,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         $this->assertMatchesRegularExpression('/#rcmbody \.noscript\s+\{/', $mod, "Prefix class styles");
 
         $css = file_get_contents(TESTS_DIR . 'src/media.css');
-        $mod = rcube_utils::mod_css_styles($css, 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles($css, 'rcmbody');
 
         $this->assertStringContainsString('#rcmbody table[class=w600]', $mod, 'Replace styles nested in @media block');
         $this->assertStringContainsString('#rcmbody { width: 600px', $mod, 'Replace body selector nested in @media block');
@@ -220,7 +229,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         $mod = \rcube_utils::mod_css_styles('font-size: 1em;', 'rcmbody');
         $this->assertSame('/* invalid! */', $mod);
 
-        $mod = rcube_utils::mod_css_styles("@import url('http://localhost/somestuff/css/master.css');", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles("@import url('http://localhost/somestuff/css/master.css');", 'rcmbody');
         $this->assertSame('/* evil! */', $mod);
 
         $mod = \rcube_utils::mod_css_styles("@\\69mport url('http://localhost/somestuff/css/master.css');", 'rcmbody');
@@ -261,47 +270,47 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         $this->assertSame('#rcmbody p { background: none !important; }', $mod);
 
         // position: fixed (#5264)
-        $mod = rcube_utils::mod_css_styles(".test { position: fixed; }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles(".test { position: fixed; }", 'rcmbody');
         $this->assertEquals("#rcmbody .test { position: absolute; }", $mod, "Replace position:fixed with position:absolute (0)");
-        $mod = rcube_utils::mod_css_styles(".test { position:\nfixed; }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles(".test { position:\nfixed; }", 'rcmbody');
         $this->assertEquals("#rcmbody .test { position: absolute; }", $mod, "Replace position:fixed with position:absolute (1)");
-        $mod = rcube_utils::mod_css_styles(".test { position:/**/fixed; }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles(".test { position:/**/fixed; }", 'rcmbody');
         $this->assertEquals("#rcmbody .test { position: absolute; }", $mod, "Replace position:fixed with position:absolute (2)");
 
         // position: fixed (#6898)
-        $mod = rcube_utils::mod_css_styles(".test { position : fixed; top: 0; }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles(".test { position : fixed; top: 0; }", 'rcmbody');
         $this->assertEquals("#rcmbody .test { position: absolute; top: 0; }", $mod, "Replace position:fixed with position:absolute (3)");
-        $mod = rcube_utils::mod_css_styles(".test { position/**/: fixed; top: 0; }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles(".test { position/**/: fixed; top: 0; }", 'rcmbody');
         $this->assertEquals("#rcmbody .test { position: absolute; top: 0; }", $mod, "Replace position:fixed with position:absolute (4)");
-        $mod = rcube_utils::mod_css_styles(".test { position\n: fixed; top: 0; }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles(".test { position\n: fixed; top: 0; }", 'rcmbody');
         $this->assertEquals("#rcmbody .test { position: absolute; top: 0; }", $mod, "Replace position:fixed with position:absolute (5)");
 
         // allow data URIs with images (#5580)
-        $mod = rcube_utils::mod_css_styles("body { background-image: url(data:image/png;base64,123); }", 'rcmbody');
+        $mod = \rcube_utils::mod_css_styles("body { background-image: url(data:image/png;base64,123); }", 'rcmbody');
         $this->assertStringContainsString("#rcmbody { background-image: url(data:image/png;base64,123);", $mod, "Data URIs in url() allowed [1]");
-        $mod = rcube_utils::mod_css_styles("body { background-image: url(data:image/png;base64,123); }", 'rcmbody', true);
+        $mod = \rcube_utils::mod_css_styles("body { background-image: url(data:image/png;base64,123); }", 'rcmbody', true);
         $this->assertStringContainsString("#rcmbody { background-image: url(data:image/png;base64,123);", $mod, "Data URIs in url() allowed [2]");
 
         // Allow strict url()
-        $mod = rcube_utils::mod_css_styles("body { background-image: url(http://example.com); }", 'rcmbody', true);
+        $mod = \rcube_utils::mod_css_styles("body { background-image: url(http://example.com); }", 'rcmbody', true);
         $this->assertStringContainsString("#rcmbody { background-image: url(http://example.com);", $mod, "Strict URIs in url() allowed with \$allow_remote=true");
 
         // XSS issue, HTML in 'content' property
         $style = "body { content: '</style><img src onerror=\"alert(\'hello\');\">'; color: red; }";
-        $mod = rcube_utils::mod_css_styles($style, 'rcmbody', true);
+        $mod = \rcube_utils::mod_css_styles($style, 'rcmbody', true);
         $this->assertSame("#rcmbody { content: ''; color: red; }", $mod);
 
         $style = "body { content: '< page: ;/style>< page: ;img src onerror=\"alert(\\'hello\\');\">'; color: red; }";
-        $mod = rcube_utils::mod_css_styles($style, 'rcmbody', true);
+        $mod = \rcube_utils::mod_css_styles($style, 'rcmbody', true);
         $this->assertSame("#rcmbody { color: red; }", $mod);
 
         // Removing page: property
         $style = "body { page: test; color: red }";
-        $mod = rcube_utils::mod_css_styles($style, 'rcmbody', true);
+        $mod = \rcube_utils::mod_css_styles($style, 'rcmbody', true);
         $this->assertSame("#rcmbody { color: red; }", $mod);
 
         $style = "body { background:url(alert(&#039;URL!&#039;)); }";
-        $mod = rcube_utils::mod_css_styles($style, 'rcmbody', true);
+        $mod = \rcube_utils::mod_css_styles($style, 'rcmbody', true);
         $this->assertSame("#rcmbody {}", $mod);
     }
 
@@ -325,7 +334,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
             :root * { color: red; }
             :root > * { top: 0; }
         ';
-        $mod = rcube_utils::mod_css_styles($css, 'rc', true, 'test');
+        $mod = \rcube_utils::mod_css_styles($css, 'rc', true, 'test');
 
         $this->assertStringContainsString('#rc .testone', $mod);
         $this->assertStringContainsString('#rc .testthree.testfour', $mod);
@@ -343,24 +352,24 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
 
     function test_xss_entity_decode()
     {
-        $mod = rcube_utils::xss_entity_decode("&lt;img/src=x onerror=alert(1)// </b>");
+        $mod = \rcube_utils::xss_entity_decode("&lt;img/src=x onerror=alert(1)// </b>");
         $this->assertStringNotContainsString('<img', $mod, "Strip (encoded) tags from style node");
 
-        $mod = rcube_utils::xss_entity_decode('#foo:after{content:"\003Cimg/src=x onerror=alert(2)>";}');
+        $mod = \rcube_utils::xss_entity_decode('#foo:after{content:"\003Cimg/src=x onerror=alert(2)>";}');
         $this->assertStringNotContainsString('<img', $mod, "Strip (encoded) tags from content property");
 
-        $mod = rcube_utils::xss_entity_decode("background: u\\r\\00006c('/images/img.png')");
+        $mod = \rcube_utils::xss_entity_decode("background: u\\r\\00006c('/images/img.png')");
         $this->assertStringContainsString("url(", $mod, "Escape sequences resolving");
 
         // #5747
-        $mod = rcube_utils::xss_entity_decode('<!-- #foo { content:css; } -->');
+        $mod = \rcube_utils::xss_entity_decode('<!-- #foo { content:css; } -->');
         $this->assertStringContainsString('#foo', $mod, "Strip HTML comments from content, but not the content");
     }
 
     /**
      * Test-Cases for parse_css_block() test
      */
-    function data_parse_css_block()
+    static function data_parse_css_block()
     {
         return [
             [
@@ -435,9 +444,10 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_parse_css_block
      */
+    #[DataProvider('data_parse_css_block')]
     function test_parse_css_block($input, $output)
     {
-        $this->assertSame($output, rcube_utils::parse_css_block($input));
+        $this->assertSame($output, \rcube_utils::parse_css_block($input));
     }
 
     /**
@@ -452,7 +462,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($data as $text => $res) {
-            $result = rcube_utils::explode_quoted_string(',', $text);
+            $result = \rcube_utils::explode_quoted_string(',', $text);
             $this->assertSame($res, $result);
         }
     }
@@ -465,7 +475,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         $data = ['', 'a,b,c', 'a', ',', ',a'];
 
         foreach ($data as $text) {
-            $result = rcube_utils::explode_quoted_string(',', $text);
+            $result = \rcube_utils::explode_quoted_string(',', $text);
             $this->assertSame(explode(',', $text), $result);
         }
     }
@@ -480,7 +490,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($input as $idx => $value) {
-            $this->assertFalse(rcube_utils::get_boolean($value), "Invalid result for $idx test item");
+            $this->assertFalse(\rcube_utils::get_boolean($value), "Invalid result for $idx test item");
         }
 
         $input = [
@@ -488,7 +498,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($input as $idx => $value) {
-            $this->assertTrue(rcube_utils::get_boolean($value), "Invalid result for $idx test item");
+            $this->assertTrue(\rcube_utils::get_boolean($value), "Invalid result for $idx test item");
         }
     }
 
@@ -498,13 +508,13 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     function test_get_input_string()
     {
         $_GET = [];
-        $this->assertSame('', rcube_utils::get_input_string('test', rcube_utils::INPUT_GET));
+        $this->assertSame('', \rcube_utils::get_input_string('test', \rcube_utils::INPUT_GET));
 
         $_GET = ['test' => 'val'];
-        $this->assertSame('val', rcube_utils::get_input_string('test', rcube_utils::INPUT_GET));
+        $this->assertSame('val', \rcube_utils::get_input_string('test', \rcube_utils::INPUT_GET));
 
         $_GET = ['test' => ['val1', 'val2']];
-        $this->assertSame('', rcube_utils::get_input_string('test', rcube_utils::INPUT_GET));
+        $this->assertSame('', \rcube_utils::get_input_string('test', \rcube_utils::INPUT_GET));
     }
 
     /**
@@ -512,18 +522,18 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      */
     function test_is_simple_string()
     {
-        $this->assertTrue(rcube_utils::is_simple_string('some-thing.123_'));
-        $this->assertFalse(rcube_utils::is_simple_string(''));
-        $this->assertFalse(rcube_utils::is_simple_string(' '));
-        $this->assertFalse(rcube_utils::is_simple_string('some–thing'));
-        $this->assertFalse(rcube_utils::is_simple_string('some=thing'));
-        $this->assertFalse(rcube_utils::is_simple_string('some thing'));
-        $this->assertFalse(rcube_utils::is_simple_string('some!thing'));
-        $this->assertFalse(rcube_utils::is_simple_string('%20'));
-        $this->assertFalse(rcube_utils::is_simple_string('\0000'));
-        $this->assertFalse(rcube_utils::is_simple_string(1));
-        $this->assertFalse(rcube_utils::is_simple_string(new stdClass()));
-        $this->assertFalse(rcube_utils::is_simple_string(null));
+        $this->assertTrue(\rcube_utils::is_simple_string('some-thing.123_'));
+        $this->assertFalse(\rcube_utils::is_simple_string(''));
+        $this->assertFalse(\rcube_utils::is_simple_string(' '));
+        $this->assertFalse(\rcube_utils::is_simple_string('some–thing'));
+        $this->assertFalse(\rcube_utils::is_simple_string('some=thing'));
+        $this->assertFalse(\rcube_utils::is_simple_string('some thing'));
+        $this->assertFalse(\rcube_utils::is_simple_string('some!thing'));
+        $this->assertFalse(\rcube_utils::is_simple_string('%20'));
+        $this->assertFalse(\rcube_utils::is_simple_string('\0000'));
+        $this->assertFalse(\rcube_utils::is_simple_string(1));
+        $this->assertFalse(\rcube_utils::is_simple_string(new \stdClass()));
+        $this->assertFalse(\rcube_utils::is_simple_string(null));
     }
 
     /**
@@ -538,7 +548,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $v) {
-            $result = rcube_utils::file2class($v[0], $v[1]);
+            $result = \rcube_utils::file2class($v[0], $v[1]);
             $this->assertSame($v[2], $result);
         }
     }
@@ -568,7 +578,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $datetime => $ts) {
-            $result = rcube_utils::strtotime($datetime);
+            $result = \rcube_utils::strtotime($datetime);
             $this->assertSame($ts, $result, "Error parsing date: $datetime");
         }
     }
@@ -595,7 +605,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $datetime => $ts) {
-            $result = rcube_utils::anytodatetime($datetime);
+            $result = \rcube_utils::anytodatetime($datetime);
             $this->assertSame($ts, $result ? $result->format('Y-m-d') : false, "Error parsing date: $datetime");
         }
 
@@ -605,7 +615,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $datetime => $ts) {
-            $result = rcube_utils::anytodatetime($datetime);
+            $result = \rcube_utils::anytodatetime($datetime);
             $this->assertSame($ts, $result ? $result->format('Y-m-d H:i:s') : false, "Error parsing date: $datetime");
         }
 
@@ -614,7 +624,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $datetime => $ts) {
-            $result = rcube_utils::anytodatetime($datetime);
+            $result = \rcube_utils::anytodatetime($datetime);
             $this->assertSame($ts, $result ? $result->format('Y-m-d H:i:s O') : false, "Error parsing date: $datetime");
         }
     }
@@ -624,17 +634,17 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      */
     function test_anytodatetime_timezone()
     {
-        $tz = new DateTimeZone('Europe/Helsinki');
+        $tz = new \DateTimeZone('Europe/Helsinki');
         $test = [
             'Jan 1st 2014 +0800' => '2013-12-31 18:00',  // result in target timezone
-            'Jan 1st 14 45:42'   => '2014-01-01 00:00',  // force fallback to rcube_utils::strtotime()
+            'Jan 1st 14 45:42'   => '2014-01-01 00:00',  // force fallback to \rcube_utils::strtotime()
             'Jan 1st 2014 UK'    => '2014-01-01 00:00',
             '1520587800'         => '2018-03-09 11:30',  // unix timestamp conversion
             'Invalid date'       => false,
         ];
 
         foreach ($test as $datetime => $ts) {
-            $result = rcube_utils::anytodatetime($datetime, $tz);
+            $result = \rcube_utils::anytodatetime($datetime, $tz);
             if ($result) $result->setTimezone($tz);  // move to target timezone for comparison
             $this->assertSame($ts, $result ? $result->format('Y-m-d H:i') : false, "Error parsing date: $datetime");
         }
@@ -653,7 +663,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $data) {
-            $result = rcube_utils::format_datestr($data[0], $data[1]);
+            $result = \rcube_utils::format_datestr($data[0], $data[1]);
             $this->assertSame($data[2], $result, "Error formatting date: " . $data[0]);
         }
     }
@@ -672,7 +682,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $input => $output) {
-            $result = rcube_utils::tokenize_string($input);
+            $result = \rcube_utils::tokenize_string($input);
             $this->assertSame($output, $result);
         }
     }
@@ -697,7 +707,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $input => $output) {
-            $result = rcube_utils::normalize_string($input);
+            $result = \rcube_utils::normalize_string($input);
             $this->assertSame($output, $result, "Error normalizing '$input'");
         }
     }
@@ -720,7 +730,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($test as $idx => $params) {
-            $result = rcube_utils::words_match($params[0], $params[1]);
+            $result = \rcube_utils::words_match($params[0], $params[1]);
             $this->assertSame($params[2], $result, "words_match() at index $idx");
         }
     }
@@ -746,7 +756,7 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
         }
 
         foreach ($test as $input => $output) {
-            $result = rcube_utils::is_absolute_path($input);
+            $result = \rcube_utils::is_absolute_path($input);
             $this->assertSame($output, $result);
         }
     }
@@ -756,17 +766,17 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      */
     function test_random_bytes()
     {
-        $this->assertMatchesRegularExpression('/^[a-zA-Z0-9]{15}$/', rcube_utils::random_bytes(15));
-        $this->assertSame(15, strlen(rcube_utils::random_bytes(15, true)));
-        $this->assertSame(1, strlen(rcube_utils::random_bytes(1)));
-        $this->assertSame(0, strlen(rcube_utils::random_bytes(0)));
-        $this->assertSame(0, strlen(rcube_utils::random_bytes(-1)));
+        $this->assertMatchesRegularExpression('/^[a-zA-Z0-9]{15}$/', \rcube_utils::random_bytes(15));
+        $this->assertSame(15, strlen(\rcube_utils::random_bytes(15, true)));
+        $this->assertSame(1, strlen(\rcube_utils::random_bytes(1)));
+        $this->assertSame(0, strlen(\rcube_utils::random_bytes(0)));
+        $this->assertSame(0, strlen(\rcube_utils::random_bytes(-1)));
     }
 
     /**
      * Test-Cases for IDN to ASCII and IDN to UTF-8
      */
-    function data_idn_convert()
+    static function data_idn_convert()
     {
 
         /*
@@ -803,9 +813,10 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      * @param string $encoded Encoded email address
      * @dataProvider data_idn_convert
      */
+    #[DataProvider('data_idn_convert')]
     function test_idn_to_ascii($decoded, $encoded)
     {
-        $this->assertEquals(rcube_utils::idn_to_ascii($decoded), $encoded);
+        $this->assertEquals(\rcube_utils::idn_to_ascii($decoded), $encoded);
     }
 
     /**
@@ -815,9 +826,10 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      * @param string $encoded Encoded email address
      * @dataProvider data_idn_convert
      */
+    #[DataProvider('data_idn_convert')]
     function test_idn_to_utf8($decoded, $encoded)
     {
-        $this->assertEquals(rcube_utils::idn_to_utf8($encoded), $decoded);
+        $this->assertEquals(\rcube_utils::idn_to_utf8($encoded), $decoded);
     }
 
     /**
@@ -825,14 +837,14 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      */
     function test_idn_to_ascii_special()
     {
-        $this->assertEquals(rcube_utils::idn_to_ascii('H.S'), 'H.S');
-        $this->assertEquals(rcube_utils::idn_to_ascii('d.-h.lastname'), 'd.-h.lastname');
+        $this->assertEquals(\rcube_utils::idn_to_ascii('H.S'), 'H.S');
+        $this->assertEquals(\rcube_utils::idn_to_ascii('d.-h.lastname'), 'd.-h.lastname');
     }
 
     /**
      * Test-Cases for test_parse_host()
      */
-    function data_parse_host()
+    static function data_parse_host()
     {
         return [
             ['%z', 'hostname', 'hostname'],
@@ -847,15 +859,16 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_parse_host
      */
+    #[DataProvider('data_parse_host')]
     function test_parse_host($name, $host, $result)
     {
-        $this->assertEquals(rcube_utils::parse_host($name, $host), $result);
+        $this->assertEquals(\rcube_utils::parse_host($name, $host), $result);
     }
 
     /**
      * Test-Cases for test_parse_host_uri()
      */
-    function data_parse_host_uri()
+    static function data_parse_host_uri()
     {
         return [
             [['hostname', null, null], ['hostname', null, null]],
@@ -878,15 +891,16 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_parse_host_uri
      */
+    #[DataProvider('data_parse_host_uri')]
     function test_parse_host_uri($args, $result)
     {
-        $this->assertSame($result, call_user_func_array('rcube_utils::parse_host_uri', $args));
+        $this->assertSame($result, call_user_func_array('\rcube_utils::parse_host_uri', $args));
     }
 
     /**
      * Test-Cases for test_remove_subject_prefix()
      */
-    function data_remove_subject_prefix() {
+    static function data_remove_subject_prefix() {
         return [
             ['both',    'Fwd: Re: Test subject both', 'Test subject both'],
             ['both',    'Re: Fwd: Test subject both', 'Test subject both'],
@@ -904,8 +918,9 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      * 
      * @dataProvider data_remove_subject_prefix
      */
+    #[DataProvider('data_remove_subject_prefix')]
     function test_remove_subject_prefix($mode, $subject, $result) {
-        $this->assertEquals(rcube_utils::remove_subject_prefix($subject, $mode), $result);
+        $this->assertEquals(\rcube_utils::remove_subject_prefix($subject, $mode), $result);
     }
 
     /**
@@ -913,13 +928,13 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
      */
     function test_server_name()
     {
-        $this->assertEquals('localhost', rcube_utils::server_name('test'));
+        $this->assertEquals('localhost', \rcube_utils::server_name('test'));
 
         $_SERVER['test'] = 'test.com:843';
-        $this->assertEquals('test.com', rcube_utils::server_name('test'));
+        $this->assertEquals('test.com', \rcube_utils::server_name('test'));
 
         $_SERVER['test'] = 'test.com';
-        $this->assertEquals('test.com', rcube_utils::server_name('test'));
+        $this->assertEquals('test.com', \rcube_utils::server_name('test'));
     }
 
     /**
@@ -929,31 +944,31 @@ class Framework_Utils extends PHPUnit\Framework\TestCase
     {
         $_SERVER['test'] = 'test.com';
 
-        $rcube = rcube::get_instance();
+        $rcube = \rcube::get_instance();
         $rcube->config->set('trusted_host_patterns', ['my.domain.tld']);
 
         StderrMock::start();
-        $this->assertEquals('localhost', rcube_utils::server_name('test'));
+        $this->assertEquals('localhost', \rcube_utils::server_name('test'));
         StderrMock::stop();
         $this->assertSame("ERROR: Specified host is not trusted. Using 'localhost'.", trim(StderrMock::$output));
 
         $rcube->config->set('trusted_host_patterns', ['test.com']);
 
         StderrMock::start();
-        $this->assertEquals('test.com', rcube_utils::server_name('test'));
+        $this->assertEquals('test.com', \rcube_utils::server_name('test'));
         StderrMock::stop();
 
         $_SERVER['test'] = 'subdomain.test.com';
 
         StderrMock::start();
-        $this->assertEquals('localhost', rcube_utils::server_name('test'));
+        $this->assertEquals('localhost', \rcube_utils::server_name('test'));
         StderrMock::stop();
 
         $rcube->config->set('trusted_host_patterns', ['^test.com$']);
         $_SERVER['test'] = '^test.com$';
 
         StderrMock::start();
-        $this->assertEquals('localhost', rcube_utils::server_name('test'));
+        $this->assertEquals('localhost', \rcube_utils::server_name('test'));
         StderrMock::stop();
     }
 }
diff --git a/tests/Framework/VCard.php b/tests/Framework/VCard.php
index c555871..a137511 100644
--- a/tests/Framework/VCard.php
+++ b/tests/Framework/VCard.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Unit tests for class rcube_vcard
- *
- * @package Tests
  */
-class Framework_VCard extends PHPUnit\Framework\TestCase
+class Framework_VCard extends TestCase
 {
 
     function _srcpath($fn)
@@ -15,7 +17,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
 
     function test_parse_one()
     {
-        $vcard = new rcube_vcard(file_get_contents($this->_srcpath('apple.vcf')));
+        $vcard = new \rcube_vcard(file_get_contents($this->_srcpath('apple.vcf')));
 
         $this->assertTrue($vcard->business, "Identify as business record");
         $this->assertEquals("Apple Computer AG", $vcard->displayname, "FN => displayname");
@@ -24,7 +26,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
 
     function test_parse_two()
     {
-        $vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
+        $vcard = new \rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
 
         $this->assertFalse($vcard->business, "Identify as private record");
         $this->assertEquals("John Doë", $vcard->displayname, "Decode according to charset attribute");
@@ -38,12 +40,12 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
      */
     function test_parse_three()
     {
-        $vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
+        $vcard = new \rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null);
 
         $vcf = $vcard->export();
         $this->assertMatchesRegularExpression('/TEL;CELL:\+987654321/', $vcf, "Return CELL instead of MOBILE (import)");
 
-        $vcard = new rcube_vcard();
+        $vcard = new \rcube_vcard();
         $vcard->set('phone', '+987654321', 'MOBILE');
 
         $vcf = $vcard->export();
@@ -56,7 +58,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
     function test_parse_four()
     {
         $vcard = "BEGIN:VCARD\nVERSION:3.0\nN:last\\;;first\\\\;middle\\\\\\;\\\\;prefix;\nFN:test\nEND:VCARD";
-        $vcard = new rcube_vcard($vcard, null);
+        $vcard = new \rcube_vcard($vcard, null);
         $vcard = $vcard->get_assoc();
 
         $this->assertEquals("last;", $vcard['surname'], "Decode backslash character");
@@ -71,7 +73,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
     function test_parse_five()
     {
         $vcard = "BEGIN:VCARD\nVERSION:3.0\nN:last\\\\\\a;fir\\nst\nURL:http\\://domain.tld\nEND:VCARD";
-        $vcard = new rcube_vcard($vcard, null);
+        $vcard = new \rcube_vcard($vcard, null);
         $vcard = $vcard->get_assoc();
 
         $this->assertEquals("last\\a", $vcard['surname'], "Decode dummy backslash character");
@@ -84,7 +86,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
      */
     function test_parse_six()
     {
-        $vcard = new rcube_vcard("BEGIN:VCARD\n"
+        $vcard = new \rcube_vcard("BEGIN:VCARD\n"
             . "VERSION:3.0\n"
             . "N:;;;;\n"
             . "FN:Apple Computer AG\n"
@@ -125,14 +127,14 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
         $input = file_get_contents($this->_srcpath('apple.vcf'));
         $input .= file_get_contents($this->_srcpath('johndoe.vcf'));
 
-        $vcards = rcube_vcard::import($input);
+        $vcards = \rcube_vcard::import($input);
 
         $this->assertCount(2, $vcards, "Detected 2 vcards");
         $this->assertEquals("Apple Computer AG", $vcards[0]->displayname, "FN => displayname");
         $this->assertEquals("John Doë", $vcards[1]->displayname, "Displayname with correct charset");
 
         // https://github.com/roundcube/roundcubemail/issues/1934
-        $vcards2 = rcube_vcard::import(file_get_contents($this->_srcpath('thebat.vcf')));
+        $vcards2 = \rcube_vcard::import(file_get_contents($this->_srcpath('thebat.vcf')));
         $this->assertEquals("Iksi=F1ski", quoted_printable_encode($vcards2[0]->surname));
 
         $vcards[0]->reset();
@@ -143,7 +145,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
     {
         $input = file_get_contents($this->_srcpath('photo.vcf'));
 
-        $vcards = rcube_vcard::import($input);
+        $vcards = \rcube_vcard::import($input);
 
         $this->assertCount(1, $vcards, "Detected 1 vcard");
 
@@ -155,7 +157,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
 
         $input = str_replace('ENCODING=b:', 'ENCODING=base64;jpeg:', $input);
 
-        $vcards = rcube_vcard::import($input);
+        $vcards = \rcube_vcard::import($input);
         $vcard = $vcards[0]->get_assoc();
 
         // ENCODING=base64 case (#1489977)
@@ -163,7 +165,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
 
         $input = str_replace('PHOTO;ENCODING=base64;jpeg:', 'PHOTO:data:image/jpeg;base64,', $input);
 
-        $vcards = rcube_vcard::import($input);
+        $vcards = \rcube_vcard::import($input);
         $vcard = $vcards[0]->get_assoc();
 
         // vcard4.0 "PHOTO:data:image/jpeg;base64," case (#1489977)
@@ -174,7 +176,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
     {
         $input = file_get_contents($this->_srcpath('utf-16_sample.vcf'));
 
-        $vcards = rcube_vcard::import($input);
+        $vcards = \rcube_vcard::import($input);
         $this->assertEquals("Ǽgean ĽdaMonté", $vcards[0]->displayname, "Decoded from UTF-16");
     }
 
@@ -183,7 +185,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
      */
     function test_parse_skip_empty()
     {
-        $vcard = new rcube_vcard("BEGIN:VCARD\n"
+        $vcard = new \rcube_vcard("BEGIN:VCARD\n"
             . "VERSION:3.0\n"
             . "N:;;;;\n"
             . "FN:Test\n"
@@ -208,7 +210,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
     function test_bday_v4()
     {
         $vcard = "BEGIN:VCARD\nVERSION:4.0\nN:last\\;;first\\\\;middle\\\\\\;\\\\;prefix;\nFN:test\nBDAY:19800202\nEND:VCARD";
-        $vcard = new rcube_vcard($vcard, null);
+        $vcard = new \rcube_vcard($vcard, null);
         $vcard = $vcard->get_assoc();
 
         $this->assertEquals("1980-02-02", $vcard['birthday'][0]);
@@ -219,7 +221,7 @@ class Framework_VCard extends PHPUnit\Framework\TestCase
      */
     function test_required_fields()
     {
-        $vcard = new rcube_vcard();
+        $vcard = new \rcube_vcard();
         $result = $vcard->export();
 
         $this->assertSame($result, "BEGIN:VCARD\r\nVERSION:3.0\r\nFN:\r\nN:;;;;\r\nEND:VCARD");
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index 0b9e1e9..a3a6d5b 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -1,11 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Framework;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcube_washtml class
- *
- * @package Tests
  */
-class Framework_Washtml extends PHPUnit\Framework\TestCase
+class Framework_Washtml extends TestCase
 {
     /**
      * A helper method to remove comments added by rcube_washtml
@@ -27,7 +30,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
             .'<A HREF="vbscript:alert(document.cookie)">Internet Explorer</a>'
             .'<a href="data:application/xhtml+xml;base64,PGh0bW">CLICK ME</a>'; // #6896
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertDoesNotMatchRegularExpression('/data:text/', $washed, "Remove data:text/html links");
@@ -42,7 +45,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<p><a href=\"\nhttp://test.com\n\">Firefox</a><a href=\"domain.com\">Firefox</a>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression('|href="http://test\.com"|', $washed, "Link href with newlines (#1488940)");
@@ -56,7 +59,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<p><img src=\"data:image/png;base64,12345\n\t67890\" /></p>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertSame("<p><img src=\"data:image/png;base64,12345\n\t67890\" /></p>", $this->cleanupResult($washed));
@@ -74,7 +77,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
             . '<Area href="vbscript:alert(document.cookie)">Internet Explorer</p>'
             . '<area HREF="javascript:alert(document.domain)" shape=default>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertDoesNotMatchRegularExpression('/data:text/', $washed, "data:text/html in area href");
@@ -91,7 +94,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
                ."<param name=\"foo\" value=\"bar\">\n"
                ."<p>This alternative text should survive</p>"
                ."</object>\n</div>";
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertDoesNotMatchRegularExpression('/<\/?object/', $washed, "Remove object tag");
@@ -104,7 +107,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
      */
     function test_comments()
     {
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
 
         $html   = "<!--[if gte mso 10]><p>p1</p><!--><p>p2</p>";
         $washed = $this->cleanupResult($washer->wash($html));
@@ -144,7 +147,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<textarea>test";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression('|<textarea>test</textarea>|', $washed);
@@ -157,7 +160,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<a href=\"http://test.com\">test</a href>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression('|</a>|', $washed);
@@ -200,7 +203,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($data as $element) {
-            rcube_washtml::fix_broken_lists($element[0]);
+            \rcube_washtml::fix_broken_lists($element[0]);
 
             $this->assertSame($element[1], $element[0], "Broken nested lists (#1488768)");
         }
@@ -213,7 +216,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<p style=\"font-size: 10px; color: rgb(241, 245, 218)\">a</p>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression('|color: rgb\(241, 245, 218\)|', $washed, "Color style (#1489697)");
@@ -228,7 +231,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         $html = "<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
             <body><span style='font-family:\"新細明體\",\"serif\";color:red'>test</span></body></html>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression(
@@ -240,7 +243,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         $html = "<html><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
             <body><span style='font-family:新細明體;color:red'>test</span></body></html>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression(
@@ -259,7 +262,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
             <body bgcolor=\"#fff\" text=\"#000\" background=\"#test\" link=\"#111\" alink=\"#222\" vlink=\"#333\">
             </body></html>";
 
-        $washer = new rcube_washtml(['html_elements' => ['body']]);
+        $washer = new \rcube_washtml(['html_elements' => ['body']]);
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression('|bgcolor="#fff"|', $washed, "Body bgcolor attribute");
@@ -277,7 +280,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<p style=\"line-height: 1; height: 10\">a</p>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertMatchesRegularExpression('|line-height: 1;|', $washed, "Untouched line-height (#1489917)");
@@ -286,7 +289,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         $html     = "<div style=\"padding: 0px\n   20px;border:1px solid #000;\"></div>";
         $expected = "<div style=\"padding: 0px 20px; border: 1px solid #000\"></div>";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertSame($this->cleanupResult($washed), $expected, 'White-space and new-line characters handling');
@@ -300,7 +303,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         $html = "<img style=aaa:'\"/onerror=alert(1)//'>";
         $exp  = "<img style=\"aaa: '&quot;/onerror=alert(1)//'\" />";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertTrue(strpos($washed, $exp) !== false, "Style quotes XSS issue (#1490227)");
@@ -308,7 +311,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         $html = "<img style=aaa:'&quot;/onerror=alert(1)//'>";
         $exp  = "<img style=\"aaa: '&quot;/onerror=alert(1)//'\" />";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertTrue(strpos($washed, $exp) !== false, "Style quotes XSS issue (#1490227)");
@@ -326,7 +329,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
      */
     function test_title()
     {
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
 
         $html = "<html><head><title>title1</title></head><body><p>test</p></body>";
         $washed = $washer->wash($html);
@@ -372,7 +375,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
   <!-- animate blocked -->
 </svg>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($svg);
 
         $this->assertSame($washed, $exp, "SVG content");
@@ -381,7 +384,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     /**
      * Test cases for SVG tests
      */
-    function data_wash_svg_tests()
+    static function data_wash_svg_tests()
     {
         $svg1 = "<svg id='x' width='100' height='100'><a xlink:href='javascript:alert(1)'><rect x='0' y='0' width='100' height='100' /></a></svg>";
 
@@ -500,9 +503,10 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_wash_svg_tests
      */
+    #[DataProvider('data_wash_svg_tests')]
     function test_wash_svg_tests($input, $expected)
     {
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($input);
 
         $this->assertSame($expected, $this->cleanupResult($washed), "SVG content");
@@ -511,7 +515,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     /**
      * Test cases for various XSS issues
      */
-    function data_wash_xss_tests()
+    static function data_wash_xss_tests()
     {
         return [
             [
@@ -566,9 +570,10 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_wash_xss_tests
      */
+    #[DataProvider('data_wash_xss_tests')]
     function test_wash_xss_tests($input, $expected)
     {
-        $washer = new rcube_washtml(['allow_remote' => true, 'html_elements' => ['body']]);
+        $washer = new \rcube_washtml(['allow_remote' => true, 'html_elements' => ['body']]);
         $washed = $washer->wash($input);
 
         $this->assertSame($expected, $this->cleanupResult($washed), "XSS issues");
@@ -582,7 +587,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         $html = "<img style='position:fixed' /><img style=\"position:/**/ fixed; top:10px\" />";
         $exp  = "<img style=\"position: absolute\" /><img style=\"position: absolute; top: 10px\" />";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertTrue(strpos($washed, $exp) !== false, "Position:fixed (#5264)");
@@ -626,7 +631,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
                 <annotation encoding="TeX">I_D = \frac{1}{2} k_n \frac{W}{L} (V_{GS}-V_t)^2</annotation>
             </semantics></math>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($mathml);
 
         // remove whitespace between tags
@@ -643,7 +648,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = "<input type=\"image\" src=\"http://TRACKING_URL/\">";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertTrue($washer->extlinks);
@@ -651,7 +656,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
 
         $html = "<video src=\"http://TRACKING_URL/\">";
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertTrue($washer->extlinks);
@@ -672,14 +677,14 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
         ];
 
         foreach ($html as $item) {
-            $washer = new rcube_washtml;
+            $washer = new \rcube_washtml();
             $washed = $washer->wash($item[0]);
 
             $this->assertSame($item[1], $washer->extlinks);
         }
 
         foreach ($html as $item) {
-            $washer = new rcube_washtml(['allow_remote' => true]);
+            $washer = new \rcube_washtml(['allow_remote' => true]);
             $washed = $washer->wash($item[0]);
 
             $this->assertFalse($washer->extlinks);
@@ -690,7 +695,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = '<textarea><p style="x:</textarea><img src=x onerror=alert(1)>">';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertStringNotContainsString('onerror=alert(1)>', $washed);
@@ -702,7 +707,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
      */
     function test_css_prefix()
     {
-        $washer = new rcube_washtml(['css_prefix' => 'test']);
+        $washer = new \rcube_washtml(['css_prefix' => 'test']);
 
         $html   = '<p id="my-id">'
             . '<label for="my-other-id" class="my-class1 my-class2">test</label>'
@@ -730,14 +735,14 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = '<p><?xml:namespace prefix = "xsl" /></p>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $this->cleanupResult($washer->wash($html));
 
         $this->assertSame($washed, '<p></p>');
 
         $html = '<?xml encoding="UTF-8"><html><body>HTML</body></html>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $this->cleanupResult($washer->wash($html));
 
         $this->assertSame($washed, 'HTML');
@@ -748,7 +753,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
      */
     function test_missing_tags()
     {
-        $washer = new rcube_washtml();
+        $washer = new \rcube_washtml();
 
         $html   = '<head></head>First line<br />Second line';
         $washed = $washer->wash($html);
@@ -790,7 +795,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     {
         $html = '<p><![CDATA[<script>alert(document.cookie)</script>]]></p>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $washer->wash($html);
 
         $this->assertTrue(strpos($washed, '<script>') === false, "CDATA content");
@@ -802,7 +807,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
     function test_resolve_base()
     {
         $html = file_get_contents(TESTS_DIR . 'src/htmlbase.txt');
-        $html = rcube_washtml::resolve_base($html);
+        $html = \rcube_washtml::resolve_base($html);
 
         $this->assertMatchesRegularExpression('|src="http://alec\.pl/dir/img1\.gif"|', $html, "URI base resolving [1]");
         $this->assertMatchesRegularExpression('|src="http://alec\.pl/dir/img2\.gif"|', $html, "URI base resolving [2]");
@@ -848,7 +853,7 @@ class Framework_Washtml extends PHPUnit\Framework\TestCase
   <tr><td></td></tr>
 </table>';
 
-        $washer = new rcube_washtml;
+        $washer = new \rcube_washtml();
         $washed = $this->cleanupResult($washer->wash($html));
 
         $this->assertSame(trim($expected), $washed);
diff --git a/tests/OutputHtmlMock.php b/tests/OutputHtmlMock.php
index 53bdc25..b4facb1 100644
--- a/tests/OutputHtmlMock.php
+++ b/tests/OutputHtmlMock.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace Roundcube\Tests;
+
 /**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
@@ -19,10 +21,8 @@
 
 /**
  * A class for easier testing of code that uses rcmail_output classes
- *
- * @package Tests
  */
-class OutputHtmlMock extends rcmail_output_html
+class OutputHtmlMock extends \rcmail_output_html
 {
     const E_EXIT     = 101;
     const E_REDIRECT = 102;
diff --git a/tests/OutputJsonMock.php b/tests/OutputJsonMock.php
index b803a3a..b22942c 100644
--- a/tests/OutputJsonMock.php
+++ b/tests/OutputJsonMock.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace Roundcube\Tests;
+
 /**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
@@ -19,10 +21,8 @@
 
 /**
  * A class for easier testing of code that uses rcmail_output classes
- *
- * @package Tests
  */
-class OutputJsonMock extends rcmail_output_json
+class OutputJsonMock extends \rcmail_output_json
 {
     const E_EXIT     = 101;
     const E_REDIRECT = 102;
diff --git a/tests/Rcmail/Action.php b/tests/Rcmail/Action.php
index 11bf233..7e6deb9 100644
--- a/tests/Rcmail/Action.php
+++ b/tests/Rcmail/Action.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_action class
- *
- * @package Tests
  */
-class Rcmail_RcmailAction extends ActionTestCase
+class Rcmail_Action extends ActionTestCase
 {
 
     /**
@@ -13,14 +15,14 @@ class Rcmail_RcmailAction extends ActionTestCase
      */
     function test_set_env_config()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $this->assertFalse($rcmail->config->get('ip_check'));
-        rcmail_action::set_env_config(['ip_check']);
+        \rcmail_action::set_env_config(['ip_check']);
         $this->assertNull($rcmail->output->get_env('ip_check'));
 
         $rcmail->config->set('ip_check', true);
-        rcmail_action::set_env_config(['ip_check']);
+        \rcmail_action::set_env_config(['ip_check']);
         $this->assertTrue($rcmail->output->get_env('ip_check'));
     }
 
@@ -32,7 +34,7 @@ class Rcmail_RcmailAction extends ActionTestCase
         $attrib = [];
         $table_data = [];
 
-        $result = rcmail_action::table_output($attrib, $table_data, ['id'], 'id');
+        $result = \rcmail_action::table_output($attrib, $table_data, ['id'], 'id');
         $expected = '<table border="0"><thead><tr><th class="id">[id]</th></tr></thead><tbody></tbody></table>';
         $this->assertSame($expected, $result);
 
@@ -116,7 +118,7 @@ class Rcmail_RcmailAction extends ActionTestCase
      */
     function test_font_defs()
     {
-        $result = rcmail_action::font_defs();
+        $result = \rcmail_action::font_defs();
         $this->assertCount(13, $result);
     }
 
@@ -125,13 +127,13 @@ class Rcmail_RcmailAction extends ActionTestCase
      */
     function test_show_bytes()
     {
-        $result = rcmail_action::show_bytes(0);
+        $result = \rcmail_action::show_bytes(0);
         $this->assertSame('0 B', $result);
 
-        $result = rcmail_action::show_bytes(2000, $unit);
+        $result = \rcmail_action::show_bytes(2000, $unit);
         $this->assertSame('2 KB', $result);
 
-        $result = rcmail_action::show_bytes(2000000, $unit);
+        $result = \rcmail_action::show_bytes(2000000, $unit);
         $this->assertSame('1.9 MB', $result);
         $this->assertSame('MB', $unit);
     }
@@ -149,28 +151,28 @@ class Rcmail_RcmailAction extends ActionTestCase
      */
     function test_get_uids()
     {
-        $result = rcmail_action::get_uids();
+        $result = \rcmail_action::get_uids();
         $this->assertSame([], $result);
 
         $_GET = [
             '_mbox' => 'Test<a>',
             '_uid' => '1',
         ];
-        $result = rcmail_action::get_uids(null, null, $is_multifolder);
+        $result = \rcmail_action::get_uids(null, null, $is_multifolder);
         $this->assertSame(['Test<a>' => ['1']], $result);
         $this->assertFalse($is_multifolder);
 
         $_GET = [
             '_uid' => '1-Test<a>',
         ];
-        $result = rcmail_action::get_uids(null, null, $is_multifolder);
+        $result = \rcmail_action::get_uids(null, null, $is_multifolder);
         $this->assertSame(['Test<a>' => ['1']], $result);
         $this->assertTrue($is_multifolder);
 
         $_GET = [
             '_uid' => '1-Test<a>,2-INBOX',
         ];
-        $result = rcmail_action::get_uids(null, null, $is_multifolder);
+        $result = \rcmail_action::get_uids(null, null, $is_multifolder);
         $this->assertSame(['Test<a>' => ['1'], 'INBOX' => ['2']], $result);
         $this->assertTrue($is_multifolder);
 
@@ -178,7 +180,7 @@ class Rcmail_RcmailAction extends ActionTestCase
             '_mbox' => 'INBOX',
             '_uid' => '*',
         ];
-        $result = rcmail_action::get_uids(null, null, $is_multifolder);
+        $result = \rcmail_action::get_uids(null, null, $is_multifolder);
         $this->assertSame(['INBOX' => '*'], $result);
         $this->assertFalse($is_multifolder);
 
@@ -186,7 +188,7 @@ class Rcmail_RcmailAction extends ActionTestCase
             '_mbox' => 'INBOX',
             '_uid' => '1.1',
         ];
-        $result = rcmail_action::get_uids(null, null, $is_multifolder);
+        $result = \rcmail_action::get_uids(null, null, $is_multifolder);
         $this->assertSame(['INBOX' => ['1.1']], $result);
         $this->assertFalse($is_multifolder);
 
@@ -194,7 +196,7 @@ class Rcmail_RcmailAction extends ActionTestCase
             '_mbox' => 'INBOX',
             '_uid' => '1:2,56',
         ];
-        $result = rcmail_action::get_uids(null, null, $is_multifolder);
+        $result = \rcmail_action::get_uids(null, null, $is_multifolder);
         $this->assertSame(['INBOX' => ['1:2','56']], $result);
         $this->assertFalse($is_multifolder);
     }
@@ -204,7 +206,7 @@ class Rcmail_RcmailAction extends ActionTestCase
      */
     function test_get_resource_content()
     {
-        $result = rcmail_action::get_resource_content('blocked.gif');
+        $result = \rcmail_action::get_resource_content('blocked.gif');
         $this->assertTrue(strpos($result, 'GIF89') === 0);
     }
 
diff --git a/tests/Rcmail/AttachmentHandler.php b/tests/Rcmail/AttachmentHandler.php
index 089ad93..e2e5814 100644
--- a/tests/Rcmail/AttachmentHandler.php
+++ b/tests/Rcmail/AttachmentHandler.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_attachment_handler class
- *
- * @package Tests
  */
-class Rcmail_RcmailAttachmentHandler extends ActionTestCase
+class Rcmail_AttachmentHandler extends ActionTestCase
 {
 
     /**
@@ -16,7 +18,7 @@ class Rcmail_RcmailAttachmentHandler extends ActionTestCase
         $svg = '<svg><a xlink:href="javascript:alert(1)"><text x="20" y="20">XSS</text></a></svg>';
         $exp = '<svg><a><text x="20" y="20">XSS</text></a></svg>';
 
-        $out = rcmail_attachment_handler::svg_filter($svg);
+        $out = \rcmail_attachment_handler::svg_filter($svg);
 
         $this->assertSame($exp, $out);
     }
diff --git a/tests/Rcmail/HtmlPage.php b/tests/Rcmail/HtmlPage.php
index 7801b94..d47dd88 100644
--- a/tests/Rcmail/HtmlPage.php
+++ b/tests/Rcmail/HtmlPage.php
@@ -1,18 +1,20 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_html_page class
- *
- * @package Tests
  */
-class Rcmail_RcmailHtmlPage extends ActionTestCase
+class Rcmail_HtmlPage extends ActionTestCase
 {
     /**
      * Test html page output
      */
     function test_html_output()
     {
-        $page = new rcmail_html_page();
+        $page = new \rcmail_html_page();
 
         $page->register_inline_warning('Test', 'Button', 'http://url');
 
diff --git a/tests/Rcmail/Install.php b/tests/Rcmail/Install.php
index 6914151..3282db2 100644
--- a/tests/Rcmail/Install.php
+++ b/tests/Rcmail/Install.php
@@ -1,18 +1,20 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_install class
- *
- * @package Tests
  */
-class Rcmail_RcmailInstall extends ActionTestCase
+class Rcmail_Install extends ActionTestCase
 {
     /**
      * Test getprop() method
      */
     function test_getprop()
     {
-        $install = rcmail_install::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $this->assertSame('default', $install->getprop('unknown', 'default'));
         $this->assertSame('', $install->getprop('unknown'));
@@ -23,7 +25,7 @@ class Rcmail_RcmailInstall extends ActionTestCase
      */
     function test_create_config()
     {
-        $install = rcmail_install::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $config = $install->create_config();
 
@@ -51,8 +53,8 @@ class Rcmail_RcmailInstall extends ActionTestCase
      */
     function test_db_schema_check()
     {
-        $rcmail  = rcmail::get_instance();
-        $install = rcmail_install::get_instance();
+        $rcmail  = \rcmail::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $result = $install->db_schema_check($rcmail->get_dbh());
 
@@ -64,8 +66,8 @@ class Rcmail_RcmailInstall extends ActionTestCase
      */
     function test_check_mime_detection()
     {
-        $rcmail  = rcmail::get_instance();
-        $install = rcmail_install::get_instance();
+        $rcmail  = \rcmail::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $result = $install->check_mime_detection();
 
@@ -77,8 +79,8 @@ class Rcmail_RcmailInstall extends ActionTestCase
      */
     function test_check_mime_extensions()
     {
-        $rcmail  = rcmail::get_instance();
-        $install = rcmail_install::get_instance();
+        $rcmail  = \rcmail::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $result = $install->check_mime_extensions();
 
@@ -90,8 +92,8 @@ class Rcmail_RcmailInstall extends ActionTestCase
      */
     function test_list_skins()
     {
-        $rcmail  = rcmail::get_instance();
-        $install = rcmail_install::get_instance();
+        $rcmail  = \rcmail::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $result = $install->list_skins();
 
@@ -103,8 +105,8 @@ class Rcmail_RcmailInstall extends ActionTestCase
      */
     function test_list_plugins()
     {
-        $rcmail  = rcmail::get_instance();
-        $install = rcmail_install::get_instance();
+        $rcmail  = \rcmail::get_instance();
+        $install = \rcmail_install::get_instance();
 
         $result = $install->list_plugins();
 
@@ -127,7 +129,7 @@ class Rcmail_RcmailInstall extends ActionTestCase
             'smtp_host' => 'ssl://test:465',
         ];
 
-        $install = rcmail_install::get_instance();
+        $install = \rcmail_install::get_instance();
         $install->configured = true;
         $install->config = $config;
 
diff --git a/tests/Rcmail/Oauth.php b/tests/Rcmail/Oauth.php
index 1fd2c97..a9d4352 100644
--- a/tests/Rcmail/Oauth.php
+++ b/tests/Rcmail/Oauth.php
@@ -1,11 +1,13 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_oauth class
- *
- * @package Tests
  */
-class Rcmail_RcmailOauth extends ActionTestCase
+class Rcmail_Oauth extends ActionTestCase
 {
     /**
      * Test jwt_decode() method with an invalid token
@@ -14,7 +16,7 @@ class Rcmail_RcmailOauth extends ActionTestCase
     {
         $jwt = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.EkN-DOsnsuRjRO6BxXemmJDm3HbxrbRzXglbN2S4sOkopdU4IsDxTI8jO19W_A4K8ZPJijNLis4EZsHeY559a4DFOd50_OqgHGuERTqYZyuhtF39yxJPAjUESwxk2J5k_4zM3O-vtd1Ghyo4IbqKKSy6J9mTniYJPenn5-HIirE';
 
-        $oauth = rcmail_oauth::get_instance();
+        $oauth = \rcmail_oauth::get_instance();
 
         // We can't use expectException until we drop support for phpunit 4.8 (i.e. PHP 5.4)
         // $this->expectException(RuntimeException::class);
@@ -22,7 +24,7 @@ class Rcmail_RcmailOauth extends ActionTestCase
         try {
             $oauth->jwt_decode($jwt);
         }
-        catch (RuntimeException $e) {
+        catch (\RuntimeException $e) {
         }
 
         $this->assertTrue(isset($e));
@@ -35,7 +37,7 @@ class Rcmail_RcmailOauth extends ActionTestCase
     {
         $jwt = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImF1ZCI6WyJzb21lLWNsaWVudCJdfQ.signature';
 
-        $oauth = new rcmail_oauth([
+        $oauth = new \rcmail_oauth([
             'client_id' => 'some-client',
         ]);
         $body = $oauth->jwt_decode($jwt);
@@ -49,7 +51,7 @@ class Rcmail_RcmailOauth extends ActionTestCase
     {
         $jwt = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImF1ZCI6InNvbWUtY2xpZW50In0.signature';
 
-        $oauth = new rcmail_oauth([
+        $oauth = new \rcmail_oauth([
             'client_id' => 'some-client',
         ]);
         $body = $oauth->jwt_decode($jwt);
@@ -61,7 +63,7 @@ class Rcmail_RcmailOauth extends ActionTestCase
      */
     function test_is_enabled()
     {
-        $oauth = rcmail_oauth::get_instance();
+        $oauth = \rcmail_oauth::get_instance();
 
         $this->assertFalse($oauth->is_enabled());
     }
@@ -71,7 +73,7 @@ class Rcmail_RcmailOauth extends ActionTestCase
      */
     function test_get_redirect_uri()
     {
-        $oauth = rcmail_oauth::get_instance();
+        $oauth = \rcmail_oauth::get_instance();
 
         $this->assertMatchesRegularExpression('|^http://.*/index.php/login/oauth$|', $oauth->get_redirect_uri());
     }
diff --git a/tests/Rcmail/OutputCli.php b/tests/Rcmail/OutputCli.php
index 98beb09..a8cd606 100644
--- a/tests/Rcmail/OutputCli.php
+++ b/tests/Rcmail/OutputCli.php
@@ -1,19 +1,21 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_output_cli class
- *
- * @package Tests
  */
-class Rcmail_RcmailOutputCli extends ActionTestCase
+class Rcmail_OutputCli extends ActionTestCase
 {
     /**
      * Test show_message() method
      */
     function test_show_message()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_cli();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_cli();
 
         ob_start();
         $output->show_message('unknown');
diff --git a/tests/Rcmail/OutputHtml.php b/tests/Rcmail/OutputHtml.php
index b38fbfe..586ad03 100644
--- a/tests/Rcmail/OutputHtml.php
+++ b/tests/Rcmail/OutputHtml.php
@@ -1,19 +1,22 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcmail_output_html class
- *
- * @package Tests
  */
-class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
+class Rcmail_OutputHtml extends TestCase
 {
     /**
      * Test check_skin()
      */
     function test_check_skin()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertTrue($output->check_skin('elastic'));
         $this->assertFalse($output->check_skin('unknown'));
@@ -24,8 +27,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_get_skin_file()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $output->set_skin('elastic');
 
@@ -38,9 +41,9 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_logo()
     {
-        $rcmail            = rcube::get_instance();
-        $output            = new rcmail_output_html();
-        $reflection        = new ReflectionClass('rcmail_output_html');
+        $rcmail            = \rcube::get_instance();
+        $output            = new \rcmail_output_html();
+        $reflection        = new \ReflectionClass('rcmail_output_html');
         $set_skin          = $reflection->getProperty('skin_name');
         $set_template      = $reflection->getProperty('template_name');
         $get_template_logo = $reflection->getMethod('get_template_logo');
@@ -273,7 +276,7 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
     /**
      * Data for test_conditions()
      */
-    function data_conditions()
+    static function data_conditions()
     {
         $txt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt "
             . "ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco "
@@ -317,9 +320,10 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      *
      * @dataProvider data_conditions
      */
+    #[DataProvider('data_conditions')]
     function test_conditions($input, $output)
     {
-        $object = new rcmail_output_html;
+        $object = new \rcmail_output_html();
         $result = $object->just_parse($input);
 
         $this->assertEquals($output, $result);
@@ -330,8 +334,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_reset()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertNull($output->reset());
     }
@@ -341,8 +345,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_abs_url()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertSame('test', $output->abs_url('test'));
         $this->assertSame('skins/elastic/ui.js', $output->abs_url('/ui.js'));
@@ -353,8 +357,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_asset_url()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertSame('http://test', $output->asset_url('http://test'));
         $this->assertSame('/ui.js', $output->asset_url('/ui.js'));
@@ -366,8 +370,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_button()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertSame('', $output->button([]));
 
@@ -380,8 +384,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_form_tag()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertSame('<form action="/usr/bin/phpunit?_task=cli" method="get">test</form>', $output->form_tag([], 'test'));
     }
@@ -391,8 +395,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_request_form()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $this->assertSame('<form action="./" method="get">test</form>', $output->request_form([], 'test'));
     }
@@ -402,8 +406,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_search_form()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $expected = '<form name="rcmqsearchform" onsubmit="rcmail.command(\'search\'); return false"'
             . ' action="/usr/bin/phpunit?_task=cli" method="get"><label for="rcmqsearchbox" class="voice">Search terms</label>'
@@ -417,8 +421,8 @@ class Rcmail_RcmailOutputHtml extends PHPUnit\Framework\TestCase
      */
     function test_charset_selector()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_html();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_html();
 
         $result = $output->charset_selector([]);
 
diff --git a/tests/Rcmail/OutputJson.php b/tests/Rcmail/OutputJson.php
index bcf8cba..bd4a2a6 100644
--- a/tests/Rcmail/OutputJson.php
+++ b/tests/Rcmail/OutputJson.php
@@ -1,21 +1,23 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_output_json class
- *
- * @package Tests
  */
-class Rcmail_RcmailOutputJson extends ActionTestCase
+class Rcmail_OutputJson extends ActionTestCase
 {
     /**
      * Test show_message() method
      */
     function test_show_message()
     {
-        $rcmail = rcube::get_instance();
-        $output = new rcmail_output_json();
+        $rcmail = \rcube::get_instance();
+        $output = new \rcmail_output_json();
 
-        $reflection = new ReflectionClass($output);
+        $reflection = new \ReflectionClass($output);
         $commands   = $reflection->getProperty('commands');
         $commands->setAccessible(true);
 
diff --git a/tests/Rcmail/Rcmail.php b/tests/Rcmail/Rcmail.php
index 4a16b38..c655336 100644
--- a/tests/Rcmail/Rcmail.php
+++ b/tests/Rcmail/Rcmail.php
@@ -1,9 +1,14 @@
 <?php
 
+
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+use Roundcube\Tests\ExitException;
+use Roundcube\Tests\OutputJsonMock;
+
 /**
  * Test class to test rcmail class
- *
- * @package Tests
  */
 class Rcmail_Rcmail extends ActionTestCase
 {
@@ -16,7 +21,7 @@ class Rcmail_Rcmail extends ActionTestCase
         $_SERVER['HTTPS'] = true;
         $_SERVER['X_FORWARDED_PATH'] = '/proxied/';
 
-        rcmail::get_instance()->filename = '';
+        \rcmail::get_instance()->filename = '';
     }
 
     /**
@@ -24,10 +29,10 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_action_handler()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         // Test keep-alive action handler
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'test', 'keep-alive');
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'test', 'keep-alive');
 
         try {
             $rcmail->action_handler();
@@ -41,7 +46,7 @@ class Rcmail_Rcmail extends ActionTestCase
         $this->assertTrue(empty($result['exec']));
 
         // Test refresh action handler
-        $output = $this->initOutput(rcmail_action::MODE_AJAX, 'settings', 'refresh');
+        $output = $this->initOutput(\rcmail_action::MODE_AJAX, 'settings', 'refresh');
 
         try {
             $rcmail->action_handler();
@@ -62,11 +67,11 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_get_address_book()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $result = $rcmail->get_address_book(0);
 
-        $this->assertInstanceOf('rcube_contacts', $result);
+        $this->assertInstanceOf(\rcube_contacts::class, $result);
 
         $source_id = $rcmail->get_address_book_id($result);
 
@@ -102,7 +107,7 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_get_address_sources()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $result = $rcmail->get_address_sources();
 
@@ -124,7 +129,7 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_url()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $this->assertEquals(
             '/sub/?_task=cli&_action=test',
@@ -210,9 +215,9 @@ class Rcmail_Rcmail extends ActionTestCase
     {
         self::initDB('contacts');
 
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
         $db     = $rcmail->get_dbh();
-        $source = $rcmail->get_address_book(rcube_addressbook::TYPE_DEFAULT, true);
+        $source = $rcmail->get_address_book(\rcube_addressbook::TYPE_DEFAULT, true);
 
         $contact_id = $rcmail->contact_create(['email' => 'test@xn--e1aybc.xn--p1ai'], $source, $error);
 
@@ -225,11 +230,11 @@ class Rcmail_Rcmail extends ActionTestCase
         $this->assertSame('test@тест.рф', $contact['email']);
         $this->assertSame('Test', $contact['name']);
 
-        $result = $rcmail->contact_exists('test@xn--e1aybc.xn--p1ai', rcube_addressbook::TYPE_DEFAULT);
+        $result = $rcmail->contact_exists('test@xn--e1aybc.xn--p1ai', \rcube_addressbook::TYPE_DEFAULT);
 
         $this->assertTrue($result);
 
-        $result = $rcmail->contact_exists('test@тест.рф', rcube_addressbook::TYPE_DEFAULT);
+        $result = $rcmail->contact_exists('test@тест.рф', \rcube_addressbook::TYPE_DEFAULT);
 
         $this->assertTrue($result);
     }
@@ -239,7 +244,7 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_user_date()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $date = $rcmail->user_date();
 
@@ -251,7 +256,7 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_find_asset()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $result = $rcmail->find_asset('non-existing.js');
         $this->assertNull($result);
@@ -265,14 +270,14 @@ class Rcmail_Rcmail extends ActionTestCase
      */
     function test_format_date()
     {
-        $rcmail = rcmail::get_instance();
+        $rcmail = \rcmail::get_instance();
 
         $date = $rcmail->format_date(date('Y-m-d H:i:s'));
         $this->assertSame('Today ' . date('H:i'), $date);
 
         // Test various formats
         setlocale(LC_ALL, 'en_US');
-        $date = new DateTime('2020-06-01 12:20:30', new DateTimeZone('UTC'));
+        $date = new \DateTime('2020-06-01 12:20:30', new \DateTimeZone('UTC'));
 
         $this->assertSame('2020-06-01 12:20', $rcmail->format_date($date));
         $this->assertSame('2020-06-01 12:20', $rcmail->format_date($date, 'Y-m-d H:i'));
diff --git a/tests/Rcmail/ResendMail.php b/tests/Rcmail/ResendMail.php
index 040dd19..ca35c5c 100644
--- a/tests/Rcmail/ResendMail.php
+++ b/tests/Rcmail/ResendMail.php
@@ -1,18 +1,20 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use PHPUnit\Framework\TestCase;
+
 /**
  * Test class to test rcmail_resend_mail class
- *
- * @package Tests
  */
-class Rcmail_RcmailResendMail extends PHPUnit\Framework\TestCase
+class Rcmail_ResendMail extends TestCase
 {
     /**
      * Test for header() method
      */
     function test_headers()
     {
-        $mail = new rcmail_resend_mail();
+        $mail = new \rcmail_resend_mail();
 
         $result = $mail->headers();
 
diff --git a/tests/Rcmail/Sendmail.php b/tests/Rcmail/Sendmail.php
index 5fd3c74..04de0d9 100644
--- a/tests/Rcmail/Sendmail.php
+++ b/tests/Rcmail/Sendmail.php
@@ -1,11 +1,14 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use PHPUnit\Framework\Attributes\DataProvider;
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_sendmail class
- *
- * @package Tests
  */
-class Rcmail_RcmailSendmail extends ActionTestCase
+class Rcmail_Sendmail extends ActionTestCase
 {
     /**
      * Test rcmail_sendmail::headers_input()
@@ -17,7 +20,7 @@ class Rcmail_RcmailSendmail extends ActionTestCase
             '_from' => 'Sender <test@domain.tld>',
         ];
 
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $headers = $sendmail->headers_input();
 
         $this->assertSame('Test1 Test2', $headers['Subject']);
@@ -74,10 +77,10 @@ class Rcmail_RcmailSendmail extends ActionTestCase
         self::initDB('identities');
         self::initUser();
 
-        $db       = rcmail::get_instance()->get_dbh();
+        $db       = \rcmail::get_instance()->get_dbh();
         $query    = $db->query('SELECT * FROM `identities` WHERE `standard` = 1 LIMIT 1');
         $identity = $db->fetch_assoc($query);
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
 
         $result = $sendmail->get_identity($identity['identity_id']);
 
@@ -97,7 +100,7 @@ class Rcmail_RcmailSendmail extends ActionTestCase
     /**
      * Data for test_convert()
      */
-    function data_email_input_format()
+    static function data_email_input_format()
     {
         return [
             [
@@ -151,9 +154,10 @@ class Rcmail_RcmailSendmail extends ActionTestCase
     /**
      * @dataProvider data_email_input_format
      */
+    #[DataProvider('data_email_input_format')]
     function test_email_input_format($input, $output, $charset)
     {
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $sendmail->options['charset'] = $charset;
 
         $this->assertEquals($output, $sendmail->email_input_format($input));
@@ -173,24 +177,24 @@ class Rcmail_RcmailSendmail extends ActionTestCase
     function test_draftinfo_encode_and_decode()
     {
         $input  = ['test' => 'test'];
-        $result = rcmail_sendmail::draftinfo_encode($input);
+        $result = \rcmail_sendmail::draftinfo_encode($input);
         $this->assertEquals('test=test', $result);
-        $this->assertEquals($input, rcmail_sendmail::draftinfo_decode($result));
+        $this->assertEquals($input, \rcmail_sendmail::draftinfo_decode($result));
 
         $input  = ['folder' => 'test'];
-        $result =  rcmail_sendmail::draftinfo_encode($input);
+        $result =  \rcmail_sendmail::draftinfo_encode($input);
         $this->assertEquals('folder=B::dGVzdA==', $result);
-        $this->assertEquals($input, rcmail_sendmail::draftinfo_decode($result));
+        $this->assertEquals($input, \rcmail_sendmail::draftinfo_decode($result));
 
         $input  = ['test' => 'test;test'];
-        $result = rcmail_sendmail::draftinfo_encode($input);
+        $result = \rcmail_sendmail::draftinfo_encode($input);
         $this->assertEquals('test=B::dGVzdDt0ZXN0', $result);
-        $this->assertEquals($input, rcmail_sendmail::draftinfo_decode($result));
+        $this->assertEquals($input, \rcmail_sendmail::draftinfo_decode($result));
 
         $input  = ['test' => 'test;test', 'a' => 'b'];
-        $result = rcmail_sendmail::draftinfo_encode($input);
+        $result = \rcmail_sendmail::draftinfo_encode($input);
         $this->assertEquals('test=B::dGVzdDt0ZXN0; a=b', $result);
-        $this->assertEquals($input, rcmail_sendmail::draftinfo_decode($result));
+        $this->assertEquals($input, \rcmail_sendmail::draftinfo_decode($result));
     }
 
     /**
@@ -198,14 +202,14 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_headers_output()
     {
-        $message = new StdClass;
-        $message->headers = new rcube_message_header;
+        $message = new \StdClass();
+        $message->headers = new \rcube_message_header();
         $message->headers->charset = 'UTF-8';
         $message->headers->to = '';
         $message->headers->from = '';
         $message->headers->cc = '';
 
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $sendmail->options['charset'] = RCUBE_CHARSET;
         $sendmail->options['message'] = $message;
 
@@ -224,10 +228,10 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_reply_subject()
     {
-        $this->assertSame('Re: Test subject', rcmail_sendmail::reply_subject('Test subject'));
-        $this->assertSame('Re: Test subject', rcmail_sendmail::reply_subject('Re: Test subject'));
-        $this->assertSame('Re: Test subject', rcmail_sendmail::reply_subject('Re: Re: Test subject'));
-        $this->assertSame('Re: Test subject', rcmail_sendmail::reply_subject('Re: Test subject (Was: Something else)'));
+        $this->assertSame('Re: Test subject', \rcmail_sendmail::reply_subject('Test subject'));
+        $this->assertSame('Re: Test subject', \rcmail_sendmail::reply_subject('Re: Test subject'));
+        $this->assertSame('Re: Test subject', \rcmail_sendmail::reply_subject('Re: Re: Test subject'));
+        $this->assertSame('Re: Test subject', \rcmail_sendmail::reply_subject('Re: Test subject (Was: Something else)'));
     }
 
     /**
@@ -235,9 +239,9 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_compose_subject()
     {
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $sendmail->options['charset'] = RCUBE_CHARSET;
-        $sendmail->options['mode'] = rcmail_sendmail::MODE_REPLY;
+        $sendmail->options['mode'] = \rcmail_sendmail::MODE_REPLY;
 
         $_POST = ['_subject' => 'test'];
 
@@ -251,9 +255,9 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_mdn_checkbox()
     {
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $sendmail->options['charset'] = RCUBE_CHARSET;
-        $sendmail->options['mode'] = rcmail_sendmail::MODE_REPLY;
+        $sendmail->options['mode'] = \rcmail_sendmail::MODE_REPLY;
 
         $result = $sendmail->mdn_checkbox([]);
 
@@ -265,9 +269,9 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_dsn_checkbox()
     {
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $sendmail->options['charset'] = RCUBE_CHARSET;
-        $sendmail->options['mode'] = rcmail_sendmail::MODE_REPLY;
+        $sendmail->options['mode'] = \rcmail_sendmail::MODE_REPLY;
 
         $result = $sendmail->dsn_checkbox([]);
 
@@ -279,9 +283,9 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_priority_selector()
     {
-        $sendmail = new rcmail_sendmail();
+        $sendmail = new \rcmail_sendmail();
         $sendmail->options['charset'] = RCUBE_CHARSET;
-        $sendmail->options['mode'] = rcmail_sendmail::MODE_REPLY;
+        $sendmail->options['mode'] = \rcmail_sendmail::MODE_REPLY;
 
         $result = $sendmail->priority_selector([]);
 
@@ -301,14 +305,14 @@ class Rcmail_RcmailSendmail extends ActionTestCase
      */
     function test_identity_select()
     {
-        $message = new StdClass;
-        $message->headers = new rcube_message_header;
+        $message = new \StdClass();
+        $message->headers = new \rcube_message_header();
         $message->headers->charset = 'UTF-8';
         $message->headers->to = '';
         $message->headers->from = '';
         $message->headers->cc = '';
 
-        $result = rcmail_sendmail::identity_select($message, []);
+        $result = \rcmail_sendmail::identity_select($message, []);
         $this->assertSame(null, $result);
 
         $identities = [
@@ -344,26 +348,26 @@ class Rcmail_RcmailSendmail extends ActionTestCase
         $message->headers->to = 'ident2@domain.tld';
         $message->headers->from = 'from@other.domain.tld';
 
-        $result = rcmail_sendmail::identity_select($message, $identities);
+        $result = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[2], $result);
 
         $message->headers->to = 'ident1@domain.tld';
         $message->headers->from = 'from@other.domain.tld';
 
-        $result = rcmail_sendmail::identity_select($message, $identities);
+        $result = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[1], $result);
 
         // #7211
         $message->headers->to = 'ident1@domain.tld';
         $message->headers->from = 'ident2@domain.tld';
 
-        $result = rcmail_sendmail::identity_select($message, $identities);
+        $result = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[1], $result);
 
         $message->headers->to = 'ident2@domain.tld';
         $message->headers->from = 'ident1@domain.tld';
 
-        $result = rcmail_sendmail::identity_select($message, $identities);
+        $result = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[2], $result);
     }
 
@@ -390,15 +394,15 @@ class Rcmail_RcmailSendmail extends ActionTestCase
             ],
         ];
 
-        $message = new stdClass;
-        $message->headers = new rcube_message_header;
+        $message = new \stdClass();
+        $message->headers = new \rcube_message_header();
         $message->headers->set('Return-Path', '<some_thing@domain.tld>');
-        $res = rcmail_sendmail::identity_select($message, $identities);
+        $res = \rcmail_sendmail::identity_select($message, $identities);
 
         $this->assertSame($identities[0], $res);
 
         $message->headers->set('Return-Path', '<thing@domain.tld>');
-        $res = rcmail_sendmail::identity_select($message, $identities);
+        $res = \rcmail_sendmail::identity_select($message, $identities);
 
         $this->assertSame($identities[1], $res);
     }
@@ -431,23 +435,23 @@ class Rcmail_RcmailSendmail extends ActionTestCase
             ],
         ];
 
-        $message = new stdClass;
-        $message->headers = new rcube_message_header;
+        $message = new \stdClass();
+        $message->headers = new \rcube_message_header();
 
         $message->headers->set('From', '<addr2@domain.tld>');
-        $res = rcmail_sendmail::identity_select($message, $identities);
+        $res = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[1], $res);
 
         $message->headers->set('From', 'Test 2 <addr2@domain.tld>');
-        $res = rcmail_sendmail::identity_select($message, $identities);
+        $res = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[1], $res);
 
         $message->headers->set('From', 'Other <addr2@domain.tld>');
-        $res = rcmail_sendmail::identity_select($message, $identities);
+        $res = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[1], $res);
 
         $message->headers->set('From', 'Test 4 <addr2@domain.tld>');
-        $res = rcmail_sendmail::identity_select($message, $identities);
+        $res = \rcmail_sendmail::identity_select($message, $identities);
         $this->assertSame($identities[3], $res);
     }
 
diff --git a/tests/Rcmail/StringReplacer.php b/tests/Rcmail/StringReplacer.php
index 9ba4516..067c217 100644
--- a/tests/Rcmail/StringReplacer.php
+++ b/tests/Rcmail/StringReplacer.php
@@ -1,18 +1,22 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use PHPUnit\Framework\TestCase;
+
+use function Roundcube\Tests\invokeMethod;
+
 /**
  * Test class to test rcmail_string_replacer class
- *
- * @package Tests
  */
-class Rcmail_RcmailStringReplacer extends PHPUnit\Framework\TestCase
+class Rcmail_StringReplacer extends TestCase
 {
     /**
      * Test for mailto_callback() method
      */
     function test_mailto_callback()
     {
-        $replacer = new rcmail_string_replacer();
+        $replacer = new \rcmail_string_replacer();
 
         $result = invokeMethod($replacer, 'mailto_callback', [['email@address.com', 'email@address.com']]);
 
diff --git a/tests/Rcmail/Utils.php b/tests/Rcmail/Utils.php
index 78b99d6..421abb3 100644
--- a/tests/Rcmail/Utils.php
+++ b/tests/Rcmail/Utils.php
@@ -1,20 +1,22 @@
 <?php
 
+namespace Roundcube\Tests\Rcmail;
+
+use Roundcube\Tests\ActionTestCase;
+
 /**
  * Test class to test rcmail_utils class
- *
- * @package Tests
  */
-class Rcmail_RcmailUtils extends ActionTestCase
+class Rcmail_Utils extends ActionTestCase
 {
     /**
      * Test for db() method
      */
     function test_db()
     {
-        $db = rcmail_utils::db();
+        $db = \rcmail_utils::db();
 
-        $this->assertInstanceOf('rcube_db', $db);
+        $this->assertInstanceOf(\rcube_db::class, $db);
     }
 
     /**
@@ -25,7 +27,7 @@ class Rcmail_RcmailUtils extends ActionTestCase
         // FIXME: It breaks the test suite for some reason
         $this->markTestIncomplete();
 
-        $v = rcmail_utils::db_version();
+        $v = \rcmail_utils::db_version();
 
         $this->assertMatchesRegularExpression('/^[0-9]{10}$/', $v);
     }
@@ -36,7 +38,7 @@ class Rcmail_RcmailUtils extends ActionTestCase
     function test_db_clean()
     {
         ob_start();
-        rcmail_utils::db_clean(7);
+        \rcmail_utils::db_clean(7);
         $output = ob_get_contents();
         ob_end_clean();
 
@@ -51,7 +53,7 @@ class Rcmail_RcmailUtils extends ActionTestCase
         self::initDB('contacts');
 
         ob_start();
-        rcmail_utils::indexcontacts();
+        \rcmail_utils::indexcontacts();
         $output = ob_get_contents();
         ob_end_clean();
 
@@ -68,10 +70,10 @@ class Rcmail_RcmailUtils extends ActionTestCase
 
         self::initDB('init');
 
-        $db = rcmail::get_instance()->get_dbh();
+        $db = \rcmail::get_instance()->get_dbh();
 
         ob_start();
-        rcmail_utils::mod_pref('test', []);
+        \rcmail_utils::mod_pref('test', []);
         $output = ob_get_contents();
         ob_end_clean();
 
diff --git a/tests/StderrMock.php b/tests/StderrMock.php
index ac8df52..01a2cee 100644
--- a/tests/StderrMock.php
+++ b/tests/StderrMock.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace Roundcube\Tests;
+
 /**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
@@ -19,16 +21,15 @@
 
 /**
  * A class for catching STDERR output
- *
- * @package Tests
  */
-class StderrMock extends php_user_filter
+class StderrMock extends \php_user_filter
 {
     public static $registered = false;
     public static $redirect;
     public static $output = '';
 
-    #[ReturnTypeWillChange]
+    #[\Override]
+    #[\ReturnTypeWillChange]
     public function filter($in, $out, &$consumed, $closing)
     {
         while ($bucket = stream_bucket_make_writeable($in)) {
@@ -37,18 +38,18 @@ class StderrMock extends php_user_filter
             self::$output .= $bucket->data;
         }
 
-        return PSFS_PASS_ON;
+        return \PSFS_PASS_ON;
     }
 
     public static function start()
     {
         if (!self::$registered) {
-            stream_filter_register("redirect", "StderrMock") or die("Failed to register filter");
+            stream_filter_register("redirect", self::class) or die("Failed to register filter");
             self::$registered = true;
         }
 
         self::$output = '';
-        self::$redirect = stream_filter_prepend(STDERR, "redirect", STREAM_FILTER_WRITE);
+        self::$redirect = stream_filter_prepend(\STDERR, "redirect", \STREAM_FILTER_WRITE);
     }
 
     public static function stop()
diff --git a/tests/StorageMock.php b/tests/StorageMock.php
index 4fdbf3e..8a1532f 100644
--- a/tests/StorageMock.php
+++ b/tests/StorageMock.php
@@ -1,5 +1,7 @@
 <?php
 
+namespace Roundcube\Tests;
+
 /**
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
@@ -19,8 +21,6 @@
 
 /**
  * A class for easier testing of code utilizing rcube_storage
- *
- * @package Tests
  */
 class StorageMock
 {
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index e49cda4..c288305 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,5 +1,12 @@
 <?php
 
+namespace Roundcube\Tests;
+
+use GuzzleHttp\Handler\MockHandler;
+use GuzzleHttp\HandlerStack;
+use GuzzleHttp\Psr7\Response;
+use Masterminds\HTML5;
+
 /*
  +-----------------------------------------------------------------------+
  | This file is part of the Roundcube Webmail client                     |
@@ -33,7 +40,7 @@ if (@is_dir(TESTS_DIR . 'config')) {
 
 require_once(INSTALL_PATH . 'program/include/iniset.php');
 
-rcmail::get_instance(0, 'test')->config->set('devel_mode', false);
+\rcmail::get_instance(0, 'test')->config->set('devel_mode', false);
 
 // Extend include path so some plugin test won't fail
 $include_path = ini_get('include_path') . PATH_SEPARATOR . TESTS_DIR . '..';
@@ -64,7 +71,7 @@ ActionTestCase::init();
  */
 function invokeMethod($object, $method, array $parameters = [], $class = null)
 {
-    $reflection = new ReflectionClass($class ?: get_class($object));
+    $reflection = new \ReflectionClass($class ?: get_class($object));
 
     $method = $reflection->getMethod($method);
     $method->setAccessible(true);
@@ -83,7 +90,7 @@ function invokeMethod($object, $method, array $parameters = [], $class = null)
  */
 function getProperty($object, $name, $class = null)
 {
-    $reflection = new ReflectionClass($class ?: get_class($object));
+    $reflection = new \ReflectionClass($class ?: get_class($object));
 
     $property = $reflection->getProperty($name);
     $property->setAccessible(true);
@@ -103,7 +110,7 @@ function getProperty($object, $name, $class = null)
  */
 function setProperty($object, $name, $value, $class = null)
 {
-    $reflection = new ReflectionClass($class ?: get_class($object));
+    $reflection = new \ReflectionClass($class ?: get_class($object));
 
     $property = $reflection->getProperty($name);
     $property->setAccessible(true);
@@ -121,10 +128,10 @@ function setProperty($object, $name, $value, $class = null)
  */
 function getHTMLNodes($html, $xpath_query)
 {
-    $html5 = new Masterminds\HTML5(['disable_html_ns' => true]);
+    $html5 = new \Masterminds\HTML5(['disable_html_ns' => true]);
     $doc  = $html5->loadHTML($html);
 
-    $xpath = new DOMXPath($doc);
+    $xpath = new \DOMXPath($doc);
 
     return $xpath->query($xpath_query);
 }
@@ -146,7 +153,7 @@ function setHttpClientMock(array $responses)
 
     $mock = new \GuzzleHttp\Handler\MockHandler($responses);
     $handler = \GuzzleHttp\HandlerStack::create($mock);
-    $rcube = rcube::get_instance();
+    $rcube = \rcube::get_instance();
 
     $rcube->config->set('http_client', ['handler' => $handler]);
 }
