Skip to content

Commit 86f52b3

Browse files
committed
Allow overriding the schema for testing purposes
1 parent e8eba9d commit 86f52b3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/TestUtils/SchemaValidationTestTrait.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
trait SchemaValidationTestTrait
1818
{
19+
/** @var string|null */
20+
protected static ?string $schemaFile = null;
21+
1922
/** @var class-string */
2023
protected static string $testedClass;
2124

@@ -41,14 +44,14 @@ public function testSchemaValidation(): void
4144
);
4245
} else {
4346
// Validate before serialization
44-
self::$testedClass::schemaValidate(self::$xmlRepresentation);
47+
self::$testedClass::schemaValidate(self::$xmlRepresentation, self::$schemaFile);
4548

4649
// Perform serialization
4750
$class = self::$testedClass::fromXML(self::$xmlRepresentation->documentElement);
4851
$serializedClass = $class->toXML();
4952

5053
// Validate after serialization
51-
self::$testedClass::schemaValidate($serializedClass->ownerDocument);
54+
self::$testedClass::schemaValidate($serializedClass->ownerDocument, self::$schemaFile);
5255

5356
// If we got this far and no exceptions were thrown, consider this test passed!
5457
$this->addToAssertionCount(1);

0 commit comments

Comments
 (0)