From 86f52b37e0b31191b72900948014fa7ae23de0f5 Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Thu, 19 Dec 2024 21:13:10 +0100 Subject: [PATCH] Allow overriding the schema for testing purposes --- src/TestUtils/SchemaValidationTestTrait.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/TestUtils/SchemaValidationTestTrait.php b/src/TestUtils/SchemaValidationTestTrait.php index f2894b8..5537d0f 100644 --- a/src/TestUtils/SchemaValidationTestTrait.php +++ b/src/TestUtils/SchemaValidationTestTrait.php @@ -16,6 +16,9 @@ */ trait SchemaValidationTestTrait { + /** @var string|null */ + protected static ?string $schemaFile = null; + /** @var class-string */ protected static string $testedClass; @@ -41,14 +44,14 @@ public function testSchemaValidation(): void ); } else { // Validate before serialization - self::$testedClass::schemaValidate(self::$xmlRepresentation); + self::$testedClass::schemaValidate(self::$xmlRepresentation, self::$schemaFile); // Perform serialization $class = self::$testedClass::fromXML(self::$xmlRepresentation->documentElement); $serializedClass = $class->toXML(); // Validate after serialization - self::$testedClass::schemaValidate($serializedClass->ownerDocument); + self::$testedClass::schemaValidate($serializedClass->ownerDocument, self::$schemaFile); // If we got this far and no exceptions were thrown, consider this test passed! $this->addToAssertionCount(1);