diff --git a/composer.json b/composer.json index 172013d..57cbd22 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "simplesamlphp/assert": "^1.1" }, "require-dev": { - "simplesamlphp/simplesamlphp-test-framework": "^1.5" + "simplesamlphp/simplesamlphp-test-framework": "^1.6" }, "support": { "issues": "https://github.com/simplesamlphp/xml-common/issues", diff --git a/src/TestUtils/SchemaValidationTestTrait.php b/src/TestUtils/SchemaValidationTestTrait.php index c9ebf8d..bf5048e 100644 --- a/src/TestUtils/SchemaValidationTestTrait.php +++ b/src/TestUtils/SchemaValidationTestTrait.php @@ -7,6 +7,7 @@ use DOMDocument; use Exception; use LibXMLError; // Officially spelled with a lower-case `l`, but that breaks composer-require-checker +use PHPUnit\Framework\Attributes\Depends; use SimpleSAML\Assert\Assert; use SimpleSAML\XML\Exception\SchemaViolationException; use XMLReader; @@ -37,9 +38,8 @@ trait SchemaValidationTestTrait /** * Test schema validation. - * - * @depends testSerialization */ + #[Depends('testSerialization')] public function testSchemaValidation(): void { if (!class_exists(self::$testedClass)) { diff --git a/src/TestUtils/SerializableElementTestTrait.php b/src/TestUtils/SerializableElementTestTrait.php index 27736a1..ede744e 100644 --- a/src/TestUtils/SerializableElementTestTrait.php +++ b/src/TestUtils/SerializableElementTestTrait.php @@ -5,6 +5,7 @@ namespace SimpleSAML\XML\TestUtils; use DOMDocument; +use PHPUnit\Framework\Attributes\Depends; use function class_exists; @@ -56,10 +57,9 @@ public function testUnmarshalling(): void /** * Test serialization / unserialization. - * - * @depends testMarshalling - * @depends testUnmarshalling */ + #[Depends('testMarshalling')] + #[Depends('testUnmarshalling')] public function testSerialization(): void { if (!class_exists(self::$testedClass)) { diff --git a/tests/Utils/RandomTest.php b/tests/Utils/RandomTest.php index 507c6c4..1e671ed 100644 --- a/tests/Utils/RandomTest.php +++ b/tests/Utils/RandomTest.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Test\XML\Utils; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\Utils\Random; @@ -11,9 +12,8 @@ /** * Tests for SimpleSAML\XML\Utils\Random. - * - * @covers \SimpleSAML\XML\Utils\Random */ +#[CoversClass(Random::class)] class RandomTest extends TestCase { /** diff --git a/tests/XML/AbstractElementTest.php b/tests/XML/AbstractElementTest.php index 8f91d9b..1f87099 100644 --- a/tests/XML/AbstractElementTest.php +++ b/tests/XML/AbstractElementTest.php @@ -4,8 +4,10 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\Element; +use SimpleSAML\XML\AbstractElement; use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\Exception\MissingAttributeException; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; @@ -16,11 +18,10 @@ /** * Class \SimpleSAML\XML\AbstractElementTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\AbstractElement - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(AbstractElement::class)] final class AbstractElementTest extends TestCase { use SerializableElementTestTrait; diff --git a/tests/XML/AttributeTest.php b/tests/XML/AttributeTest.php index 549f137..84d9766 100644 --- a/tests/XML/AttributeTest.php +++ b/tests/XML/AttributeTest.php @@ -5,6 +5,7 @@ namespace SimpleSAML\Test\XML; use DOMDocument; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\Attribute; use SimpleSAML\XML\DOMDocumentFactory; @@ -13,11 +14,10 @@ /** * Class \SimpleSAML\XML\AttributeTest * - * @covers \SimpleSAML\XML\Attribute - * @covers \SimpleSAML\XML\TestUtils\ArrayizableElementTestTrait - * * @package simplesamlphp\xml-common */ +#[CoversClass(ArrayizableElementTestTrait::class)] +#[CoversClass(Attribute::class)] final class AttributeTest extends TestCase { use ArrayizableElementTestTrait; diff --git a/tests/XML/Base64ElementTraitTest.php b/tests/XML/Base64ElementTraitTest.php index 8765f81..1f19d1f 100644 --- a/tests/XML/Base64ElementTraitTest.php +++ b/tests/XML/Base64ElementTraitTest.php @@ -4,9 +4,13 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\XMLDumper; +use SimpleSAML\XML\Base64ElementTrait; use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\StringElementTrait; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use function dirname; @@ -15,13 +19,12 @@ /** * Class \SimpleSAML\XML\Base64ElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\Base64ElementTrait - * @covers \SimpleSAML\XML\StringElementTrait - * @covers \SimpleSAML\XML\AbstractElement - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(Base64ElementTrait::class)] +#[CoversClass(StringElementTrait::class)] +#[CoversClass(AbstractElement::class)] final class Base64ElementTraitTest extends TestCase { use SerializableElementTestTrait; @@ -65,8 +68,8 @@ public function testUnmarshalling(): void /** * @param non-empty-string $xml - * @dataProvider provideBase64Cases */ + #[DataProvider('provideBase64Cases')] public function testBase64Cases(string $xml): void { $xmlRepresentation = DOMDocumentFactory::fromString($xml); diff --git a/tests/XML/BooleanElementTraitTest.php b/tests/XML/BooleanElementTraitTest.php index 9565787..a8e1280 100644 --- a/tests/XML/BooleanElementTraitTest.php +++ b/tests/XML/BooleanElementTraitTest.php @@ -4,8 +4,10 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\BooleanElement; +use SimpleSAML\XML\BooleanElementTrait; use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; @@ -15,12 +17,11 @@ /** * Class \SimpleSAML\XML\BooleanElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\BooleanElementTrait - * @covers \SimpleSAML\XML\AbstractElement - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(BooleanElementTrait::class)] +#[CoversClass(AbstractElement::class)] final class BooleanElementTraitTest extends TestCase { use SerializableElementTestTrait; diff --git a/tests/XML/ChunkTest.php b/tests/XML/ChunkTest.php index c413adc..5893b0c 100644 --- a/tests/XML/ChunkTest.php +++ b/tests/XML/ChunkTest.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\Chunk; use SimpleSAML\XML\DOMDocumentFactory; @@ -16,11 +17,10 @@ /** * Class \SimpleSAML\XML\ChunkTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\Chunk - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(Chunk::class)] final class ChunkTest extends TestCase { use SerializableElementTestTrait; diff --git a/tests/XML/DOMDocumentFactoryTest.php b/tests/XML/DOMDocumentFactoryTest.php index 9c01396..2e01f03 100644 --- a/tests/XML/DOMDocumentFactoryTest.php +++ b/tests/XML/DOMDocumentFactoryTest.php @@ -4,6 +4,8 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use RuntimeException; use SimpleSAML\Assert\AssertionFailedException; @@ -13,14 +15,12 @@ use function strval; /** - * @covers \SimpleSAML\XML\DOMDocumentFactory * @package simplesamlphp\xml-common */ +#[CoversClass(DOMDocumentFactory::class)] +#[Group('domdocument')] final class DOMDocumentFactoryTest extends TestCase { - /** - * @group domdocument - */ public function testNotXmlStringRaisesAnException(): void { $this->expectException(UnparseableXMLException::class); @@ -28,9 +28,6 @@ public function testNotXmlStringRaisesAnException(): void } - /** - * @group domdocument - */ public function testXmlStringIsCorrectlyLoaded(): void { $xml = ''; @@ -41,8 +38,6 @@ public function testXmlStringIsCorrectlyLoaded(): void } - /** - */ public function testFileThatDoesNotExistIsNotAccepted(): void { $this->expectException(RuntimeException::class); @@ -51,9 +46,6 @@ public function testFileThatDoesNotExistIsNotAccepted(): void } - /** - * @group domdocument - */ public function testFileThatDoesNotContainXMLCannotBeLoaded(): void { $this->expectException(RuntimeException::class); @@ -61,9 +53,6 @@ public function testFileThatDoesNotContainXMLCannotBeLoaded(): void } - /** - * @group domdocument - */ public function testFileWithValidXMLCanBeLoaded(): void { $file = 'resources/xml/domdocument_valid_xml.xml'; @@ -73,9 +62,6 @@ public function testFileWithValidXMLCanBeLoaded(): void } - /** - * @group domdocument - */ public function testFileThatContainsDocTypeIsNotAccepted(): void { $file = 'resources/xml/domdocument_doctype.xml'; @@ -87,9 +73,6 @@ public function testFileThatContainsDocTypeIsNotAccepted(): void } - /** - * @group domdocument - */ public function testStringThatContainsDocTypeIsNotAccepted(): void { $xml = ' ]>'; @@ -101,9 +84,6 @@ public function testStringThatContainsDocTypeIsNotAccepted(): void } - /** - * @group domdocument - */ public function testEmptyFileIsNotValid(): void { $file = 'resources/xml/domdocument_empty.xml'; @@ -113,9 +93,6 @@ public function testEmptyFileIsNotValid(): void } - /** - * @group domdocument - */ public function testEmptyStringIsNotValid(): void { $this->expectException(AssertionFailedException::class); diff --git a/tests/XML/Exception/IOExceptionTest.php b/tests/XML/Exception/IOExceptionTest.php index 6aec975..6fd7887 100644 --- a/tests/XML/Exception/IOExceptionTest.php +++ b/tests/XML/Exception/IOExceptionTest.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\Exception\IOException; @@ -11,9 +12,8 @@ * Empty shell class for testing IOException. * * @package simplesaml/xml-security - * - * @covers \SimpleSAML\XML\Exception\IOException */ +#[CoversClass(IOException::class)] final class IOExceptionTest extends TestCase { /** diff --git a/tests/XML/Exception/UnparseableXMLExceptionTest.php b/tests/XML/Exception/UnparseableXMLExceptionTest.php index 557d004..7f3f1de 100644 --- a/tests/XML/Exception/UnparseableXMLExceptionTest.php +++ b/tests/XML/Exception/UnparseableXMLExceptionTest.php @@ -5,6 +5,7 @@ namespace SimpleSAML\Test\XML; use LibXMLError; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\Exception\UnparseableXMLException; @@ -12,9 +13,8 @@ * Empty shell class for testing UnparseableXMLException. * * @package simplesaml/xml-security - * - * @covers \SimpleSAML\XML\Exception\UnparseableXMLException */ +#[CoversClass(UnparseableXMLException::class)] final class UnparseableXMLExceptionTest extends TestCase { /** @var \LibXMLError $libxmlerror */ diff --git a/tests/XML/ExtendableAttributesTest.php b/tests/XML/ExtendableAttributesTest.php index 2cfe820..17603f4 100644 --- a/tests/XML/ExtendableAttributesTest.php +++ b/tests/XML/ExtendableAttributesTest.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\ExtendableAttributesElement; use SimpleSAML\XML\Attribute; @@ -16,11 +17,10 @@ /** * Class \SimpleSAML\XML\ExtendableAttributesTest * - * @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * * @package simplesamlphp\xml-common */ +#[CoversClass(SchemaValidationTestTrait::class)] +#[CoversClass(SerializableElementTestTrait::class)] final class ExtendableAttributesTest extends TestCase { use SchemaValidationTestTrait; diff --git a/tests/XML/ExtendableAttributesTraitTest.php b/tests/XML/ExtendableAttributesTraitTest.php index a6178b6..13ebcec 100644 --- a/tests/XML/ExtendableAttributesTraitTest.php +++ b/tests/XML/ExtendableAttributesTraitTest.php @@ -4,21 +4,24 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Assert\AssertionFailedException; use SimpleSAML\Test\XML\ExtendableAttributesElement; +use SimpleSAML\Test\XML\ExtendableAttributesTrait; use SimpleSAML\XML\Attribute; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use SimpleSAML\XML\XsNamespace as NS; /** * Class \SimpleSAML\XML\ExtendableAttributesTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\ExtendableAttributesTrait - * * @package simplesamlphp\xml-common */ +#[CoversClass(SchemaValidationTestTrait::class)] +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(ExtendableElementTestTrait::class)] final class ExtendableAttributesTraitTest extends TestCase { /** @var \SimpleSAML\XML\Attribute */ diff --git a/tests/XML/ExtendableElementTest.php b/tests/XML/ExtendableElementTest.php index 5cf1073..9d09ca1 100644 --- a/tests/XML/ExtendableElementTest.php +++ b/tests/XML/ExtendableElementTest.php @@ -4,6 +4,7 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\Chunk; use SimpleSAML\XML\DOMDocumentFactory; @@ -16,11 +17,10 @@ /** * Class \SimpleSAML\XML\ExtendableElementTest * - * @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * * @package simplesamlphp\xml-common */ +#[CoversClass(SchemaValidationTestTrait::class)] +#[CoversClass(SerializableElementTestTrait::class)] final class ExtendableElementTest extends TestCase { use SchemaValidationTestTrait; diff --git a/tests/XML/ExtendableElementTraitTest.php b/tests/XML/ExtendableElementTraitTest.php index 8c40b44..ea09589 100644 --- a/tests/XML/ExtendableElementTraitTest.php +++ b/tests/XML/ExtendableElementTraitTest.php @@ -4,23 +4,26 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Assert\AssertionFailedException; use SimpleSAML\Test\XML\ExtendableElement; use SimpleSAML\XML\Chunk; use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\ElementInterface; +use SimpleSAML\XML\ExtendableElementTrait; +use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; +use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use SimpleSAML\XML\XsNamespace as NS; /** * Class \SimpleSAML\XML\ExtendableElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SchemaValidationTestTrait - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\ExtendableElementTrait - * * @package simplesamlphp\xml-common */ +#[CoversClass(SchemaValidationTestTrait::class)] +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(ExtendableElementTrait::class)] final class ExtendableElementTraitTest extends TestCase { /** @var \SimpleSAML\XML\SerializableElementInterface */ diff --git a/tests/XML/LocalizedStringElementTraitTest.php b/tests/XML/LocalizedStringElementTraitTest.php index c4198ad..4266630 100644 --- a/tests/XML/LocalizedStringElementTraitTest.php +++ b/tests/XML/LocalizedStringElementTraitTest.php @@ -4,9 +4,12 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\LocalizedStringElement; +use SimpleSAML\XML\AbstractElement; use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\LocalizedStringElementTrait; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use function dirname; @@ -15,12 +18,11 @@ /** * Class \SimpleSAML\XML\LocalizedStringElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\LocalizedStringElementTrait - * @covers \SimpleSAML\XML\AbstractElement - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(LocalizedStringElementTrait::class)] +#[CoversClass(AbstractElement::class)] final class LocalizedStringElementTraitTest extends TestCase { use SerializableElementTestTrait; diff --git a/tests/XML/QNameElementTraitTest.php b/tests/XML/QNameElementTraitTest.php index f0300f6..4610efe 100644 --- a/tests/XML/QNameElementTraitTest.php +++ b/tests/XML/QNameElementTraitTest.php @@ -4,9 +4,11 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\XML\DOMDocumentFactory; use SimpleSAML\XML\Exception\SchemaViolationException; +use SimpleSAML\XML\QNameElementTrait; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use function dirname; @@ -15,11 +17,10 @@ /** * Class \SimpleSAML\Test\XML\QNameElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\QNameElementTrait - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(QNameElementTrait::class)] final class QNameElementTraitTest extends TestCase { use SerializableElementTestTrait; diff --git a/tests/XML/StringElementTraitTest.php b/tests/XML/StringElementTraitTest.php index 5b2750c..aeb66b8 100644 --- a/tests/XML/StringElementTraitTest.php +++ b/tests/XML/StringElementTraitTest.php @@ -4,9 +4,12 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\StringElement; +use SimpleSAML\XML\AbstractElement; use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\StringElementTrait; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use function dirname; @@ -15,12 +18,11 @@ /** * Class \SimpleSAML\XML\StringElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\StringElementTrait - * @covers \SimpleSAML\XML\AbstractElement - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(StringElementTrait::class)] +#[CoversClass(AbstractElement::class)] final class StringElementTraitTest extends TestCase { use SerializableElementTestTrait; diff --git a/tests/XML/URIElementTraitTest.php b/tests/XML/URIElementTraitTest.php index be7f4bb..27d3e59 100644 --- a/tests/XML/URIElementTraitTest.php +++ b/tests/XML/URIElementTraitTest.php @@ -4,9 +4,12 @@ namespace SimpleSAML\Test\XML; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; use SimpleSAML\Test\XML\URIElement; +use SimpleSAML\XML\AbstractElement; use SimpleSAML\XML\DOMDocumentFactory; +use SimpleSAML\XML\URIElementTrait; use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; use function dirname; @@ -15,12 +18,11 @@ /** * Class \SimpleSAML\XML\URIElementTraitTest * - * @covers \SimpleSAML\XML\TestUtils\SerializableElementTestTrait - * @covers \SimpleSAML\XML\URIElementTrait - * @covers \SimpleSAML\XML\AbstractElement - * * @package simplesamlphp\xml-common */ +#[CoversClass(SerializableElementTestTrait::class)] +#[CoversClass(URIElementTrait::class)] +#[CoversClass(AbstractElement::class)] final class URIElementTraitTest extends TestCase { use SerializableElementTestTrait; diff --git a/tools/composer-require-checker.json b/tools/composer-require-checker.json new file mode 100644 index 0000000..0ba3560 --- /dev/null +++ b/tools/composer-require-checker.json @@ -0,0 +1,5 @@ +{ + "symbol-whitelist": [ + "PHPUnit\\Framework\\Attributes\\Depends", + ] +}