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 9d8bff3 commit 8598fb2
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.idea/
/.phpunit.cache/
.phpunit.cache/
.phpunit.result.cache
/build/
/cache.properties/
Expand Down
18 changes: 10 additions & 8 deletions tests/Assert/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace SimpleSAML\Test\Assert;

use BadMethodCallException; // Requires ext-spl
use DateTimeImmutable; // Requires ext-spl
use LogicException; // Requires ext-spl
use BadMethodCallException;
use DateTimeImmutable;
use LogicException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
use SimpleSAML\Assert\Assert;
Expand All @@ -18,15 +21,14 @@
use function sys_get_temp_dir;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\AssertTest
*
* @package simplesamlphp/assert
*/
#[CoversClass(Assert::class)]
final class AssertTest extends TestCase
{
/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testAssertionPassing(): void
{
Assert::integer(1);
Expand Down Expand Up @@ -114,10 +116,10 @@ public function testAllCustomAssertionWorks(): void


/**
* @dataProvider provideValue
* @param mixed $value
* @param string $expected
*/
#[DataProvider('provideValue')]
public function testValueToString(mixed $value, string $expected): void
{
$assert = new Assert();
Expand Down
10 changes: 5 additions & 5 deletions tests/Assert/Base64Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\Base64Test
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::stringPlausibleBase64
*/
#[CoversClass(Assert::class)]
final class Base64Test extends TestCase
{
/**
* @dataProvider provideBase64
* @param boolean $shouldPass
* @param string $name
*/
#[DataProvider('provideBase64')]
public function testStringPlausibleBase64(bool $shouldPass, string $name): void
{
try {
Expand Down
13 changes: 6 additions & 7 deletions tests/Assert/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\DateTimeTest
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::validDateTime
* @covers \SimpleSAML\Assert\Assert::validDateTimeZulu
*/
#[CoversClass(Assert::class)]
final class DateTimeTest extends TestCase
{
/**
* @dataProvider provideDateTime
* @param boolean $shouldPass
* @param string $timestamp
*/
#[DataProvider('provideDateTime')]
public function testValidDateTime(bool $shouldPass, string $timestamp): void
{
try {
Expand All @@ -36,10 +35,10 @@ public function testValidDateTime(bool $shouldPass, string $timestamp): void


/**
* @dataProvider provideDateTimeZulu
* @param boolean $shouldPass
* @param string $timestamp
*/
#[DataProvider('provideDateTimeZulu')]
public function testValidDateTimeZulu(bool $shouldPass, string $timestamp): void
{
try {
Expand Down
10 changes: 5 additions & 5 deletions tests/Assert/DurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\DurationTest
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::validDuration
*/
#[CoversClass(Assert::class)]
final class DurationTest extends TestCase
{
/**
* @dataProvider provideDuration
* @param boolean $shouldPass
* @param string $duration
*/
#[DataProvider('provideDuration')]
public function testValidDuration(bool $shouldPass, string $duration): void
{
try {
Expand Down
10 changes: 5 additions & 5 deletions tests/Assert/NCNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\NCNameTest
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::validNCName
*/
#[CoversClass(Assert::class)]
final class NCNameTest extends TestCase
{
/**
* @dataProvider provideNCName
* @param boolean $shouldPass
* @param string $name
*/
#[DataProvider('provideNCName')]
public function testValidNCName(bool $shouldPass, string $name): void
{
try {
Expand Down
10 changes: 5 additions & 5 deletions tests/Assert/NotInArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\NotInArrayTest
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::notInArray
*/
#[CoversClass(Assert::class)]
final class NotInArrayTest extends TestCase
{
/**
* @dataProvider provideNotInArray
* @param boolean $shouldPass
* @param mixed $item
* @param array<mixed> $arr
*/
#[DataProvider('provideNotInArray')]
public function testnotInArray(bool $shouldPass, $item, array $arr): void
{
try {
Expand Down
10 changes: 5 additions & 5 deletions tests/Assert/QNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\QNameTest
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::validQName
*/
#[CoversClass(Assert::class)]
final class QNameTest extends TestCase
{
/**
* @dataProvider provideQName
* @param boolean $shouldPass
* @param string $name
*/
#[DataProvider('provideQName')]
public function testValidQName(bool $shouldPass, string $name): void
{
try {
Expand Down
16 changes: 7 additions & 9 deletions tests/Assert/URITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@

namespace SimpleSAML\Test\Assert;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use SimpleSAML\Assert\Assert;
use SimpleSAML\Assert\AssertionFailedException;

/**
* Class \SimpleSAML\Assert\Assert
* Class \SimpleSAML\Assert\URITest
*
* @package simplesamlphp/assert
*
* @covers \SimpleSAML\Assert\Assert::__callStatic
* @covers \SimpleSAML\Assert\Assert::validURI
* @covers \SimpleSAML\Assert\Assert::validURL
* @covers \SimpleSAML\Assert\Assert::validURN
*/
#[CoversClass(Assert::class)]
final class URITest extends TestCase
{
/**
* @dataProvider provideURI
* @param boolean $shouldPass
* @param string $uri
*/
#[DataProvider('provideURI')]
public function testValidURI(bool $shouldPass, string $uri): void
{
try {
Expand All @@ -37,10 +35,10 @@ public function testValidURI(bool $shouldPass, string $uri): void


/**
* @dataProvider provideURL
* @param boolean $shouldPass
* @param string $url
*/
#[DataProvider('provideURL')]
public function testValidURL(bool $shouldPass, string $url): void
{
try {
Expand All @@ -53,10 +51,10 @@ public function testValidURL(bool $shouldPass, string $url): void


/**
* @dataProvider provideURN
* @param boolean $shouldPass
* @param string $urn
*/
#[DataProvider('provideURN')]
public function testValidURN(bool $shouldPass, string $urn): void
{
try {
Expand Down

0 comments on commit 8598fb2

Please sign in to comment.