Skip to content

Commit

Permalink
Replace docblocks with attributes where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
christeredvartsen committed Jan 6, 2025
1 parent bdc7f3f commit a619e5c
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 656 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"ci": [
"@phpunit",
"@behat",
"@sa",
"@cs"
],
"test": [
Expand Down
19 changes: 5 additions & 14 deletions tests/ArrayContainsComparator/Matcher/ArrayLengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace Imbo\BehatApiExtension\ArrayContainsComparator\Matcher;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\ArrayLength
*/
#[CoversClass(ArrayLength::class)]
class ArrayLengthTest extends TestCase
{
private ArrayLength $matcher;
Expand Down Expand Up @@ -56,10 +56,7 @@ public static function getValuesThatFail(): array
];
}

/**
* @dataProvider getArraysAndLengths
* @covers ::__invoke
*/
#[DataProvider('getArraysAndLengths')]
public function testCanMatchLengthOfArrays(array $list, int $length): void
{
$matcher = $this->matcher;
Expand All @@ -70,9 +67,6 @@ public function testCanMatchLengthOfArrays(array $list, int $length): void
);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionWhenMatchingLengthAgainstAnythingOtherThanAnArray(): void
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -81,10 +75,7 @@ public function testThrowsExceptionWhenMatchingLengthAgainstAnythingOtherThanAnA
$matcher(['foo' => 'bar'], 123);
}

/**
* @dataProvider getValuesThatFail
* @covers ::__invoke
*/
#[DataProvider('getValuesThatFail')]
public function testThrowsExceptionWhenLengthIsNotCorrect(array $list, int $maxLength, string $message): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
19 changes: 5 additions & 14 deletions tests/ArrayContainsComparator/Matcher/ArrayMaxLengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace Imbo\BehatApiExtension\ArrayContainsComparator\Matcher;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\ArrayMaxLength
*/
#[CoversClass(ArrayMaxLength::class)]
class ArrayMaxLengthTest extends TestCase
{
private ArrayMaxLength $matcher;
Expand Down Expand Up @@ -56,10 +56,7 @@ public static function getValuesThatFail(): array
];
}

/**
* @dataProvider getArraysAndLengths
* @covers ::__invoke
*/
#[DataProvider('getArraysAndLengths')]
public function testCanMatchMaxLengthOfArrays(array $list, int $length): void
{
$matcher = $this->matcher;
Expand All @@ -69,9 +66,6 @@ public function testCanMatchMaxLengthOfArrays(array $list, int $length): void
);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionWhenMatchingAgainstAnythingOtherThanAnArray(): void
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -80,10 +74,7 @@ public function testThrowsExceptionWhenMatchingAgainstAnythingOtherThanAnArray()
$matcher(['foo' => 'bar'], 123);
}

/**
* @dataProvider getValuesThatFail
* @covers ::__invoke
*/
#[DataProvider('getValuesThatFail')]
public function testThrowsExceptionWhenLengthIsTooShort(array $array, int $maxLength, string $message): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
19 changes: 5 additions & 14 deletions tests/ArrayContainsComparator/Matcher/ArrayMinLengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace Imbo\BehatApiExtension\ArrayContainsComparator\Matcher;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\ArrayMinLength
*/
#[CoversClass(ArrayMinLength::class)]
class ArrayMinLengthTest extends TestCase
{
private ArrayMinLength $matcher;
Expand Down Expand Up @@ -56,10 +56,7 @@ public static function getValuesThatFail(): array
];
}

/**
* @dataProvider getArraysAndMinLengths
* @covers ::__invoke
*/
#[DataProvider('getArraysAndMinLengths')]
public function testCanMatchMinLengthOfArrays(array $list, int $min): void
{
$matcher = $this->matcher;
Expand All @@ -69,9 +66,6 @@ public function testCanMatchMinLengthOfArrays(array $list, int $min): void
);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionWhenMatchingAgainstAnythingOtherThanAnArray(): void
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -80,10 +74,7 @@ public function testThrowsExceptionWhenMatchingAgainstAnythingOtherThanAnArray()
$matcher(['foo' => 'bar'], 123);
}

/**
* @dataProvider getValuesThatFail
* @covers ::__invoke
*/
#[DataProvider('getValuesThatFail')]
public function testThrowsExceptionWhenLengthIsTooLong(array $array, int $minLength, string $message): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
22 changes: 5 additions & 17 deletions tests/ArrayContainsComparator/Matcher/GreaterThanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace Imbo\BehatApiExtension\ArrayContainsComparator\Matcher;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\GreaterThan
*/
#[CoversClass(GreaterThan::class)]
class GreaterThanTest extends TestCase
{
private GreaterThan $matcher;
Expand Down Expand Up @@ -66,10 +66,7 @@ public static function getFailingValues(): array
];
}

