diff --git a/tests/src/OneLogin/Saml2/MetadataTest.php b/tests/src/OneLogin/Saml2/MetadataTest.php index 3a93e3eb..290ff9ff 100644 --- a/tests/src/OneLogin/Saml2/MetadataTest.php +++ b/tests/src/OneLogin/Saml2/MetadataTest.php @@ -165,8 +165,9 @@ public function testSignMetadata() try { $signedMetadata2 = Metadata::signMetadata('', $key, $cert); $this->fail('Exception was not raised'); - } catch (\Error $e) { - $this->assertStringContainsString('Argument #1 ($source) must not be empty', $e->getMessage()); + } catch (\Error | \Exception $e) { + $expectedErrors = array('DOMDocument::loadXML(): Argument #1 ($source) must not be empty', 'DOMDocument::loadXML(): Empty string supplied as input'); + $this->assertTrue(in_array($e->getMessage(), $expectedErrors)); } } @@ -261,8 +262,9 @@ public function testAddX509KeyDescriptors() try { $signedMetadata2 = Metadata::addX509KeyDescriptors('', $cert); $this->fail('Exception was not raised'); - } catch (\Error $e) { - $this->assertStringContainsString('Argument #1 ($source) must not be empty', $e->getMessage()); + } catch (\Error | \Exception $e) { + $expectedErrors = array('DOMDocument::loadXML(): Argument #1 ($source) must not be empty', 'Error parsing metadata. DOMDocument::loadXML(): Empty string supplied as input'); + $this->assertTrue(in_array($e->getMessage(), $expectedErrors)); } libxml_use_internal_errors(true); diff --git a/tests/src/OneLogin/Saml2/SettingsTest.php b/tests/src/OneLogin/Saml2/SettingsTest.php index 87708629..ca0ed7c4 100644 --- a/tests/src/OneLogin/Saml2/SettingsTest.php +++ b/tests/src/OneLogin/Saml2/SettingsTest.php @@ -831,8 +831,9 @@ public function testValidateMetadataNoXML() try { $errors = $settings->validateMetadata($metadata); $this->fail('Exception was not raised'); - } catch (\Error $e) { - $this->assertStringContainsString('Argument #1 ($source) must not be empty', $e->getMessage()); + } catch (\Error | \Exception $e) { + $expectedErrors = array('DOMDocument::loadXML(): Argument #1 ($source) must not be empty', 'DOMDocument::loadXML(): Empty string supplied as input'); + $this->assertTrue(in_array($e->getMessage(), $expectedErrors)); } $metadata = '';