Skip to content

Commit bc43479

Browse files
committed
Migrate phpunit metadata to attributes
1 parent de6b335 commit bc43479

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+245
-144
lines changed

tests/Backend/OpenSSLTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,9 @@ public function testEncryptOAEPDecryptRSA15(): void
200200
self::$backend->setCipher(C::KEY_TRANSPORT_OAEP);
201201
$ciphertext = self::$backend->encrypt(self::$pubKey, 'Plaintext');
202202
self::$backend->setCipher(C::KEY_TRANSPORT_RSA_1_5);
203-
// As of March 2024 the openssl_decrypt function no longer throws an exception
204-
// $this->expectException(RuntimeException::class);
205-
// $this->expectExceptionMessageMatches('/^Cannot decrypt data:/');
206-
$plaintext = self::$backend->decrypt(self::$privKey, $ciphertext);
207-
$this->assertNotEquals('Plaintext', $plaintext);
203+
$this->expectException(RuntimeException::class);
204+
$this->expectExceptionMessageMatches('/^Cannot decrypt data:/');
205+
self::$backend->decrypt(self::$privKey, $ciphertext);
208206
}
209207

210208

tests/CryptoEncoding/PEMBundleTest.php

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
namespace SimpleSAML\XMLSecurity\Test\CryptoEncoding;
66

77
use LogicException;
8+
use PHPUnit\Framework\Attributes\Depends;
9+
use PHPUnit\Framework\Attributes\Group;
810
use PHPUnit\Framework\TestCase;
911
use SimpleSAML\XMLSecurity\CryptoEncoding\PEM;
1012
use SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle;
@@ -14,10 +16,9 @@
1416
use function dirname;
1517