/**
* @dataProvider getValuesForMatching
* @covers ::__invoke
*/
#[DataProvider('getValuesForMatching')]
public function testCanCompareValuesOfType(int|float|string $number, int|float|string $min): void
{
$matcher = $this->matcher;
Expand All @@ -79,9 +76,6 @@ public function testCanCompareValuesOfType(int|float|string $number, int|float|s
);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionIfNumberIsNotNumeric(): void
{
$matcher = $this->matcher;
Expand All @@ -90,9 +84,6 @@ public function testThrowsExceptionIfNumberIsNotNumeric(): void
$matcher('foo', 123);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionIfMinimumNumberIsNotNumeric(): void
{
$matcher = $this->matcher;
Expand All @@ -101,10 +92,7 @@ public function testThrowsExceptionIfMinimumNumberIsNotNumeric(): void
$matcher(123, 'foo');
}

/**
* @dataProvider getFailingValues
* @covers ::__invoke
*/
#[DataProvider('getFailingValues')]
public function testThrowsExceptionWhenComparisonFails(int|string|float $number, int|string|float $min, string $errorMessage): void
{
$matcher = $this->matcher;
Expand Down
22 changes: 4 additions & 18 deletions tests/ArrayContainsComparator/Matcher/JWTTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use Imbo\BehatApiExtension\ArrayContainsComparator;
use Imbo\BehatApiExtension\Exception\ArrayContainsComparatorException;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\JWT
*/
#[CoversClass(JWT::class)]
class JWTTest extends TestCase
{
private JWT $matcher;
Expand Down Expand Up @@ -45,9 +45,6 @@ public static function getJwt(): array
];
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionWhenMatchingAgainstJwtThatDoesNotExist(): void
{
$matcher = $this->matcher;
Expand All @@ -56,10 +53,6 @@ public function testThrowsExceptionWhenMatchingAgainstJwtThatDoesNotExist(): voi
$matcher('some jwt', 'some name');
}

/**
* @covers ::addToken
* @covers ::__invoke
*/
public function testThrowsExceptionWhenJwtDoesNotMatch(): void
{
$matcher = $this->matcher->addToken('some name', ['some' => 'data'], 'secret');
Expand All @@ -71,10 +64,7 @@ public function testThrowsExceptionWhenJwtDoesNotMatch(): void
);
}

/**
* @covers ::__invoke
* @dataProvider getJwt
*/
#[DataProvider('getJwt')]
public function testCanMatchJwt(string $jwt, string $name, array $payload, string $secret): void
{
$matcher = $this->matcher->addToken($name, $payload, $secret);
Expand All @@ -84,10 +74,6 @@ public function testCanMatchJwt(string $jwt, string $name, array $payload, strin
));
}

/**
* @covers ::__construct
* @covers ::__invoke
*/
public function testThrowsExceptionWhenComparatorDoesNotReturnSuccess(): void
{
$comparator = $this->createConfiguredMock(ArrayContainsComparator::class, [
Expand Down
22 changes: 5 additions & 17 deletions tests/ArrayContainsComparator/Matcher/LessThanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace Imbo\BehatApiExtension\ArrayContainsComparator\Matcher;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\LessThan
*/
#[CoversClass(LessThan::class)]
class LessThanTest extends TestCase
{
private LessThan $matcher;
Expand Down Expand Up @@ -66,10 +66,7 @@ public static function getFailingValues(): array
];
}

/**
* @dataProvider getValuesForMatching
* @covers ::__invoke
*/
#[DataProvider('getValuesForMatching')]
public function testCanCompareValuesOfType(int|string $number, int|string|float $max): void
{
$matcher = $this->matcher;
Expand All @@ -79,9 +76,6 @@ public function testCanCompareValuesOfType(int|string $number, int|string|float
);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionIfNumberIsNotNumeric(): void
{
$matcher = $this->matcher;
Expand All @@ -90,9 +84,6 @@ public function testThrowsExceptionIfNumberIsNotNumeric(): void
$matcher('foo', 123);
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionIfMaximumNumberIsNotNumeric(): void
{
$matcher = $this->matcher;
Expand All @@ -101,10 +92,7 @@ public function testThrowsExceptionIfMaximumNumberIsNotNumeric(): void
$matcher(123, 'foo');
}

/**
* @dataProvider getFailingValues
* @covers ::__invoke
*/
#[DataProvider('getFailingValues')]
public function testThrowsExceptionWhenComparisonFails(int|float|string $number, int|float|string $max, string $errorMessage): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
14 changes: 4 additions & 10 deletions tests/ArrayContainsComparator/Matcher/RegExpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
namespace Imbo\BehatApiExtension\ArrayContainsComparator\Matcher;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversDefaultClass Imbo\BehatApiExtension\ArrayContainsComparator\Matcher\RegExp
*/
#[CoversClass(RegExp::class)]
class RegExpTest extends TestCase
{
private RegExp $matcher;
Expand Down Expand Up @@ -37,19 +37,13 @@ public static function getSubjectsAndPatterns(): array
];
}

/**
* @dataProvider getSubjectsAndPatterns
* @covers ::__invoke
*/
#[DataProvider('getSubjectsAndPatterns')]
public function testCanMatchRegularExpressionPatternsAgainst(float|int|string $subject, string $pattern): void
{
$matcher = $this->matcher;
$this->assertTrue($matcher($subject, $pattern));
}

/**
* @covers ::__invoke
*/
public function testThrowsExceptionIfPatternDoesNotMatchSubject(): void
{
$matcher = $this->matcher;
Expand Down
Loading

0 comments on commit a619e5c

Please sign in to comment.