diff --git a/src/XML/fed/AbstractPseudonymBasisType.php b/src/XML/fed/AbstractPseudonymBasisType.php index da250cb0..f104d4f6 100644 --- a/src/XML/fed/AbstractPseudonymBasisType.php +++ b/src/XML/fed/AbstractPseudonymBasisType.php @@ -47,18 +47,6 @@ final public function __construct( } - /** - * Test if an object, at the state it's in, would produce an empty XML-element - * - * @return bool - */ - public function isEmptyElement(): bool - { - return empty($this->getElements()) - && empty($this->getAttributesNS()); - } - - /** * Create an instance of this object from its XML representation. * diff --git a/tests/WSSecurity/XML/fed/FederationMetadataHandler.php b/tests/WSSecurity/XML/fed/FederationMetadataHandlerTest.php similarity index 100% rename from tests/WSSecurity/XML/fed/FederationMetadataHandler.php rename to tests/WSSecurity/XML/fed/FederationMetadataHandlerTest.php diff --git a/tests/WSSecurity/XML/fed/ReferenceToken11Test.php b/tests/WSSecurity/XML/fed/ReferenceToken11Test.php index 6d0b7e7b..7dd44744 100644 --- a/tests/WSSecurity/XML/fed/ReferenceToken11Test.php +++ b/tests/WSSecurity/XML/fed/ReferenceToken11Test.php @@ -74,4 +74,19 @@ public function testMarshalling(): void strval($referenceToken11), ); } + + + /** + * Adding an empty X509lToken element should yield an empty element. + */ + public function testMarshallingEmptyElement(): void + { + $fedns = C::NS_FED; + $referenceToken11 = new ReferenceToken11(); + $this->assertEquals( + "", + strval($referenceToken11), + ); + $this->assertTrue($referenceToken11->isEmptyElement()); + } } diff --git a/tests/WSSecurity/XML/fed/ReferenceTokenTest.php b/tests/WSSecurity/XML/fed/ReferenceTokenTest.php index 61951173..04691418 100644 --- a/tests/WSSecurity/XML/fed/ReferenceTokenTest.php +++ b/tests/WSSecurity/XML/fed/ReferenceTokenTest.php @@ -135,4 +135,19 @@ public function testMarshalling(): void strval($referenceToken) ); } + + + /** + * Adding an empty ReferenceToken element should yield an empty element. + */ + public function testMarshallingEmptyElement(): void + { + $fedns = C::NS_FED; + $referenceToken = new ReferenceToken(); + $this->assertEquals( + "", + strval($referenceToken), + ); + $this->assertTrue($referenceToken->isEmptyElement()); + } } diff --git a/tests/WSSecurity/XML/fed/RelativeToTest.php b/tests/WSSecurity/XML/fed/RelativeToTest.php index 58d620c0..4737630b 100644 --- a/tests/WSSecurity/XML/fed/RelativeToTest.php +++ b/tests/WSSecurity/XML/fed/RelativeToTest.php @@ -66,4 +66,19 @@ public function testMarshalling(): void strval($relativeTo), ); } + + + /** + * Adding an empty RelativeTo element should yield an empty element. + */ + public function testMarshallingEmptyElement(): void + { + $fedns = C::NS_FED; + $relativeTo = new RelativeTo(); + $this->assertEquals( + "", + strval($relateTo), + ); + $this->assertTrue($relativeTo->isEmptyElement()); + } } diff --git a/tests/WSSecurity/XML/wst/CodeTest.php b/tests/WSSecurity/XML/wst/CodeTest.php index 136b0f18..7f952822 100644 --- a/tests/WSSecurity/XML/wst/CodeTest.php +++ b/tests/WSSecurity/XML/wst/CodeTest.php @@ -16,6 +16,7 @@ * Class \SimpleSAML\WSSecurity\XML\wst\CodeTest * * @covers \SimpleSAML\WSSecurity\XML\wst\Code + * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractStatusCodeOpenEnum * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement * * @package tvdijen/ws-security diff --git a/tests/WSSecurity/XML/wst/ComputedKeyTest.php b/tests/WSSecurity/XML/wst/ComputedKeyTest.php index 75ad84c3..4b97b8b5 100644 --- a/tests/WSSecurity/XML/wst/ComputedKeyTest.php +++ b/tests/WSSecurity/XML/wst/ComputedKeyTest.php @@ -17,6 +17,7 @@ * Class \SimpleSAML\WSSecurity\XML\wst\ComputedKeyTest * * @covers \SimpleSAML\WSSecurity\XML\wst\ComputedKey + * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractComputedKeyOpenEnum * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement * * @package tvdijen/ws-security diff --git a/tests/WSSecurity/XML/wst/KeyTypeTest.php b/tests/WSSecurity/XML/wst/KeyTypeTest.php index de819055..fb299252 100644 --- a/tests/WSSecurity/XML/wst/KeyTypeTest.php +++ b/tests/WSSecurity/XML/wst/KeyTypeTest.php @@ -17,6 +17,7 @@ * Class \SimpleSAML\WSSecurity\XML\wst\KeyTypeTest * * @covers \SimpleSAML\WSSecurity\XML\wst\KeyType + * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractKeyTypeOpenEnum * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement * * @package tvdijen/ws-security diff --git a/tests/WSSecurity/XML/wst/ParticipantsTest.php b/tests/WSSecurity/XML/wst/ParticipantsTest.php index 544ff04d..610accc7 100644 --- a/tests/WSSecurity/XML/wst/ParticipantsTest.php +++ b/tests/WSSecurity/XML/wst/ParticipantsTest.php @@ -21,7 +21,7 @@ * Class \SimpleSAML\WSSecurity\XML\wst\ParticipantsTest * * @covers \SimpleSAML\WSSecurity\XML\wst\Participants - * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractParticipantType + * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractParticipantsType * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement * * @package tvdijen/ws-security @@ -66,4 +66,19 @@ public function testMarshalling(): void strval($participants), ); } + + + /** + * Adding an empty Participants element should yield an empty element. + */ + public function testMarshallingEmptyElement(): void + { + $fedns = C::NS_FED; + $participants = new Participants(); + $this->assertEquals( + "", + strval($participants), + ); + $this->assertTrue($participants->isEmptyElement()); + } } diff --git a/tests/WSSecurity/XML/wst/SignChallengeTest.php b/tests/WSSecurity/XML/wst/SignChallengeTest.php index cfa4c973..dcfb5a6e 100644 --- a/tests/WSSecurity/XML/wst/SignChallengeTest.php +++ b/tests/WSSecurity/XML/wst/SignChallengeTest.php @@ -66,4 +66,15 @@ public function testMarshalling(): void strval($signChallenge), ); } + + + /** + * Test creating an empty SignChallenge object from scratch. + */ + public function testMarshallingEmpty(): void + { + $signChallenge = new SignChallenge(); + + $this->assertTrue($signChallenge->isEmptyElement()); + } } diff --git a/tests/WSSecurity/XML/wst/StatusTest.php b/tests/WSSecurity/XML/wst/StatusTest.php index 8c907408..e8bdf923 100644 --- a/tests/WSSecurity/XML/wst/StatusTest.php +++ b/tests/WSSecurity/XML/wst/StatusTest.php @@ -19,6 +19,7 @@ * Class \SimpleSAML\WSSecurity\XML\wst\StatusTest * * @covers \SimpleSAML\WSSecurity\XML\wst\Status + * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractStatusType * @covers \SimpleSAML\WSSecurity\XML\wst\AbstractWstElement * * @package tvdijen/ws-security