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 Mar 19, 2024
1 parent de6b335 commit 2b9d9e6
Show file tree
Hide file tree
Showing 53 changed files with 242 additions and 139 deletions.
29 changes: 11 additions & 18 deletions tests/CryptoEncoding/PEMBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace SimpleSAML\XMLSecurity\Test\CryptoEncoding;

use LogicException;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XMLSecurity\CryptoEncoding\PEM;
use SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle;
Expand All @@ -14,10 +16,9 @@
use function dirname;

/**
* @group pem
*
* @internal
*/
#[Group('pem')]
class PEMBundleTest extends TestCase
{
private static string $baseDir;
Expand All @@ -43,21 +44,19 @@ public function testBundle(): PEMBundle


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testAll(PEMBundle $bundle): void
{
$this->assertContainsOnlyInstancesOf(PEM::class, $bundle->all());
}


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testFirst(PEMBundle $bundle): void
{
$this->assertInstanceOf(PEM::class, $bundle->first());
Expand All @@ -66,10 +65,9 @@ public function testFirst(PEMBundle $bundle): void


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testLast(PEMBundle $bundle): void
{
$this->assertInstanceOf(PEM::class, $bundle->last());
Expand All @@ -78,21 +76,19 @@ public function testLast(PEMBundle $bundle): void


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testCount(PEMBundle $bundle): void
{
$this->assertCount(150, $bundle);
}


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testIterator(PEMBundle $bundle): void
{
$values = [];
Expand All @@ -104,21 +100,19 @@ public function testIterator(PEMBundle $bundle): void


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testString(PEMBundle $bundle): void
{
$this->assertIsString($bundle->string());
}


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testToString(PEMBundle $bundle): void
{
$this->assertIsString(strval($bundle));
Expand Down Expand Up @@ -168,10 +162,9 @@ public function testLastEmptyFail(): void


/**
* @depends testBundle
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
*/
#[Depends('testBundle')]
public function testWithPEMs(PEMBundle $bundle): void
{
$bundle = $bundle->withPEMs(new PEM('TEST', 'data'));
Expand Down
14 changes: 6 additions & 8 deletions tests/CryptoEncoding/PEMTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace SimpleSAML\XMLSecurity\Test\CryptoEncoding;

use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use SimpleSAML\XMLSecurity\CryptoEncoding\PEM;
Expand All @@ -14,10 +16,9 @@
use function file_get_contents;

/**
* @group pem
*
* @internal
*/
#[Group('pem')]
class PEMTest extends TestCase
{
private static string $baseDir;
Expand Down Expand Up @@ -51,10 +52,9 @@ public function testFromFile(): PEM


/**
* @depends testFromFile
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $pem
*/
#[Depends('testFromFile')]
public function testType(PEM $pem): void
{
$this->assertEquals(PEM::TYPE_PUBLIC_KEY, $pem->type());
Expand Down Expand Up @@ -101,21 +101,19 @@ public function testInvalidFile(): void


/**
* @depends testFromFile
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $pem
*/
#[Depends('testFromFile')]
public function testString(PEM $pem): void
{
$this->assertIsString($pem->string());
}


/**
* @depends testFromFile
*
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $pem
*/
#[Depends('testFromFile')]
public function testToString(PEM $pem): void
{
$this->assertIsString(strval($pem));
Expand Down
19 changes: 8 additions & 11 deletions tests/Utils/CertificateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

namespace SimpleSAML\XMLSecurity\Test\Utils;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\Utils\Certificate;

/**
* @covers \SimpleSAML\XMLSecurity\Utils\Certificate
* @package simplesamlphp/xml-security
*/
#[Group('utilities')]
#[CoversClass(Certificate::class)]
final class CertificateTest extends TestCase
{
/**
* @group utilities
* @test
*/
#[Test]
public function testValidStructure(): void
{
$result = Certificate::hasValidStructure(
Expand All @@ -32,10 +33,7 @@ public function testValidStructure(): void
}


/**
* @group utilities
* @test
*/
#[Test]
public function testConvertToCertificate(): void
{
$result = Certificate::convertToCertificate(PEMCertificatesMock::getPlainCertificateContents());
Expand All @@ -44,8 +42,7 @@ public function testConvertToCertificate(): void
}


/**
*/
#[Test]
public function testParseIssuer(): void
{
// Test string input
Expand Down
3 changes: 2 additions & 1 deletion tests/XML/CustomSignableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SimpleSAML\XMLSecurity\Test\XML;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
Expand All @@ -15,9 +16,9 @@
/**
* Class \SimpleSAML\XMLSecurity\Test\XML\CustomSignableTest
*
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable
* @package simplesamlphp/xml-security
*/
#[CoversClass(CustomSignable::class)]
final class CustomSignableTest extends TestCase
{
use SerializableElementTestTrait;
Expand Down
11 changes: 7 additions & 4 deletions tests/XML/EncryptedCustomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\XMLSecurity\Test\XML;

use DOMElement;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmFactory;
Expand All @@ -13,19 +14,21 @@
use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\Key\PublicKey;
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
use SimpleSAML\XMLSecurity\Test\XML\EncryptedCustom;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\XML\EncryptableElementTrait;
use SimpleSAML\XMLSecurity\XML\EncryptedElementTrait;

use function dirname;

/**
* Class \SimpleSAML\XMLSecurity\Test\XML\EncryptedCustomTest
*
* @covers \SimpleSAML\XMLSecurity\XML\EncryptableElementTrait
* @covers \SimpleSAML\XMLSecurity\XML\EncryptedElementTrait
* @covers \SimpleSAML\XMLSecurity\Test\XML\EncryptedCustom
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(EncryptableElementTrait::class)]
#[CoversClass(EncryptedElementTrait::class)]
#[CoversClass(EncryptedCustom::class)]
class EncryptedCustomTest extends TestCase
{
/** @var \DOMElement */
Expand Down
5 changes: 3 additions & 2 deletions tests/XML/SignableElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
namespace SimpleSAML\XMLSecurity\Test\XML;

use DOMDocument;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
use SimpleSAML\XMLSecurity\Key\PrivateKey;
use SimpleSAML\XMLSecurity\Test\XML\CustomSignable;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
Expand All @@ -28,10 +30,9 @@
/**
* Class \SimpleSAML\XMLSecurity\Test\XML\SignableElementTest
*
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(CustomSignable::class)]
final class SignableElementTest extends TestCase
{
use SerializableElementTestTrait;
Expand Down
8 changes: 5 additions & 3 deletions tests/XML/SignedElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\XMLSecurity\Test\XML;

use DOMElement;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
Expand All @@ -13,20 +14,21 @@
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
use SimpleSAML\XMLSecurity\Key\PublicKey;
use SimpleSAML\XMLSecurity\Key\X509Certificate;
use SimpleSAML\XMLSecurity\Test\XML\CustomSignable;
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use SimpleSAML\XMLSecurity\XML\SignedElementTrait;

use function dirname;
use function strval;

/**
* Class \SimpleSAML\XMLSecurity\Test\XML\SignedElementTest
*
* @covers \SimpleSAML\XMLSecurity\XML\SignedElementTrait
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(SignedElementTrait::class)]
#[CoversClass(CustomSignable::class)]
final class SignedElementTest extends TestCase
{
/** @var \SimpleSAML\XMLSecurity\CryptoEncoding\PEM */
Expand Down
7 changes: 4 additions & 3 deletions tests/XML/ds/CanonicalizationMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@

namespace SimpleSAML\XMLSecurity\Test\XML\ds;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
use SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod;

use function dirname;

/**
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\CanonicalizationMethodTest
*
* @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
* @covers \SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(AbstractDsElement::class)]
#[CoversClass(CanonicalizationMethod::class)]
final class CanonicalizationMethodTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
7 changes: 4 additions & 3 deletions tests/XML/ds/DigestMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

namespace SimpleSAML\XMLSecurity\Test\XML\ds;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\DOMDocumentFactory;
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
use SimpleSAML\XMLSecurity\Constants as C;
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
use SimpleSAML\XMLSecurity\XML\ds\DigestMethod;

use function dirname;
Expand All @@ -18,11 +20,10 @@
/**
* Class \SimpleSAML\XMLSecurity\XML\Test\ds\DigestMethodTest
*
* @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
* @covers \SimpleSAML\XMLSecurity\XML\ds\DigestMethod
*
* @package simplesamlphp/xml-security
*/
#[CoversClass(AbstractDsElement::class)]
#[CoversClass(DigestMethod::class)]
final class DigestMethodTest extends TestCase
{
use SchemaValidationTestTrait;
Expand Down
Loading

0 comments on commit 2b9d9e6

Please sign in to comment.