Skip to content

Commit

Permalink
Migrate phpunit metadata to attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Apr 9, 2024
1 parent d013111 commit 7b40b5d
Show file tree
Hide file tree
Showing 169 changed files with 1,288 additions and 731 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
10 changes: 4 additions & 6 deletions tests/SAML2/Assertion/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use Psr\Log\LoggerInterface;
use SimpleSAML\SAML2\Assertion\Decrypter;
use SimpleSAML\SAML2\Assertion\Exception\InvalidAssertionException;
Expand All @@ -23,10 +24,9 @@
use stdClass;

/**
* @covers \SimpleSAML\SAML2\Assertion\Processor
* @package simplesamlphp/saml2
* @runTestsInSeparateProcesses
*/
#[CoversClass(Processor::class)]
final class ProcessorTest extends MockeryTestCase
{
/**
Expand Down Expand Up @@ -63,9 +63,8 @@ public static function setUpBeforeClass(): void


/**
* @test
*/
public function processorCorrectlyEncryptsAssertions(): void
public function testProcessorCorrectlyEncryptsAssertions(): void
{
$encryptedAssertion = EncryptedAssertion::fromXML(
DOMDocumentFactory::fromFile(
Expand Down Expand Up @@ -101,9 +100,8 @@ public function processorCorrectlyEncryptsAssertions(): void


/**
* @test
*/
public function unsuportedAssertionsAreRejected(): void
public function testUnsuportedAssertionsAreRejected(): void
{
$this->expectException(InvalidAssertionException::class);
$this->expectExceptionMessage('The assertion must be of type: EncryptedAssertion or Assertion');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

declare(strict_types=1);

namespace SimpleSAML\Test\SAML2\XML\saml;
namespace SimpleSAML\Test\SAML2\Assertion\Transformer;

use DateTimeImmutable;
use DOMDocument;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -147,11 +149,10 @@ public static function setUpBeforeClass(): void

/**
* Verifies that we can create decrypted NameIDs.
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @return void
*/
#[PreserveGlobalState(false)]
#[RunInSeparateProcess]
public function testBasicNameIdDecryption(): void
{
$this->markTestSkipped();
Expand All @@ -169,10 +170,10 @@ public function testBasicNameIdDecryption(): void
/**
* Run the decoder through processAssertions.
*
* @runInSeparateProcess
* @preserveGlobalState disabled
* @return void
*/
#[PreserveGlobalState(false)]
#[RunInSeparateProcess]
public function testDecryptionProcessAssertions(): void
{
$this->markTestSkipped();
Expand Down
17 changes: 9 additions & 8 deletions tests/SAML2/Assertion/Validation/AssertionValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

declare(strict_types=1);

namespace SimpleSAML\Test\SAML2\XML\saml;
namespace SimpleSAML\Test\SAML2\Assertion\Validation;

use DOMDocument;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use Psr\Log\LoggerInterface;
Expand All @@ -27,9 +30,9 @@
/**
* Tests for the Assertion validators
*
* @covers \SimpleSAML\SAML2\Assertion\Validation\AssertionValidator
* @package simplesamlphp/saml2
*/
#[CoversClass(AssertionValidator::class)]
final class AssertionValidatorTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
Expand Down Expand Up @@ -120,10 +123,9 @@ public static function setUpBeforeClass(): void

/**
* Verifies that the assertion validator works
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
#[PreserveGlobalState(false)]
#[RunInSeparateProcess]
public function testBasicValidation(): void
{
$assertion = Assertion::fromXML(self::$document->firstChild);
Expand All @@ -135,10 +137,9 @@ public function testBasicValidation(): void
/**
* Verifies that violations are caught
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
#[PreserveGlobalState(false)]
#[RunInSeparateProcess]
public function testAssertionNonValidation(): void
{
$accr = C::AUTHNCONTEXT_CLASS_REF_LOA1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;

use DateInterval;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotBefore;
Expand All @@ -19,10 +21,9 @@
use SimpleSAML\Test\SAML2\Constants as C;

/**
* @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotBefore
*
* @package simplesamlphp/saml2
*/
#[CoversClass(NotBefore::class)]
final class NotBeforeTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
Expand Down Expand Up @@ -57,10 +58,9 @@ public static function setUpBeforeClass(): void


/**
* @group assertion-validation
* @test
*/
public function timestampInTheFutureBeyondGraceperiodIsNotValid(): void
#[Group('assertion-validation')]
public function testTimestampInTheFutureBeyondGraceperiodIsNotValid(): void
{
// Create Conditions
$conditions = new Conditions(self::$clock->now()->add(new DateInterval('PT61S')));
Expand All @@ -84,10 +84,9 @@ public function timestampInTheFutureBeyondGraceperiodIsNotValid(): void


/**
* @group assertion-validation
* @test
*/
public function timeWithinGraceperiodIsValid(): void
#[Group('assertion-validation')]
public function testTimeWithinGraceperiodIsValid(): void
{
// Create Conditions
$conditions = new Conditions(self::$clock->now()->add(new DateInterval('PT60S')));
Expand All @@ -110,10 +109,9 @@ public function timeWithinGraceperiodIsValid(): void


/**
* @group assertion-validation
* @test
*/
public function currentTimeIsValid(): void
#[Group('assertion-validation')]
public function testCurrentTimeIsValid(): void
{
// Create Conditions
$conditions = new Conditions(self::$clock->now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;

use DateInterval;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter;
Expand All @@ -19,10 +21,9 @@
use SimpleSAML\Test\SAML2\Constants as C;

/**
* @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter
*
* @package simplesamlphp/saml2
*/
#[CoversClass(NotOnOrAfter::class)]
final class NotOnOrAfterTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
Expand Down Expand Up @@ -57,10 +58,9 @@ public static function setUpBeforeClass(): void


/**
* @group assertion-validation
* @test
*/
public function timestampInThePastBeforeGraceperiodIsNotValid(): void
#[Group('assertion-validation')]
public function testTimestampInThePastBeforeGraceperiodIsNotValid(): void
{
// Create Conditions
$conditions = new Conditions(null, self::$clock->now()->sub(new DateInterval('PT60S')));
Expand All @@ -84,10 +84,9 @@ public function timestampInThePastBeforeGraceperiodIsNotValid(): void


/**
* @group assertion-validation
* @test
*/
public function timeWithinGraceperiodIsValid(): void
#[Group('assertion-validation')]
public function testTimeWithinGraceperiodIsValid(): void
{
// Create Conditions
$conditions = new Conditions(null, self::$clock->now()->sub(new DateInterval('PT59S')));
Expand All @@ -110,10 +109,9 @@ public function timeWithinGraceperiodIsValid(): void


/**
* @group assertion-validation
* @test
*/
public function currentTimeIsValid(): void
#[Group('assertion-validation')]
public function testCurrentTimeIsValid(): void
{
// Create Conditions
$conditions = new Conditions(null, self::$clock->now());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace SimpleSAML\Test\SAML2\Assertion\Validation\ConstraintValidator;

use DateInterval;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter;
Expand All @@ -18,10 +20,9 @@
use SimpleSAML\Test\SAML2\Constants as C;

/**
* @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter
*
* @package simplesamlphp/saml2
*/
#[CoversClass(SessionNotOnOrAfter::class)]
final class SessionNotOnOrAfterTest extends TestCase
{
/** @var \Psr\Clock\ClockInterface */
Expand All @@ -43,9 +44,8 @@ public static function setUpBeforeClass(): void


/**
* @group assertion-validation
* @test
*/
#[Group('assertion-validation')]
public function timestampInThePastBeforeGraceperiodIsNotValid(): void
{
// Create the statements
Expand Down Expand Up @@ -73,9 +73,8 @@ public function timestampInThePastBeforeGraceperiodIsNotValid(): void


/**
* @group assertion-validation
* @test
*/
#[Group('assertion-validation')]
public function timeWithinGraceperiodIsValid(): void
{
// Create the statements
Expand All @@ -102,10 +101,9 @@ public function timeWithinGraceperiodIsValid(): void


/**
* @group assertion-validation
* @test
*/
public function currentTimeIsValid(): void
#[Group('assertion-validation')]
public function testCurrentTimeIsValid(): void
{
// Create the statements
$authnStatement = new AuthnStatement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Mockery;
use Mockery\Adapter\Phpunit\MockeryTestCase;
use Mockery\MockInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Psr\Clock\ClockInterface;
use SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience;
use SimpleSAML\SAML2\Assertion\Validation\Result;
Expand All @@ -26,9 +28,9 @@
* Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
* tests.
*
* @covers \SimpleSAML\SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience
* @package simplesamlphp/saml2
*/
#[CoversClass(SpIsValidAudience::class)]
final class SpIsValidAudienceTest extends MockeryTestCase
{
/** @var \SimpleSAML\SAML2\XML\saml\AuthnStatement */
Expand Down Expand Up @@ -85,10 +87,9 @@ public function setUp(): void


/**
* @group assertion-validation
* @test
*/
public function whenNoValidAudiencesAreGivenTheAssertionIsValid(): void
#[Group('assertion-validation')]
public function testWhenNoValidAudiencesAreGivenTheAssertionIsValid(): void
{
// Create an assertion
$assertion = new Assertion(
Expand All @@ -110,10 +111,9 @@ public function whenNoValidAudiencesAreGivenTheAssertionIsValid(): void


/**
* @group assertion-validation
* @test
*/
public function ifTheSpEntityIdIsNotInTheValidAudiencesTheAssertionIsInvalid(): void
#[Group('assertion-validation')]
public function testIfTheSpEntityIdIsNotInTheValidAudiencesTheAssertionIsInvalid(): void
{
// Create an assertion
$assertion = new Assertion(
Expand All @@ -137,10 +137,9 @@ public function ifTheSpEntityIdIsNotInTheValidAudiencesTheAssertionIsInvalid():


/**
* @group assertion-validation
* @test
*/
public function theAssertionIsValidWhenTheCurrentSpEntityIdIsAValidAudience(): void
#[Group('assertion-validation')]
public function testTheAssertionIsValidWhenTheCurrentSpEntityIdIsAValidAudience(): void
{
// Create an assertion
$assertion = new Assertion(
Expand Down
Loading

0 comments on commit 7b40b5d

Please sign in to comment.