Skip to content

Commit 792d9c9

Browse files
authored
Fix remaining tests.Added pre-commit commands in composer.json (#394)
1 parent 90f3fb4 commit 792d9c9

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

composer.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,15 @@
6969
"phpstan/extension-installer": true,
7070
"simplesamlphp/composer-xmlprovider-installer": true
7171
}
72+
},
73+
"scripts": {
74+
"pre-commit": [
75+
"vendor/bin/phpcs -p",
76+
"vendor/bin/composer-require-checker check --config-file=tools/composer-require-checker.json composer.json",
77+
"vendor/bin/phpstan analyze -c phpstan.neon",
78+
"vendor/bin/phpstan analyze -c phpstan-dev.neon",
79+
"vendor/bin/composer-unused",
80+
"vendor/bin/phpunit --no-coverage --testdox"
81+
]
7282
}
7383
}

tests/SAML2/XML/md/EntityDescriptorTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,17 @@ public function testUnmarshalling(): void
494494
$entityDescriptor->getAdditionalMetadataLocation()[1],
495495
);
496496

497-
$this->assertEquals(
497+
// Normalize both documents before comparing
498+
$expectedDoc = DOMDocumentFactory::fromString(
498499
$xmlRepresentation->saveXML($xmlRepresentation->documentElement),
499-
strval($entityDescriptor),
500500
);
501+
$expected = DOMDocumentFactory::normalizeDocument($expectedDoc);
502+
503+
$actualDoc = DOMDocumentFactory::fromString((string) $entityDescriptor);
504+
$actual = DOMDocumentFactory::normalizeDocument($actualDoc);
505+
506+
// Compare normalized XML
507+
$this->assertXmlStringEqualsXmlString($expected->saveXML(), $actual->saveXML());
501508
}
502509

503510

tests/SAML2/XML/saml/SubjectTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,12 @@ public function testMarshallingBaseID(): void
266266
AbstractBaseID::fromXML(self::$baseId->documentElement)->toXML($document->documentElement);
267267
SubjectConfirmation::fromXML(self::$subjectConfirmation->documentElement)->toXML($document->documentElement);
268268

269-
$this->assertXmlStringEqualsXmlString($document->saveXML(), strval($subject));
269+
// Normalize both documents before comparing
270+
$expected = DOMDocumentFactory::normalizeDocument($document);
271+
$actualDoc = DOMDocumentFactory::fromString((string) $subject);
272+
$actual = DOMDocumentFactory::normalizeDocument($actualDoc);
273+
274+
$this->assertXmlStringEqualsXmlString($expected->saveXML(), $actual->saveXML());
270275
}
271276

272277

0 commit comments

Comments
 (0)