Skip to content

Commit

Permalink
Slightly raise coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 14, 2024
1 parent 994de22 commit 7d7dc3d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/XML/DOMDocumentFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\Test\XML;

use DOMDocument;
use Exception;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
Expand All @@ -14,6 +15,8 @@
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\Exception\UnparseableXMLException;

use function restore_error_handler;
use function set_error_handler;
use function strval;

/**
Expand Down Expand Up @@ -135,4 +138,20 @@ public function testSchemaValidationWrongElementFails(): void
$this->expectException(SchemaViolationException::class);
DOMDocumentFactory::fromFile($file, $schemaFile);
}


public function testSchemaValidationUnknownSchemaFileFails(): void
{
$file = 'tests/resources/xml/ssp_Chunk.xml';
$schemaFile = 'tests/resources/schemas/doesnotexist.xsd';

// Dirty trick to catch the warning emitted by PHP
set_error_handler(static function (int $errno, string $errstr): never {
restore_error_handler();
throw new Exception($errstr, $errno);
}, E_WARNING);

$this->expectExceptionMessage('Failed to locate the main schema resource at');
DOMDocumentFactory::fromFile($file, $schemaFile);
}
}

0 comments on commit 7d7dc3d

Please sign in to comment.