Skip to content

Commit

Permalink
Raise coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jan 25, 2024
1 parent 06a7d5e commit d6d6bde
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 14 deletions.
12 changes: 0 additions & 12 deletions src/XML/fed/AbstractPseudonymBasisType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion src/XML/fed/AbstractRelativeToType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class AbstractRelativeToType extends AbstractFedElement
* @param \SimpleSAML\XML\Attribute[] $namespacedAttributes
*/
final public function __construct(
array $children,
array $children = [],
array $namespacedAttributes = []
) {
$this->setElements($children);
Expand Down
15 changes: 15 additions & 0 deletions tests/WSSecurity/XML/fed/ReferenceToken11Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"<fed:ReferenceToken11 xmlns:fed=\"$fedns\"/>",
strval($referenceToken11),
);
$this->assertTrue($referenceToken11->isEmptyElement());
}
}
15 changes: 15 additions & 0 deletions tests/WSSecurity/XML/fed/ReferenceTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"<fed:ReferenceToken xmlns:fed=\"$fedns\"/>",
strval($referenceToken),
);
$this->assertTrue($referenceToken->isEmptyElement());
}
}
16 changes: 16 additions & 0 deletions tests/WSSecurity/XML/fed/RelativeToTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\Test\WSSecurity\XML\fed;

use PHPUnit\Framework\TestCase;
use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\fed\RelativeTo;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
Expand Down Expand Up @@ -66,4 +67,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(
"<fed:RelativeTo xmlns:fed=\"$fedns\"/>",
strval($relativeTo),
);
$this->assertTrue($relativeTo->isEmptyElement());
}
}
1 change: 1 addition & 0 deletions tests/WSSecurity/XML/wst/CodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/WSSecurity/XML/wst/ComputedKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/WSSecurity/XML/wst/KeyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion tests/WSSecurity/XML/wst/ParticipantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PHPUnit\Framework\TestCase;
use SimpleSAML\SOAP\Constants as SOAP;
use SimpleSAML\WSSecurity\Constants as C;
use SimpleSAML\WSSecurity\XML\wsa\MessageID;
use SimpleSAML\WSSecurity\XML\wst\Participant;
use SimpleSAML\WSSecurity\XML\wst\Participants;
Expand All @@ -21,7 +22,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
Expand Down Expand Up @@ -66,4 +67,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(

Check failure on line 79 in tests/WSSecurity/XML/wst/ParticipantsTest.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.2, windows-latest

Failed asserting that two strings are equal.

Check failure on line 79 in tests/WSSecurity/XML/wst/ParticipantsTest.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.2, ubuntu-latest

Failed asserting that two strings are equal.

Check failure on line 79 in tests/WSSecurity/XML/wst/ParticipantsTest.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.3, windows-latest

Failed asserting that two strings are equal.

Check failure on line 79 in tests/WSSecurity/XML/wst/ParticipantsTest.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.3, ubuntu-latest

Failed asserting that two strings are equal.
"<fed:Participants xmlns:fed=\"$fedns\"/>",
strval($participants),

Check failure on line 81 in tests/WSSecurity/XML/wst/ParticipantsTest.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.1, ubuntu-latest

Failed asserting that two strings are equal.
);
$this->assertTrue($participants->isEmptyElement());
}
}
11 changes: 11 additions & 0 deletions tests/WSSecurity/XML/wst/SignChallengeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
1 change: 1 addition & 0 deletions tests/WSSecurity/XML/wst/StatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d6d6bde

Please sign in to comment.