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 307766a
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 13 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
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());
}
}
15 changes: 15 additions & 0 deletions tests/WSSecurity/XML/fed/RelativeToTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Check failure on line 76 in tests/WSSecurity/XML/fed/RelativeToTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UndefinedClass

tests/WSSecurity/XML/fed/RelativeToTest.php:76:18: UndefinedClass: Class, interface or enum named SimpleSAML\Test\WSSecurity\XML\fed\C does not exist (see https://psalm.dev/019)
$relativeTo = new RelativeTo();

Check failure on line 77 in tests/WSSecurity/XML/fed/RelativeToTest.php

View workflow job for this annotation

GitHub Actions / Quality control

TooFewArguments

tests/WSSecurity/XML/fed/RelativeToTest.php:77:23: TooFewArguments: Too few arguments for SimpleSAML\WSSecurity\XML\fed\RelativeTo::__construct - expecting children to be passed (see https://psalm.dev/025)
$this->assertEquals(
"<fed:RelativeTo xmlns:fed=\"$fedns\"/>",
strval($relateTo),

Check failure on line 80 in tests/WSSecurity/XML/fed/RelativeToTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UndefinedVariable

tests/WSSecurity/XML/fed/RelativeToTest.php:80:20: UndefinedVariable: Cannot find referenced variable $relateTo (see https://psalm.dev/024)
);
$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
17 changes: 16 additions & 1 deletion tests/WSSecurity/XML/wst/ParticipantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

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

View workflow job for this annotation

GitHub Actions / Quality control

UndefinedClass

tests/WSSecurity/XML/wst/ParticipantsTest.php:76:18: UndefinedClass: Class, interface or enum named SimpleSAML\Test\WSSecurity\XML\wst\C does not exist (see https://psalm.dev/019)
$participants = new Participants();
$this->assertEquals(
"<fed:Participants xmlns:fed=\"$fedns\"/>",
strval($participants),
);
$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 307766a

Please sign in to comment.