Skip to content

Commit

Permalink
Fix tests for PHP7.3 and PHP7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
pitbulk committed Jun 9, 2023
1 parent fc74ec9 commit da8c051
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions tests/src/OneLogin/Saml2/MetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions tests/src/OneLogin/Saml2/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<no xml>';
Expand Down

0 comments on commit da8c051

Please sign in to comment.