1618
/**
17-
* @group pem
18-
*
1919
* @internal
2020
*/
21+
#[Group('pem')]
2122
class PEMBundleTest extends TestCase
2223
{
2324
private static string $baseDir;
@@ -43,21 +44,19 @@ public function testBundle(): PEMBundle
4344

4445

4546
/**
46-
* @depends testBundle
47-
*
4847
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
4948
*/
49+
#[Depends('testBundle')]
5050
public function testAll(PEMBundle $bundle): void
5151
{
5252
$this->assertContainsOnlyInstancesOf(PEM::class, $bundle->all());
5353
}
5454

5555

5656
/**
57-
* @depends testBundle
58-
*
5957
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
6058
*/
59+
#[Depends('testBundle')]
6160
public function testFirst(PEMBundle $bundle): void
6261
{
6362
$this->assertInstanceOf(PEM::class, $bundle->first());
@@ -66,10 +65,9 @@ public function testFirst(PEMBundle $bundle): void
6665

6766

6867
/**
69-
* @depends testBundle
70-
*
7168
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
7269
*/
70+
#[Depends('testBundle')]
7371
public function testLast(PEMBundle $bundle): void
7472
{
7573
$this->assertInstanceOf(PEM::class, $bundle->last());
@@ -78,21 +76,19 @@ public function testLast(PEMBundle $bundle): void
7876

7977

8078
/**
81-
* @depends testBundle
82-
*
8379
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
8480
*/
81+
#[Depends('testBundle')]
8582
public function testCount(PEMBundle $bundle): void
8683
{
8784
$this->assertCount(150, $bundle);
8885
}
8986

9087

9188
/**
92-
* @depends testBundle
93-
*
9489
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
9590
*/
91+
#[Depends('testBundle')]
9692
public function testIterator(PEMBundle $bundle): void
9793
{
9894
$values = [];
@@ -104,21 +100,19 @@ public function testIterator(PEMBundle $bundle): void
104100

105101

106102
/**
107-
* @depends testBundle
108-
*
109103
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
110104
*/
105+
#[Depends('testBundle')]
111106
public function testString(PEMBundle $bundle): void
112107
{
113108
$this->assertIsString($bundle->string());
114109
}
115110

116111

117112
/**
118-
* @depends testBundle
119-
*
120113
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
121114
*/
115+
#[Depends('testBundle')]
122116
public function testToString(PEMBundle $bundle): void
123117
{
124118
$this->assertIsString(strval($bundle));
@@ -168,10 +162,9 @@ public function testLastEmptyFail(): void
168162

169163

170164
/**
171-
* @depends testBundle
172-
*
173165
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEMBundle $bundle
174166
*/
167+
#[Depends('testBundle')]
175168
public function testWithPEMs(PEMBundle $bundle): void
176169
{
177170
$bundle = $bundle->withPEMs(new PEM('TEST', 'data'));

tests/CryptoEncoding/PEMTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace SimpleSAML\XMLSecurity\Test\CryptoEncoding;
66

7+
use PHPUnit\Framework\Attributes\Depends;
8+
use PHPUnit\Framework\Attributes\Group;
79
use PHPUnit\Framework\TestCase;
810
use RuntimeException;
911
use SimpleSAML\XMLSecurity\CryptoEncoding\PEM;
@@ -14,10 +16,9 @@
1416
use function file_get_contents;
1517

1618
/**
17-
* @group pem
18-
*
1919
* @internal
2020
*/
21+
#[Group('pem')]
2122
class PEMTest extends TestCase
2223
{
2324
private static string $baseDir;
@@ -51,10 +52,9 @@ public function testFromFile(): PEM
5152

5253

5354
/**
54-
* @depends testFromFile
55-
*
5655
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $pem
5756
*/
57+
#[Depends('testFromFile')]
5858
public function testType(PEM $pem): void
5959
{
6060
$this->assertEquals(PEM::TYPE_PUBLIC_KEY, $pem->type());
@@ -101,21 +101,19 @@ public function testInvalidFile(): void
101101

102102

103103
/**
104-
* @depends testFromFile
105-
*
106104
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $pem
107105
*/
106+
#[Depends('testFromFile')]
108107
public function testString(PEM $pem): void
109108
{
110109
$this->assertIsString($pem->string());
111110
}
112111

113112

114113
/**
115-
* @depends testFromFile
116-
*
117114
* @param \SimpleSAML\XMLSecurity\CryptoEncoding\PEM $pem
118115
*/
116+
#[Depends('testFromFile')]
119117
public function testToString(PEM $pem): void
120118
{
121119
$this->assertIsString(strval($pem));

tests/Utils/CertificateTest.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44

55
namespace SimpleSAML\XMLSecurity\Test\Utils;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\Attributes\Test;
710
use PHPUnit\Framework\TestCase;
811
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
912
use SimpleSAML\XMLSecurity\Utils\Certificate;
1013

1114
/**
12-
* @covers \SimpleSAML\XMLSecurity\Utils\Certificate
1315
* @package simplesamlphp/xml-security
1416
*/
17+
#[Group('utilities')]
18+
#[CoversClass(Certificate::class)]
1519
final class CertificateTest extends TestCase
1620
{
17-
/**
18-
* @group utilities
19-
* @test
20-
*/
21+
#[Test]
2122
public function testValidStructure(): void
2223
{
2324
$result = Certificate::hasValidStructure(
@@ -32,10 +33,7 @@ public function testValidStructure(): void
3233
}
3334

3435

35-
/**
36-
* @group utilities
37-
* @test
38-
*/
36+
#[Test]
3937
public function testConvertToCertificate(): void
4038
{
4139
$result = Certificate::convertToCertificate(PEMCertificatesMock::getPlainCertificateContents());
@@ -44,8 +42,7 @@ public function testConvertToCertificate(): void
4442
}
4543

4644

47-
/**
48-
*/
45+
#[Test]
4946
public function testParseIssuer(): void
5047
{
5148
// Test string input

tests/XML/CustomSignableTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SimpleSAML\XMLSecurity\Test\XML;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use SimpleSAML\XML\DOMDocumentFactory;
910
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
@@ -15,9 +16,9 @@
1516
/**
1617
* Class \SimpleSAML\XMLSecurity\Test\XML\CustomSignableTest
1718
*
18-
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable
1919
* @package simplesamlphp/xml-security
2020
*/
21+
#[CoversClass(CustomSignable::class)]
2122
final class CustomSignableTest extends TestCase
2223
{
2324
use SerializableElementTestTrait;

tests/XML/EncryptedCustomTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimpleSAML\XMLSecurity\Test\XML;
66

77
use DOMElement;
8+
use PHPUnit\Framework\Attributes\CoversClass;
89
use PHPUnit\Framework\TestCase;
910
use SimpleSAML\XML\DOMDocumentFactory;
1011
use SimpleSAML\XMLSecurity\Alg\Encryption\EncryptionAlgorithmFactory;
@@ -13,19 +14,21 @@
1314
use SimpleSAML\XMLSecurity\Key\PrivateKey;
1415
use SimpleSAML\XMLSecurity\Key\PublicKey;
1516
use SimpleSAML\XMLSecurity\Key\SymmetricKey;
17+
use SimpleSAML\XMLSecurity\Test\XML\EncryptedCustom;
1618
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
19+
use SimpleSAML\XMLSecurity\XML\EncryptableElementTrait;
20+
use SimpleSAML\XMLSecurity\XML\EncryptedElementTrait;
1721

1822
use function dirname;
1923

2024
/**
2125
* Class \SimpleSAML\XMLSecurity\Test\XML\EncryptedCustomTest
2226
*
23-
* @covers \SimpleSAML\XMLSecurity\XML\EncryptableElementTrait
24-
* @covers \SimpleSAML\XMLSecurity\XML\EncryptedElementTrait
25-
* @covers \SimpleSAML\XMLSecurity\Test\XML\EncryptedCustom
26-
*
2727
* @package simplesamlphp/xml-security
2828
*/
29+
#[CoversClass(EncryptableElementTrait::class)]
30+
#[CoversClass(EncryptedElementTrait::class)]
31+
#[CoversClass(EncryptedCustom::class)]
2932
class EncryptedCustomTest extends TestCase
3033
{
3134
/** @var \DOMElement */

tests/XML/SignableElementTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
namespace SimpleSAML\XMLSecurity\Test\XML;
66

77
use DOMDocument;
8+
use PHPUnit\Framework\Attributes\CoversClass;
89
use PHPUnit\Framework\TestCase;
910
use SimpleSAML\XML\DOMDocumentFactory;
1011
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
1112
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
1213
use SimpleSAML\XMLSecurity\Constants as C;
1314
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
1415
use SimpleSAML\XMLSecurity\Key\PrivateKey;
16+
use SimpleSAML\XMLSecurity\Test\XML\CustomSignable;
1517
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
1618
use SimpleSAML\XMLSecurity\XML\ds\KeyInfo;
1719
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
@@ -28,10 +30,9 @@
2830
/**
2931
* Class \SimpleSAML\XMLSecurity\Test\XML\SignableElementTest
3032
*
31-
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable
32-
*
3333
* @package simplesamlphp/xml-security
3434
*/
35+
#[CoversClass(CustomSignable::class)]
3536
final class SignableElementTest extends TestCase
3637
{
3738
use SerializableElementTestTrait;

tests/XML/SignedElementTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimpleSAML\XMLSecurity\Test\XML;
66

77
use DOMElement;
8+
use PHPUnit\Framework\Attributes\CoversClass;
89
use PHPUnit\Framework\TestCase;
910
use SimpleSAML\XML\DOMDocumentFactory;
1011
use SimpleSAML\XMLSecurity\Alg\Signature\SignatureAlgorithmFactory;
@@ -13,20 +14,21 @@
1314
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
1415
use SimpleSAML\XMLSecurity\Key\PublicKey;
1516
use SimpleSAML\XMLSecurity\Key\X509Certificate;
17+
use SimpleSAML\XMLSecurity\Test\XML\CustomSignable;
1618
use SimpleSAML\XMLSecurity\TestUtils\PEMCertificatesMock;
1719
use SimpleSAML\XMLSecurity\XML\ds\Signature;
20+
use SimpleSAML\XMLSecurity\XML\SignedElementTrait;
1821

1922
use function dirname;
2023
use function strval;
2124

2225
/**
2326
* Class \SimpleSAML\XMLSecurity\Test\XML\SignedElementTest
2427
*
25-
* @covers \SimpleSAML\XMLSecurity\XML\SignedElementTrait
26-
* @covers \SimpleSAML\XMLSecurity\Test\XML\CustomSignable
27-
*
2828
* @package simplesamlphp/xml-security
2929
*/
30+
#[CoversClass(SignedElementTrait::class)]
31+
#[CoversClass(CustomSignable::class)]
3032
final class SignedElementTest extends TestCase
3133
{
3234
/** @var \SimpleSAML\XMLSecurity\CryptoEncoding\PEM */

tests/XML/ds/CanonicalizationMethodTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@
44

55
namespace SimpleSAML\XMLSecurity\Test\XML\ds;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use SimpleSAML\XML\DOMDocumentFactory;
910
use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait;
1011
use SimpleSAML\XML\TestUtils\SerializableElementTestTrait;
1112
use SimpleSAML\XMLSecurity\Constants as C;
13+
use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
1214
use SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod;
1315

1416
use function dirname;
1517

1618
/**
1719
* Class \SimpleSAML\XMLSecurity\Test\XML\ds\CanonicalizationMethodTest
1820
*
19-
* @covers \SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement
20-
* @covers \SimpleSAML\XMLSecurity\XML\ds\CanonicalizationMethod
21-
*
2221
* @package simplesamlphp/xml-security
2322
*/
23+
#[CoversClass(AbstractDsElement::class)]
24+
#[CoversClass(CanonicalizationMethod::class)]
2425
final class CanonicalizationMethodTest extends TestCase
2526
{
2627
use SchemaValidationTestTrait;

0 commit comments

Comments
 (0)