diff --git a/tests/modules/core/lib/Auth/Process/PHPTest.php b/tests/modules/core/lib/Auth/Process/PHPTest.php
index a7148af7dd754a1061ac20a26378d4deeee3885e..cb7488dbec3a7bb27c36a2c29c03fe16fc00afbb 100644
--- a/tests/modules/core/lib/Auth/Process/PHPTest.php
+++ b/tests/modules/core/lib/Auth/Process/PHPTest.php
@@ -32,8 +32,8 @@ class PHPTest extends TestCase
     public function testInvalidConfiguration()
     {
         $config = [];
-        $this->expectException(
-            \SimpleSAML\Error\Exception::class,
+        $this->expectException(\SimpleSAML\Error\Exception::class);
+        $this->expectExceptionMessage(
             "core:PHP: missing mandatory configuration option 'code'."
         );
         new \SimpleSAML\Module\core\Auth\Process\PHP($config, null);
@@ -113,10 +113,8 @@ class PHPTest extends TestCase
             ]
         ];
 
-        $this->expectException(
-            \Exception::class,
-            "Missing uid attribute."
-        );
+        $this->expectException(Exception::class);
+        $this->expectExceptionMessage("Missing uid attribute.");
         $this->processFilter($config, $request);
     }
 
diff --git a/tests/modules/core/lib/Auth/UserPassBaseTest.php b/tests/modules/core/lib/Auth/UserPassBaseTest.php
index 51007e89c6a049abf3b993237096df3e659872c6..3fc706060842232d0a0fe9a2ad3c38a60dc05150 100644
--- a/tests/modules/core/lib/Auth/UserPassBaseTest.php
+++ b/tests/modules/core/lib/Auth/UserPassBaseTest.php
@@ -60,7 +60,8 @@ class UserPassBaseTest extends \PHPUnit\Framework\TestCase
      */
     public function testAuthenticateECPMissingPassword()
     {
-        $this->expectException(\SimpleSAML\Error\Error::class, 'WRONGUSERPASS');
+        $this->expectException(\SimpleSAML\Error\Error::class);
+        $this->expectExceptionMessage('WRONGUSERPASS');
 
         $state = [
             'saml:Binding' => \SAML2\Constants::BINDING_PAOS,