Skip to content

Commit

Permalink
WIP: Migrate phpunit metadata to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Mar 24, 2024
1 parent cd71f18 commit f9b8ca7
Show file tree
Hide file tree
Showing 135 changed files with 677 additions and 395 deletions.
3 changes: 2 additions & 1 deletion tests/InterOperability/EntitiesDescriptorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\Test\SAML2;

use DOMElement;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\md\EntitiesDescriptor;
Expand All @@ -18,10 +19,10 @@
final class EntitiesDescriptorTest extends TestCase
{
/**
* @dataProvider provideMetadata
* @param boolean $shouldPass
* @param \DOMElement $metadata;
*/
#[DataProvider('provideMetadata')]
public function testUnmarshalling(bool $shouldPass, DOMElement $metadata): void
{
try {
Expand Down
21 changes: 10 additions & 11 deletions tests/SAML2/Certificate/KeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace SimpleSAML\Test\SAML2\Certificate;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Certificate\Exception\InvalidKeyUsageException;
use SimpleSAML\SAML2\Certificate\Key;
Expand All @@ -15,12 +18,12 @@
* @covers \SimpleSAML\SAML2\Certificate\Key
* @package simplesamlphp/saml2
*/
#[Group('certificate')]
final class KeyTest extends TestCase
{
/**
* @group certificate
* @test
*/
#[Test]
public function invalidKeyUsageShouldThrowAnException(): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
Expand All @@ -30,10 +33,9 @@ public function invalidKeyUsageShouldThrowAnException(): void


/**
* @group certificate
* @dataProvider functionProvider
* @test
*/
#[DataProvider('functionProvider')]
#[Test]
public function invalidOffsetTypeShouldThrowAnException($function, $params): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
Expand All @@ -43,9 +45,8 @@ public function invalidOffsetTypeShouldThrowAnException($function, $params): voi


/**
* @group certificate
* @test
*/
#[Test]
public function assertThatKeyUsageCheckWorksCorrectly(): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
Expand All @@ -59,9 +60,8 @@ public function assertThatKeyUsageCheckWorksCorrectly(): void


/**
* @group certificate
* @test
*/
#[Test]
public function assertThatOffsetgetWorksCorrectly(): void
{
$key = new Key([Key::USAGE_SIGNING => true]);
Expand All @@ -70,9 +70,8 @@ public function assertThatOffsetgetWorksCorrectly(): void


/**
* @group certificate
* @test
*/
#[Test]
public function assertThatOffsetunsetUnsetsOffset(): void
{
$key = new Key([Key::USAGE_SIGNING => true, Key::USAGE_ENCRYPTION => true]);
Expand Down
9 changes: 5 additions & 4 deletions tests/SAML2/Certificate/PrivateKeyLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace SimpleSAML\Test\SAML2\Certificate;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Certificate\PrivateKey;
use SimpleSAML\SAML2\Certificate\PrivateKeyLoader;
Expand All @@ -29,12 +31,11 @@ public static function setUpBeforeClass(): void


/**
* @group certificate
* @test
* @dataProvider privateKeyTestProvider
*
* @param \SimpleSAML\SAML2\Configuration\PrivateKey $configuredKey
*/
#[Test]
#[Group('certificate')]
#[DataProvider('privateKeyTestProvider')]
public function loadingAConfiguredPrivateKeyReturnsACertificatePrivateKey(
ConfPrivateKey $configuredKey
): void {
Expand Down
7 changes: 4 additions & 3 deletions tests/SAML2/XML/alg/DigestMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace SimpleSAML\Test\SAML2\XML\alg;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\alg\AbstractAlgElement;
use SimpleSAML\SAML2\XML\alg\DigestMethod;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Chunk;
Expand All @@ -19,11 +21,10 @@
/**
* Class \SAML2\XML\alg\DigestMethodTest
*
* @covers \SimpleSAML\SAML2\XML\alg\AbstractAlgElement
* @covers \SimpleSAML\SAML2\XML\alg\DigestMethod
*
* @package simplesamlphp/saml2
*/
#[CoversClass(DigestMethod::class)]
#[CoversClass(AbstractAlgElement::class)]
final class DigestMethodTest extends TestCase
{
use SerializableElementTestTrait;
Expand Down
7 changes: 4 additions & 3 deletions tests/SAML2/XML/alg/SigningMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace SimpleSAML\Test\SAML2\XML\alg;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\alg\AbstractAlgElement;
use SimpleSAML\SAML2\XML\alg\SigningMethod;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Chunk;
Expand All @@ -19,11 +21,10 @@
/**
* Class \SAML2\XML\alg\SigningMethodTest
*
* @covers \SimpleSAML\SAML2\XML\alg\AbstractAlgElement
* @covers \SimpleSAML\SAML2\XML\alg\SigningMethod
*
* @package simplesamlphp/saml2
*/
#[CoversClass(SigningMethod::class)]
#[CoversClass(AbstractAlgElement::class)]
final class SigningMethodTest extends TestCase
{
use SerializableElementTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/ecp/RelayStateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace SimpleSAML\Test\SAML2\XML\ecp;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\RelayState;
use SimpleSAML\SOAP\Constants as SOAP;
use SimpleSAML\XML\DOMDocumentFactory;
Expand All @@ -16,10 +18,10 @@
use function strval;

/**
* @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
* @covers \SimpleSAML\SAML2\XML\ecp\RelayState
* @package simplesamlphp/saml2
*/
#[CoversClass(RelayState::class)]
#[CoversClass(AbstractEcpElement::class)]
final class RelayStateTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/ecp/RequestAuthenticatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace SimpleSAML\Test\SAML2\XML\ecp;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\RequestAuthenticated;
use SimpleSAML\SOAP\Constants as C;
use SimpleSAML\XML\DOMDocumentFactory;
Expand All @@ -17,9 +19,9 @@

/**
* @package simplesamlphp/saml2
* @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
* @covers \SimpleSAML\SAML2\XML\ecp\RequestAuthenticated
*/
#[CoversClass(RequestAuthenticated::class)]
#[CoversClass(AbstractEcpElement::class)]
final class RequestAuthenticatedTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/ecp/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace SimpleSAML\Test\SAML2\XML\ecp;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\Request;
use SimpleSAML\SAML2\XML\saml\Issuer;
use SimpleSAML\SAML2\XML\samlp\GetComplete;
Expand All @@ -20,10 +22,10 @@
use function strval;

/**
* @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
* @covers \SimpleSAML\SAML2\XML\ecp\Request
* @package simplesamlphp/saml2
*/
#[CoversClass(Request::class)]
#[CoversClass(AbstractEcpElement::class)]
final class RequestTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/ecp/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
namespace SimpleSAML\Test\SAML2\XML\ecp;

use DOMDocument;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Constants as C;
use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\Response;
use SimpleSAML\SOAP\Constants as SOAP;
use SimpleSAML\XML\DOMDocumentFactory;
Expand All @@ -19,10 +21,10 @@
use function strval;

/**
* @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
* @covers \SimpleSAML\SAML2\XML\ecp\Response
* @package simplesamlphp/saml2
*/
#[CoversClass(Response::class)]
#[CoversClass(AbstractEcpElement::class)]
final class ResponseTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/ecp/SubjectConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
namespace SimpleSAML\Test\SAML2\XML\ecp;

use DateTimeImmutable;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\ecp\AbstractEcpElement;
use SimpleSAML\SAML2\XML\ecp\SubjectConfirmation;
use SimpleSAML\SAML2\XML\saml\SubjectConfirmationData;
use SimpleSAML\SOAP\Constants as SOAP;
Expand All @@ -23,10 +25,10 @@
use function strval;

/**
* @covers \SimpleSAML\SAML2\XML\ecp\AbstractEcpElement
* @covers \SimpleSAML\SAML2\XML\ecp\SubjectConfirmation
* @package simplesamlphp/saml2
*/
#[CoversClass(SubjectConfirmation::class)]
#[CoversClass(AbstractEcpElement::class)]
final class SubjectConfirmationTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/emd/RepublishRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace SimpleSAML\Test\SAML2\XML\emd;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\XML\emd\AbstractEmdElement;
use SimpleSAML\SAML2\XML\emd\RepublishRequest;
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
use SimpleSAML\XML\DOMDocumentFactory;
Expand All @@ -18,10 +20,10 @@
/**
* Class \SimpleSAML\SAML2\XML\emd\RepublishRequest
*
* @covers \SimpleSAML\SAML2\XML\emd\RepublishRequest
* @covers \SimpleSAML\SAML2\XML\emd\AbstractEmdElement
* @package simplesamlphp/saml2
*/
#[CoversClass(RepublishRequest::class)]
#[CoversClass(AbstractEmdElement::class)]
final class RepublishRequestTest extends TestCase
{
use ArrayizableElementTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/emd/RepublishTargetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace SimpleSAML\Test\SAML2\XML\emd;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\emd\AbstractEmdElement;
use SimpleSAML\SAML2\XML\emd\RepublishTarget;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
Expand All @@ -16,10 +18,10 @@
/**
* Class \SimpleSAML\SAML2\XML\emd\RepublishTarget
*
* @covers \SimpleSAML\SAML2\XML\emd\RepublishTarget
* @covers \SimpleSAML\SAML2\XML\emd\AbstractEmdElement
* @package simplesamlphp/saml2
*/
#[CoversClass(RepublishTarget::class)]
#[CoversClass(AbstractEmdElement::class)]
final class RepublishTargetTest extends TestCase
{
use SerializableElementTestTrait;
Expand Down
9 changes: 6 additions & 3 deletions tests/SAML2/XML/idpdisc/DiscoveryResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace SimpleSAML\Test\SAML2\XML\idpdisc;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\AssertionFailedException;
use SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponse;
use SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType;
use SimpleSAML\SAML2\XML\md\AbstractMdElement;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
use SimpleSAML\XML\Chunk;
Expand All @@ -21,11 +24,11 @@
/**
* Class \SAML2\XML\idpdisc\DiscoveryResponseTest
*
* @covers \SimpleSAML\SAML2\XML\idpdisc\DiscoveryResponse
* @covers \SimpleSAML\SAML2\XML\md\AbstractIndexedEndpointType
* @covers \SimpleSAML\SAML2\XML\md\AbstractMdElement
* @package simplesamlphp/saml2
*/
#[CoversClass(DiscoveryResponse::class)]
#[CoversClass(AbstractIndexedEndpointType::class)]
#[CoversClass(AbstractMdElement::class)]
final class DiscoveryResponseTest extends TestCase
{
use ArrayizableElementTestTrait;
Expand Down
6 changes: 4 additions & 2 deletions tests/SAML2/XML/init/RequestInitiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace SimpleSAML\Test\SAML2\XML\init;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\SAML2\Exception\ProtocolViolationException;
use SimpleSAML\SAML2\XML\init\AbstractInitElement;
use SimpleSAML\SAML2\XML\init\RequestInitiator;
use SimpleSAML\Test\SAML2\Constants as C;
use SimpleSAML\XML\Attribute as XMLAttribute;
Expand All @@ -20,10 +22,10 @@
/**
* Class \SAML2\XML\init\RequestInitiatorTest
*
* @covers \SimpleSAML\SAML2\XML\init\RequestInitiator
*
* @package simplesamlphp/saml2
*/
#[CoversClass(RequestInitiator::class)]
#[CoversClass(AbstractInitElement::class)]
final class RequestInitiatorTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
Loading

0 comments on commit f9b8ca7

Please sign in to comment.