diff --git a/composer.json b/composer.json index de5d8fe..c3f2de6 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,6 @@ "ci": [ "@phpunit", "@behat", - "@sa", "@cs" ], "test": [ diff --git a/tests/ArrayContainsComparator/Matcher/ArrayLengthTest.php b/tests/ArrayContainsComparator/Matcher/ArrayLengthTest.php index 7a5c992..72b30b4 100644 --- a/tests/ArrayContainsComparator/Matcher/ArrayLengthTest.php +++ b/tests/ArrayContainsComparator/Matcher/ArrayLengthTest.php @@ -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; @@ -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; @@ -70,9 +67,6 @@ public function testCanMatchLengthOfArrays(array $list, int $length): void ); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionWhenMatchingLengthAgainstAnythingOtherThanAnArray(): void { $this->expectException(InvalidArgumentException::class); @@ -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); diff --git a/tests/ArrayContainsComparator/Matcher/ArrayMaxLengthTest.php b/tests/ArrayContainsComparator/Matcher/ArrayMaxLengthTest.php index 18e30c4..8066c63 100644 --- a/tests/ArrayContainsComparator/Matcher/ArrayMaxLengthTest.php +++ b/tests/ArrayContainsComparator/Matcher/ArrayMaxLengthTest.php @@ -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; @@ -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; @@ -69,9 +66,6 @@ public function testCanMatchMaxLengthOfArrays(array $list, int $length): void ); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionWhenMatchingAgainstAnythingOtherThanAnArray(): void { $this->expectException(InvalidArgumentException::class); @@ -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); diff --git a/tests/ArrayContainsComparator/Matcher/ArrayMinLengthTest.php b/tests/ArrayContainsComparator/Matcher/ArrayMinLengthTest.php index 2862916..eb7c64e 100644 --- a/tests/ArrayContainsComparator/Matcher/ArrayMinLengthTest.php +++ b/tests/ArrayContainsComparator/Matcher/ArrayMinLengthTest.php @@ -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; @@ -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; @@ -69,9 +66,6 @@ public function testCanMatchMinLengthOfArrays(array $list, int $min): void ); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionWhenMatchingAgainstAnythingOtherThanAnArray(): void { $this->expectException(InvalidArgumentException::class); @@ -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); diff --git a/tests/ArrayContainsComparator/Matcher/GreaterThanTest.php b/tests/ArrayContainsComparator/Matcher/GreaterThanTest.php index a41a657..bdf7098 100644 --- a/tests/ArrayContainsComparator/Matcher/GreaterThanTest.php +++ b/tests/ArrayContainsComparator/Matcher/GreaterThanTest.php @@ -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; @@ -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; @@ -79,9 +76,6 @@ public function testCanCompareValuesOfType(int|float|string $number, int|float|s ); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionIfNumberIsNotNumeric(): void { $matcher = $this->matcher; @@ -90,9 +84,6 @@ public function testThrowsExceptionIfNumberIsNotNumeric(): void $matcher('foo', 123); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionIfMinimumNumberIsNotNumeric(): void { $matcher = $this->matcher; @@ -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; diff --git a/tests/ArrayContainsComparator/Matcher/JWTTest.php b/tests/ArrayContainsComparator/Matcher/JWTTest.php index 5280567..2227e7d 100644 --- a/tests/ArrayContainsComparator/Matcher/JWTTest.php +++ b/tests/ArrayContainsComparator/Matcher/JWTTest.php @@ -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; @@ -45,9 +45,6 @@ public static function getJwt(): array ]; } - /** - * @covers ::__invoke - */ public function testThrowsExceptionWhenMatchingAgainstJwtThatDoesNotExist(): void { $matcher = $this->matcher; @@ -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'); @@ -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); @@ -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, [ diff --git a/tests/ArrayContainsComparator/Matcher/LessThanTest.php b/tests/ArrayContainsComparator/Matcher/LessThanTest.php index c8db33e..68e4098 100644 --- a/tests/ArrayContainsComparator/Matcher/LessThanTest.php +++ b/tests/ArrayContainsComparator/Matcher/LessThanTest.php @@ -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; @@ -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; @@ -79,9 +76,6 @@ public function testCanCompareValuesOfType(int|string $number, int|string|float ); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionIfNumberIsNotNumeric(): void { $matcher = $this->matcher; @@ -90,9 +84,6 @@ public function testThrowsExceptionIfNumberIsNotNumeric(): void $matcher('foo', 123); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionIfMaximumNumberIsNotNumeric(): void { $matcher = $this->matcher; @@ -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); diff --git a/tests/ArrayContainsComparator/Matcher/RegExpTest.php b/tests/ArrayContainsComparator/Matcher/RegExpTest.php index b5b57ba..e5e4ec3 100644 --- a/tests/ArrayContainsComparator/Matcher/RegExpTest.php +++ b/tests/ArrayContainsComparator/Matcher/RegExpTest.php @@ -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; @@ -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; diff --git a/tests/ArrayContainsComparator/Matcher/VariableTypeTest.php b/tests/ArrayContainsComparator/Matcher/VariableTypeTest.php index 4f5d11c..c39c4c2 100644 --- a/tests/ArrayContainsComparator/Matcher/VariableTypeTest.php +++ b/tests/ArrayContainsComparator/Matcher/VariableTypeTest.php @@ -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\VariableType - */ +#[CoversClass(VariableType::class)] class VariableTypeTest extends TestCase { private VariableType $matcher; @@ -158,11 +158,7 @@ public static function getInvalidMatches(): array ]; } - /** - * @dataProvider getValuesAndTypes - * @covers ::__invoke - * @covers ::normalizeTypes - */ + #[DataProvider('getValuesAndTypes')] public function testCanMatchValuesOfType(mixed $value, string $type): void { $matcher = $this->matcher; @@ -172,9 +168,6 @@ public function testCanMatchValuesOfType(mixed $value, string $type): void ); } - /** - * @covers ::__invoke - */ public function testThrowsExceptionWhenGivenInvalidType(): void { $matcher = $this->matcher; @@ -183,10 +176,7 @@ public function testThrowsExceptionWhenGivenInvalidType(): void $matcher('foo', 'resource'); } - /** - * @dataProvider getInvalidMatches - * @covers ::__invoke - */ + #[DataProvider('getInvalidMatches')] public function testThrowsExceptionWhenTypeOfValueDoesNotMatchExpectedType(mixed $value, string $type, string $message): void { $matcher = $this->matcher; diff --git a/tests/ArrayContainsComparatorTest.php b/tests/ArrayContainsComparatorTest.php index bcac929..25a299d 100644 --- a/tests/ArrayContainsComparatorTest.php +++ b/tests/ArrayContainsComparatorTest.php @@ -4,11 +4,11 @@ use Imbo\BehatApiExtension\ArrayContainsComparator\Matcher; 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 - */ +#[CoversClass(ArrayContainsComparator::class)] class ArrayContainsComparatorTest extends TestCase { private ArrayContainsComparator $comparator; @@ -509,9 +509,6 @@ public static function getCustomFunctionsAndDataThatWillFail(): array ]; } - /** - * @covers ::compare - */ public function testThrowsExceptionWhenMatchingANumericallyIndexedArrayAgainstAnAssociativeArray(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -539,14 +536,7 @@ public function testThrowsExceptionWhenMatchingANumericallyIndexedArrayAgainstAn $this->comparator->compare([1, 2, 3], ['foo' => 'bar']); } - /** - * @dataProvider getDataForInArrayCheck - * @covers ::compare - * @covers ::inArray - * @covers ::compareValues - * @covers ::arrayIsList - * @covers ::arrayIsObject - */ + #[DataProvider('getDataForInArrayCheck')] public function testCanRecursivelyDoInArrayChecksWith(array $needle, array $haystack): void { $this->assertTrue( @@ -555,10 +545,6 @@ public function testCanRecursivelyDoInArrayChecksWith(array $needle, array $hays ); } - /** - * @covers ::compare - * @covers ::inArray - */ public function testThrowsExceptionWhenNeedleValueIsAListAndHaystackDoesNotContainAnyLists(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -584,10 +570,6 @@ public function testThrowsExceptionWhenNeedleValueIsAListAndHaystackDoesNotConta $this->comparator->compare([[1]], [1]); } - /** - * @covers ::compare - * @covers ::inArray - */ public function testThrowsExceptionWhenNeedleValueIsAnObjectAndHaystackDoesNotContainAnyObjects(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -621,10 +603,6 @@ public function testThrowsExceptionWhenNeedleValueIsAnObjectAndHaystackDoesNotCo ]); } - /** - * @covers ::compare - * @covers ::inArray - */ public function testThrowsExceptionWhenHaystackListIsMissingValuesFromNeedleList(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -668,10 +646,6 @@ public function testThrowsExceptionWhenHaystackListIsMissingValuesFromNeedleList ]); } - /** - * @covers ::compare - * @covers ::inArray - */ public function testThrowsExceptionWhenHaystackObjectIsMissingValuesFromNeedleObject(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -735,13 +709,7 @@ public function testThrowsExceptionWhenHaystackObjectIsMissingValuesFromNeedleOb ]); } - /** - * @dataProvider getDataForCompareCheck - * @covers ::compare - * @covers ::compareValues - * @covers ::arrayIsList - * @covers ::arrayIsObject - */ + #[DataProvider('getDataForCompareCheck')] public function testCanRecursivelyCompareAssociativeArraysWith(array $needle, array $haystack): void { $this->assertTrue( @@ -750,9 +718,6 @@ public function testCanRecursivelyCompareAssociativeArraysWith(array $needle, ar ); } - /** - * @covers ::compare - */ public function testThrowsExceptionWhenComparingObjectsAndKeyIsMissingFromHaystack(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -785,9 +750,6 @@ public function testThrowsExceptionWhenComparingObjectsAndKeyIsMissingFromHaysta ], ]); } - /** - * @covers ::compare - */ public function testThrowsExceptionWhenRegularStringKeyValueDoesNotMatch(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -817,10 +779,6 @@ public function testThrowsExceptionWhenRegularStringKeyValueDoesNotMatch(): void ]); } - /** - * @covers ::compare - * @covers ::compareValues - */ public function testCanRecursivelyMatchKeysInObjects(): void { $this->assertTrue( @@ -849,9 +807,6 @@ public function testCanRecursivelyMatchKeysInObjects(): void ); } - /** - * @covers ::compare - */ public function testThrowsExceptionWhenRegularStringKeyValueInDeepObjectDoesNotMatch(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -893,11 +848,7 @@ public function testThrowsExceptionWhenRegularStringKeyValueInDeepObjectDoesNotM ]); } - /** - * @dataProvider getDataForSpecificKeyInListChecks - * @covers ::compare - * @covers ::compareValues - */ + #[DataProvider('getDataForSpecificKeyInListChecks')] public function testCanCompareSpecificIndexesInAListWith(array $needle, array $haystack): void { $this->assertTrue( @@ -906,9 +857,6 @@ public function testCanCompareSpecificIndexesInAListWith(array $needle, array $h ); } - /** - * @covers ::compare - */ public function testThrowsExceptionWhenTargetingAListIndexWithAKeyThatDoesNotExist(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -938,10 +886,7 @@ public function testThrowsExceptionWhenTargetingAListIndexWithAKeyThatDoesNotExi ]); } - /** - * @dataProvider getDataForSpecificKeyInListChecksWithInvalidData - * @covers ::compare - */ + #[DataProvider('getDataForSpecificKeyInListChecksWithInvalidData')] public function testThrowsExceptionWhenTargetingAListIndexWithAKeyThatContains(array $needle, array $haystack, string $exceptionMessage): void { $this->expectException(ArrayContainsComparatorException::class); @@ -949,9 +894,6 @@ public function testThrowsExceptionWhenTargetingAListIndexWithAKeyThatContains(a $this->comparator->compare($needle, $haystack); } - /** - * @covers ::compare - */ public function testThrowsExceptionWhenTargetingAListIndexThatDoesNotExist(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -987,9 +929,6 @@ public function testThrowsExceptionWhenTargetingAListIndexThatDoesNotExist(): vo ]); } - /** - * @covers ::compare - */ public function testThrowsExceptionOnValueMismatchWhenTargetingSpecificIndexInList(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -1015,12 +954,7 @@ public function testThrowsExceptionOnValueMismatchWhenTargetingSpecificIndexInLi ]); } - /** - * @dataProvider getCustomFunctionsAndData - * @covers ::addFunction - * @covers ::compare - * @covers ::compareValues - */ + #[DataProvider('getCustomFunctionsAndData')] public function testCanUseCustomFunctionMatcher(string $function, callable $callback, array $needle, array $haystack): void { $this->assertTrue( @@ -1031,10 +965,6 @@ public function testCanUseCustomFunctionMatcher(string $function, callable $call ); } - /** - * @covers ::compare - * @covers ::compareValues - */ public function testPerformsARegularStringComparisonWhenSpecifiedCustomFunctionMatcherDoesNotExist(): void { $this->expectException(ArrayContainsComparatorException::class); @@ -1063,12 +993,7 @@ public function testPerformsARegularStringComparisonWhenSpecifiedCustomFunctionM ); } - /** - * @dataProvider getCustomFunctionsAndDataThatWillFail - * @covers ::addFunction - * @covers ::compare - * @covers ::compareValues - */ + #[DataProvider('getCustomFunctionsAndDataThatWillFail')] public function testThrowsExceptionWhenCustomFunctionMatcherFails(string $function, callable $callback, array $needle, array $haystack, string $errorMessage): void { $this->expectException(ArrayContainsComparatorException::class); @@ -1081,10 +1006,6 @@ public function testThrowsExceptionWhenCustomFunctionMatcherFails(string $functi ); } - /** - * @covers ::compare - * @covers ::inArray - */ public function testSupportsInArrayCheckWhenListsAreInADeepStructure(): void { $needle = [ @@ -1140,9 +1061,6 @@ public function testSupportsInArrayCheckWhenListsAreInADeepStructure(): void $this->assertTrue($this->comparator->compare($needle, $haystack)); } - /** - * @covers ::getMatcherFunction - */ public function testCanReturnRegisteredMatcherFunction(): void { $f = fn (): bool => true; @@ -1154,9 +1072,6 @@ public function testCanReturnRegisteredMatcherFunction(): void ); } - /** - * @covers ::getMatcherFunction - */ public function testThrowsExceptionWhenGettingFunctionThatDoesNotExist(): void { $this->expectException(InvalidArgumentException::class); diff --git a/tests/Context/ApiContextTest.php b/tests/Context/ApiContextTest.php index 33630a8..f067e61 100644 --- a/tests/Context/ApiContextTest.php +++ b/tests/Context/ApiContextTest.php @@ -15,6 +15,8 @@ use Imbo\BehatApiExtension\Exception\AssertionFailedException; use InvalidArgumentException; use OutOfRangeException; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use RuntimeException; @@ -46,9 +48,7 @@ function is_readable(string $path): bool return \is_readable($path); } -/** - * @coversDefaultClass Imbo\BehatApiExtension\Context\ApiContext - */ +#[CoversClass(ApiContext::class)] class ApiContextTest extends TestCase { private ApiContext $context; @@ -383,9 +383,6 @@ public static function getHttpMethodsForFormParametersTest(): array ]; } - /** - * @covers ::setRequestHeader - */ public function testCanSetRequestHeaders(): void { $this->mockHandler->append(new Response(200)); @@ -405,9 +402,6 @@ public function testCanSetRequestHeaders(): void $this->assertSame('bar', $request->getHeaderLine('bar')); } - /** - * @covers ::addRequestHeader - */ public function testCanAddRequestHeaders(): void { $this->mockHandler->append(new Response(200)); @@ -427,9 +421,6 @@ public function testCanAddRequestHeaders(): void $this->assertSame('foo, bar', $request->getHeaderLine('bar')); } - /** - * @covers ::setBasicAuth - */ public function testSupportBasicHttpAuthentication(): void { $this->mockHandler->append(new Response(200)); @@ -446,9 +437,6 @@ public function testSupportBasicHttpAuthentication(): void $this->assertSame('Basic dXNlcjpwYXNz', $request->getHeaderLine('authorization')); } - /** - * @covers ::oauthWithPasswordGrantInScope - */ public function testSupportOAuthWithPasswordGrant(): void { $this->mockHandler->append(new Response(200, [], '{"access_token": "some_access_token"}')); @@ -490,9 +478,6 @@ public function testSupportOAuthWithPasswordGrant(): void $this->assertSame('Bearer some_access_token', $request->getHeaderLine('authorization')); } - /** - * @covers ::oauthWithPasswordGrantInScope - */ public function testThrowsExceptionWhenOauthAccessTokenRequestFails(): void { $this->mockHandler->append(new Response(401, [], '{"error": "some_error"}')); @@ -502,9 +487,6 @@ public function testThrowsExceptionWhenOauthAccessTokenRequestFails(): void $this->context->oauthWithPasswordGrantInScope('/path', 'username', 'password', 'scope', 'client_id', 'client_secret'); } - /** - * @covers ::oauthWithPasswordGrantInScope - */ public function testThrowsExceptionWhenOauthAccessTokenIsMissingFromResponse(): void { $this->mockHandler->append(new Response(200, [], '{"foo": "bar"}')); @@ -514,10 +496,6 @@ public function testThrowsExceptionWhenOauthAccessTokenIsMissingFromResponse(): $this->context->oauthWithPasswordGrantInScope('/path', 'username', 'password', 'scope', 'client_id', 'client_secret'); } - /** - * @covers ::addMultipartFileToRequest - * @covers ::addMultipartPart - */ public function testCanAddMultipleMultipartFilesToTheRequest(): void { $this->mockHandler->append(new Response(200)); @@ -551,10 +529,6 @@ public function testCanAddMultipleMultipartFilesToTheRequest(): void } } - /** - * @covers ::setRequestMultipartFormParams - * @covers ::addMultipartPart - */ public function testCanAddMultipartFormDataParametersToTheRequest(): void { $this->mockHandler->append(new Response(200)); @@ -578,10 +552,6 @@ public function testCanAddMultipartFormDataParametersToTheRequest(): void $this->assertSame(sprintf('multipart/form-data; boundary=%s', $boundary), $request->getHeaderLine('Content-Type')); } - /** - * @covers ::setRequestFormParams - * @covers ::sendRequest - */ public function testCanSetFormParametersInTheRequest(): void { $this->mockHandler->append(new Response(200)); @@ -603,11 +573,7 @@ public function testCanSetFormParametersInTheRequest(): void $this->assertSame('foo=bar&bar%5B0%5D=foo&bar%5B1%5D=bar', (string) $request->getBody()); } - /** - * @dataProvider getHttpMethodsForFormParametersTest - * @covers ::setRequestFormParams - * @covers ::sendRequest - */ + #[DataProvider('getHttpMethodsForFormParametersTest')] public function testCanSetFormParametersInTheRequestWithCustomMethod(string $httpMethod): void { $this->mockHandler->append(new Response(200)); @@ -629,9 +595,6 @@ public function testCanSetFormParametersInTheRequestWithCustomMethod(string $htt $this->assertSame('foo=bar&bar%5B0%5D=foo&bar%5B1%5D=bar', (string) $request->getBody()); } - /** - * @covers ::sendRequest - */ public function testCanSetFormParametersAndAttachAFileInTheSameMultipartRequest(): void { $this->mockHandler->append(new Response(200)); @@ -685,9 +648,6 @@ public function testCanSetFormParametersAndAttachAFileInTheSameMultipartRequest( $this->assertStringContainsString($bar1, $contents); } - /** - * @covers ::addMultipartFileToRequest - */ public function testThrowsExceptionWhenAddingNonExistingFileAsMultipartPartToTheRequest(): void { $this->expectException(InvalidArgumentException::class); @@ -695,10 +655,6 @@ public function testThrowsExceptionWhenAddingNonExistingFileAsMultipartPartToThe $this->context->addMultipartFileToRequest('/foo/bar', 'foo'); } - /** - * @covers ::setRequestBodyToFileResource - * @covers ::setRequestBody - */ public function testCanSetRequestBodyToAFile(): void { $this->mockHandler->append(new Response()); @@ -711,10 +667,7 @@ public function testCanSetRequestBodyToAFile(): void $this->assertSame('text/x-php', $request->getHeaderLine('Content-Type')); } - /** - * @dataProvider getRequestBodyValues - * @covers ::setRequestBody - */ + #[DataProvider('getRequestBodyValues')] public function testCanSetRequestBodyToAString(string|PyStringNode $data, string $expected): void { $this->mockHandler->append(new Response()); @@ -726,11 +679,7 @@ public function testCanSetRequestBodyToAString(string|PyStringNode $data, string $this->assertSame($expected, (string) $request->getBody()); } - /** - * @dataProvider getUris - * @covers ::initializeClient - * @covers ::setRequestPath - */ + #[DataProvider('getUris')] public function testResolvesFilePathsCorrectlyWhenAttachingFilesToTheRequestBody(string $baseUri, string $path, string $fullUri): void { // Set a new client with the given base_uri (and not the one used in setUp()) @@ -748,10 +697,6 @@ public function testResolvesFilePathsCorrectlyWhenAttachingFilesToTheRequestBody $this->assertSame($fullUri, (string) $request->getUri()); } - /** - * @covers ::addJwtToken - * @covers ::jsonDecode - */ public function testCanAddJwtTokensToTheJwtMatcher(): void { $name = 'some name'; @@ -778,9 +723,6 @@ public function testCanAddJwtTokensToTheJwtMatcher(): void ); } - /** - * @covers ::addJwtToken - */ public function testThrowsExceptionWhenTryingToAddJwtTokenWhenThereIsNoMatcherFunctionRegistered(): void { $this->comparator @@ -795,13 +737,7 @@ public function testThrowsExceptionWhenTryingToAddJwtTokenWhenThereIsNoMatcherFu $this->context->addJwtToken('name', 'secret', new PyStringNode(['{"some":"data"}'], 1)); } - /** - * @dataProvider getHttpMethods - * @covers ::requestPath - * @covers ::setRequestPath - * @covers ::setRequestMethod - * @covers ::sendRequest - */ + #[DataProvider('getHttpMethods')] public function testCanMakeRequestsUsingDifferentHttpMethods(string $method): void { $this->mockHandler->append(new Response(200)); @@ -811,13 +747,6 @@ public function testCanMakeRequestsUsingDifferentHttpMethods(string $method): vo $this->assertSame($method, $this->historyContainer[0]['request']->getMethod()); } - /** - * @covers ::requestPath - * @covers ::setRequestMethod - * @covers ::setRequestPath - * @covers ::setRequestBody - * @covers ::sendRequest - */ public function testCanMakeRequestsWithQueryStringInThePath(): void { $this->mockHandler->append(new Response(200)); @@ -833,10 +762,6 @@ public function testCanMakeRequestsWithQueryStringInThePath(): void $this->assertSame('foo=bar&bar=foo&a%5B%5D=1&a%5B%5D=2', $request->getUri()->getQuery()); } - /** - * @covers ::setQueryStringParameter - * @covers ::setQueryStringParameters - */ public function testCanSetQueryStringParameters(): void { $this->mockHandler->append(new Response(200)); @@ -875,11 +800,7 @@ public function testCanSetQueryStringParameters(): void $this->assertSame('p1%5B0%5D=v6&p1%5B1%5D=v7&p2%5B0%5D=v8&p3=v9&p4=v5&p5=v10', $request->getUri()->getQuery()); } - /** - * @dataProvider getResponseCodes - * @covers ::assertResponseCodeIs - * @covers ::validateResponseCode - */ + #[DataProvider('getResponseCodes')] public function testCanAssertWhatTheResponseCodeIs(int $code): void { $this->mockHandler->append(new Response($code)); @@ -887,10 +808,6 @@ public function testCanAssertWhatTheResponseCodeIs(int $code): void $this->assertTrue($this->context->assertResponseCodeIs($code)); } - /** - * @covers ::assertResponseCodeIsNot - * @covers ::validateResponseCode - */ public function testCanAssertWhatTheResponseCodeIsNot(): void { $this->mockHandler->append(new Response(200)); @@ -899,12 +816,9 @@ public function testCanAssertWhatTheResponseCodeIsNot(): void } /** - * @dataProvider getGroupAndResponseCodes - * @covers ::assertResponseIs - * @covers ::requireResponse - * @covers ::getResponseCodeGroupRange * @param array $codes */ + #[DataProvider('getGroupAndResponseCodes')] public function testCanAssertWhichGroupTheResponseIsIn(string $group, array $codes): void { foreach ($codes as $code) { @@ -915,11 +829,9 @@ public function testCanAssertWhichGroupTheResponseIsIn(string $group, array $cod } /** - * @dataProvider getGroupAndResponseCodes - * @covers ::assertResponseIsNot - * @covers ::assertResponseIs * @param array $codes */ + #[DataProvider('getGroupAndResponseCodes')] public function testCanAssertWhichGroupTheResponseIsNotIn(string $group, array $codes): void { $groups = [ @@ -941,10 +853,7 @@ public function testCanAssertWhichGroupTheResponseIsNotIn(string $group, array $ } } - /** - * @dataProvider getResponseCodesAndReasonPhrases - * @covers ::assertResponseReasonPhraseIs - */ + #[DataProvider('getResponseCodesAndReasonPhrases')] public function testCanAssertWhatTheResponseReasonPhraseIs(int $code, string $phrase): void { $this->mockHandler->append(new Response($code, [], null, '1.1', $phrase)); @@ -952,9 +861,6 @@ public function testCanAssertWhatTheResponseReasonPhraseIs(int $code, string $ph $this->assertTrue($this->context->assertResponseReasonPhraseIs($phrase)); } - /** - * @covers ::assertResponseReasonPhraseIsNot - */ public function testCanAssertWhatTheResponseReasonPhraseIsNot(): void { $this->mockHandler->append(new Response()); @@ -962,9 +868,6 @@ public function testCanAssertWhatTheResponseReasonPhraseIsNot(): void $this->assertTrue($this->context->assertResponseReasonPhraseIsNot('Not Modified')); } - /** - * @covers ::assertResponseReasonPhraseMatches - */ public function testCanAssertThatTheResponseReasonPhraseMatchesAnExpression(): void { $this->mockHandler->append(new Response(200)); @@ -972,10 +875,7 @@ public function testCanAssertThatTheResponseReasonPhraseMatchesAnExpression(): v $this->assertTrue($this->context->assertResponseReasonPhraseMatches('/OK/')); } - /** - * @dataProvider getResponseCodesAndReasonPhrases - * @covers ::assertResponseStatusLineIs - */ + #[DataProvider('getResponseCodesAndReasonPhrases')] public function testCanAssertWhatTheResponseStatusLineIs(int $code, string $phrase): void { $this->mockHandler->append(new Response($code, [], null, '1.1', $phrase)); @@ -983,9 +883,6 @@ public function testCanAssertWhatTheResponseStatusLineIs(int $code, string $phra $this->assertTrue($this->context->assertResponseStatusLineIs(sprintf('%d %s', $code, $phrase))); } - /** - * @covers ::assertResponseStatusLineIsNot - */ public function testCanAssertWhatTheResponseStatusLineIsNot(): void { $this->mockHandler->append(new Response()); @@ -993,9 +890,6 @@ public function testCanAssertWhatTheResponseStatusLineIsNot(): void $this->assertTrue($this->context->assertResponseStatusLineIsNot('304 Not Modified')); } - /** - * @covers ::assertResponseStatusLineMatches - */ public function testCanAssertThatTheResponseStatusLineMatchesAnExpression(): void { $this->mockHandler->append(new Response(200)); @@ -1003,9 +897,6 @@ public function testCanAssertThatTheResponseStatusLineMatchesAnExpression(): voi $this->assertTrue($this->context->assertResponseStatusLineMatches('/200 OK/')); } - /** - * @covers ::assertResponseHeaderExists - */ public function testCanAssertThatAResponseHeaderExists(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => 'application/json'])); @@ -1013,9 +904,6 @@ public function testCanAssertThatAResponseHeaderExists(): void $this->assertTrue($this->context->assertResponseHeaderExists('Content-Type')); } - /** - * @covers ::assertResponseHeaderDoesNotExist - */ public function testCanAssertThatAResponseHeaderDoesNotExist(): void { $this->mockHandler->append(new Response(200)); @@ -1023,9 +911,6 @@ public function testCanAssertThatAResponseHeaderDoesNotExist(): void $this->assertTrue($this->context->assertResponseHeaderDoesNotExist('Content-Type')); } - /** - * @covers ::assertResponseHeaderIs - */ public function testCanAssertWhatAResponseHeaderIs(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => 'application/json'])); @@ -1033,9 +918,6 @@ public function testCanAssertWhatAResponseHeaderIs(): void $this->assertTrue($this->context->assertResponseHeaderIs('Content-Type', 'application/json')); } - /** - * @covers ::assertResponseHeaderIsNot - */ public function testCanAssertWhatAResponseHeaderIsNot(): void { $this->mockHandler->append(new Response(200, ['Content-Length' => '123'])); @@ -1043,9 +925,6 @@ public function testCanAssertWhatAResponseHeaderIsNot(): void $this->assertTrue($this->context->assertResponseHeaderIsNot('Content-Type', '456')); } - /** - * @covers ::assertResponseHeaderMatches - */ public function testCanAssertThatAResponseHeaderMatchesAnExpression(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => 'application/json'])); @@ -1053,9 +932,6 @@ public function testCanAssertThatAResponseHeaderMatchesAnExpression(): void $this->assertTrue($this->context->assertResponseHeaderMatches('Content-Type', '#^application/(json|xml)$#')); } - /** - * @covers ::assertResponseBodyIs - */ public function testCanAssertWhatTheResponseBodyIs(): void { $this->mockHandler->append(new Response(200, [], 'response body')); @@ -1063,9 +939,6 @@ public function testCanAssertWhatTheResponseBodyIs(): void $this->assertTrue($this->context->assertResponseBodyIs(new PyStringNode(['response body'], 1))); } - /** - * @covers ::assertResponseBodyIsNot - */ public function testCanAssertWhatTheResponseBodyIsNot(): void { $this->mockHandler->append(new Response(200, [], 'response body')); @@ -1073,9 +946,6 @@ public function testCanAssertWhatTheResponseBodyIsNot(): void $this->assertTrue($this->context->assertResponseBodyIsNot(new PyStringNode(['some other response body'], 1))); } - /** - * @covers ::assertResponseBodyMatches - */ public function testCanAssertThatTheResponseBodyMatchesAnExpression(): void { $this->mockHandler->append(new Response(200, [], '{"foo":"bar"}')); @@ -1083,11 +953,6 @@ public function testCanAssertThatTheResponseBodyMatchesAnExpression(): void $this->assertTrue($this->context->assertResponseBodyMatches(new PyStringNode(['/^{"FOO": ?"BAR"}$/i'], 1))); } - /** - * @covers ::assertResponseBodyIsAnEmptyJsonArray - * @covers ::getResponseBodyArray - * @covers ::getResponseBody - */ public function testCanAssertThatTheResponseIsAnEmptyArray(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode([]))); @@ -1095,9 +960,6 @@ public function testCanAssertThatTheResponseIsAnEmptyArray(): void $this->assertTrue($this->context->assertResponseBodyIsAnEmptyJsonArray()); } - /** - * @covers ::assertResponseBodyIsAnEmptyJsonObject - */ public function testCanAssertThatTheResponseIsAnEmptyObject(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode(new stdClass()))); @@ -1105,9 +967,6 @@ public function testCanAssertThatTheResponseIsAnEmptyObject(): void $this->assertTrue($this->context->assertResponseBodyIsAnEmptyJsonObject()); } - /** - * @covers ::assertResponseBodyIsEmpty - */ public function testCanAssertThatTheResponseBodyIsEmpty(): void { $this->mockHandler->append(new Response(204)); @@ -1115,9 +974,6 @@ public function testCanAssertThatTheResponseBodyIsEmpty(): void $this->assertTrue($this->context->assertResponseBodyIsEmpty()); } - /** - * @covers ::assertResponseBodyIsEmpty - */ public function testCanAssertThatTheResponseBodyIsEmptyCanFail(): void { $this->mockHandler->append(new Response(200, [], 'some content')); @@ -1127,9 +983,6 @@ public function testCanAssertThatTheResponseBodyIsEmptyCanFail(): void $this->assertTrue($this->context->assertResponseBodyIsEmpty()); } - /** - * @covers ::assertResponseBodyIsEmpty - */ public function testAssertThatTheResponseBodyIsEmptyThrowsExceptionOnMissingResponse(): void { $this->expectException(RuntimeException::class); @@ -1138,11 +991,9 @@ public function testAssertThatTheResponseBodyIsEmptyThrowsExceptionOnMissingResp } /** - * @dataProvider getResponseBodyArrays - * @covers ::assertResponseBodyJsonArrayLength - * @covers ::getResponseBodyArray * @param array $body */ + #[DataProvider('getResponseBodyArrays')] public function testCanAssertThatTheArrayInTheResponseBodyHasACertainLength(array $body, int $lengthToUse, bool $willFail): void { $this->mockHandler->append(new Response(200, [], (string) json_encode($body))); @@ -1162,11 +1013,9 @@ public function testCanAssertThatTheArrayInTheResponseBodyHasACertainLength(arra } /** - * @dataProvider getResponseBodyArraysForAtLeast - * @covers ::assertResponseBodyJsonArrayMinLength - * @covers ::getResponseBody * @param array $body */ + #[DataProvider('getResponseBodyArraysForAtLeast')] public function testCanAssertTheMinLengthOfAnArrayInTheResponseBody(array $body, int $min): void { $this->mockHandler->append(new Response(200, [], (string) json_encode($body))); @@ -1175,11 +1024,9 @@ public function testCanAssertTheMinLengthOfAnArrayInTheResponseBody(array $body, } /** - * @dataProvider getResponseBodyArraysForAtMost - * @covers ::assertResponseBodyJsonArrayMaxLength - * @covers ::getResponseBody * @param array $body */ + #[DataProvider('getResponseBodyArraysForAtMost')] public function testCanAssertTheMaxLengthOfAnArrayInTheResponseBody(array $body, int $max): void { $this->mockHandler->append(new Response(200, [], (string) json_encode($body))); @@ -1187,12 +1034,6 @@ public function testCanAssertTheMaxLengthOfAnArrayInTheResponseBody(array $body, $this->assertTrue($this->context->assertResponseBodyJsonArrayMaxLength($max)); } - /** - * @covers ::setArrayContainsComparator - * @covers ::assertResponseBodyContainsJson - * @covers ::getResponseBody - * @covers ::jsonDecode - */ public function testCanAssertThatTheResponseBodyContainsJson(): void { $this->mockHandler->append(new Response(200, [], '{"foo":"bar","bar":"foo"}')); @@ -1208,7 +1049,6 @@ public function testCanAssertThatTheResponseBodyContainsJson(): void /** * @see https://github.com/imbo/behat-api-extension/issues/7 - * @covers ::setRequestBody */ public function testThrowsExceptionWhenTryingToCombineARequestBodyWithMultipartOrFormData(): void { @@ -1219,9 +1059,6 @@ public function testThrowsExceptionWhenTryingToCombineARequestBodyWithMultipartO $this->context->setRequestBody('some body'); } - /** - * @covers ::setRequestBodyToFileResource - */ public function testThrowsExceptionWhenAttachingANonExistingFileToTheRequestBody(): void { $this->mockHandler->append(new Response()); @@ -1230,9 +1067,6 @@ public function testThrowsExceptionWhenAttachingANonExistingFileToTheRequestBody $this->context->setRequestBodyToFileResource('/foo/bar'); } - /** - * @covers ::setRequestBodyToFileResource - */ public function testThrowsExceptionWhenAttachingANonReadableFileToTheRequestBody(): void { $this->mockHandler->append(new Response()); @@ -1241,9 +1075,6 @@ public function testThrowsExceptionWhenAttachingANonReadableFileToTheRequestBody $this->context->setRequestBodyToFileResource('/non/readable/file'); } - /** - * @covers ::sendRequest - */ public function testThrowsExceptionWhenTheRequestCanNotBeSent(): void { $this->mockHandler->append(new RequestException('error', new Request('GET', 'path'))); @@ -1252,9 +1083,6 @@ public function testThrowsExceptionWhenTheRequestCanNotBeSent(): void $this->context->requestPath('path'); } - /** - * @covers ::assertResponseCodeIs - */ public function testAssertingWhatTheResponseCodeIsCanFail(): void { $this->mockHandler->append(new Response(200)); @@ -1264,11 +1092,7 @@ public function testAssertingWhatTheResponseCodeIsCanFail(): void $this->context->assertResponseCodeIs(400); } - /** - * @dataProvider getInvalidHttpResponseCodes - * @covers ::assertResponseCodeIs - * @covers ::validateResponseCode - */ + #[DataProvider('getInvalidHttpResponseCodes')] public function testThrowsExceptionWhenSpecifyingAnInvalidCodeWhenAssertingWhatTheResponseCodeIs(int $code): void { $this->mockHandler->append(new Response(200)); @@ -1280,10 +1104,6 @@ public function testThrowsExceptionWhenSpecifyingAnInvalidCodeWhenAssertingWhatT $this->context->assertResponseCodeIs($code); } - /** - * @covers ::assertResponseCodeIs - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseCodeIsWhenNoResponseExists(): void { $this->expectException(RuntimeException::class); @@ -1291,9 +1111,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseCodeIsWhenNoRespo $this->context->assertResponseCodeIs(200); } - /** - * @covers ::assertResponseCodeIsNot - */ public function testAssertingWhatTheResponseCodeIsNotCanFail(): void { $this->mockHandler->append(new Response(200)); @@ -1303,11 +1120,7 @@ public function testAssertingWhatTheResponseCodeIsNotCanFail(): void $this->context->assertResponseCodeIsNot(200); } - /** - * @dataProvider getInvalidHttpResponseCodes - * @covers ::assertResponseCodeIsNot - * @covers ::validateResponseCode - */ + #[DataProvider('getInvalidHttpResponseCodes')] public function testThrowsExceptionWhenSpecifyingAnInvalidCodeWhenAssertingWhatTheResponseCodeIsNot(int $code): void { $this->mockHandler->append(new Response(200)); @@ -1319,10 +1132,6 @@ public function testThrowsExceptionWhenSpecifyingAnInvalidCodeWhenAssertingWhatT $this->context->assertResponseCodeIsNot($code); } - /** - * @covers ::assertResponseCodeIsNot - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseCodeIsNotWhenNoResponseExists(): void { $this->expectException(RuntimeException::class); @@ -1330,12 +1139,7 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseCodeIsNotWhenNoRe $this->context->assertResponseCodeIsNot(200); } - /** - * @dataProvider getDataForResponseGroupFailures - * @covers ::assertResponseIs - * @covers ::getResponseCodeGroupRange - * @covers ::getResponseGroup - */ + #[DataProvider('getDataForResponseGroupFailures')] public function testAssertingThatTheResponseIsInAGroupCanFail(int $responseCode, string $actualGroup, string $expectedGroup): void { $this->mockHandler->append(new Response($responseCode)); @@ -1351,10 +1155,6 @@ public function testAssertingThatTheResponseIsInAGroupCanFail(int $responseCode, $this->context->assertResponseIs($expectedGroup); } - /** - * @covers ::assertResponseIs - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhichGroupTheResponseIsInWhenNoResponseExists(): void { $this->expectException(RuntimeException::class); @@ -1362,10 +1162,6 @@ public function testThrowsExceptionWhenAssertingWhichGroupTheResponseIsInWhenNoR $this->context->assertResponseIs('success'); } - /** - * @covers ::assertResponseIs - * @covers ::getResponseCodeGroupRange - */ public function testThrowsExceptionWhenAssertingThatTheResponseIsInAnInvalidGroup(): void { $this->mockHandler->append(new Response(200)); @@ -1375,10 +1171,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseIsInAnInvalidGrou $this->context->assertResponseIs('foobar'); } - /** - * @covers ::assertResponseIsNot - * @covers ::assertResponseIs - */ public function testAssertingThatTheResponseIsNotInAGroupCanFail(): void { $this->mockHandler->append(new Response(200)); @@ -1388,10 +1180,6 @@ public function testAssertingThatTheResponseIsNotInAGroupCanFail(): void $this->context->assertResponseIsNot('success'); } - /** - * @covers ::assertResponseIsNot - * @covers ::getResponseCodeGroupRange - */ public function testThrowsExceptionWhenAssertingThatTheResponseIsNotInAnInvalidGroup(): void { $this->mockHandler->append(new Response(200)); @@ -1401,10 +1189,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseIsNotInAnInvalidG $this->context->assertResponseIsNot('foobar'); } - /** - * @covers ::assertResponseIsNot - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhichGroupTheResponseIsNotInWhenNoResponseExists(): void { $this->expectException(RuntimeException::class); @@ -1412,9 +1196,6 @@ public function testThrowsExceptionWhenAssertingWhichGroupTheResponseIsNotInWhen $this->context->assertResponseIsNot('success'); } - /** - * @covers ::assertResponseReasonPhraseIs - */ public function testAssertingWhatTheResponseReasonPhraseIsCanFail(): void { $this->mockHandler->append(new Response()); @@ -1424,10 +1205,6 @@ public function testAssertingWhatTheResponseReasonPhraseIsCanFail(): void $this->context->assertResponseReasonPhraseIs('ok'); } - /** - * @covers ::assertResponseReasonPhraseIs - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseReasonPhraseIsWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1435,9 +1212,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseReasonPhraseIsWhe $this->context->assertResponseReasonPhraseIs('OK'); } - /** - * @covers ::assertResponseReasonPhraseIsNot - */ public function testAssertingWhatTheResponseReasonPhraseIsNotCanFail(): void { $this->mockHandler->append(new Response()); @@ -1447,10 +1221,6 @@ public function testAssertingWhatTheResponseReasonPhraseIsNotCanFail(): void $this->context->assertResponseReasonPhraseIsNot('OK'); } - /** - * @covers ::assertResponseReasonPhraseIsNot - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseReasonPhraseIsNotWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1458,9 +1228,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseReasonPhraseIsNot $this->context->assertResponseReasonPhraseIsNot('OK'); } - /** - * @covers ::assertResponseReasonPhraseMatches - */ public function testAssertingThatTheResponseReasonPhraseMatchesAnExpressionCanFail(): void { $this->mockHandler->append(new Response(200)); @@ -1470,10 +1237,6 @@ public function testAssertingThatTheResponseReasonPhraseMatchesAnExpressionCanFa $this->context->assertResponseReasonPhraseMatches('/ok/'); } - /** - * @covers ::assertResponseReasonPhraseMatches - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatTheResponseReasonPhraseMatchesAnExpressionWhenThereIsNoResponse(): void { $this->expectException(RuntimeException::class); @@ -1481,9 +1244,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseReasonPhraseMatch $this->context->assertResponseReasonPhraseMatches('/ok/'); } - /** - * @covers ::assertResponseStatusLineIs - */ public function testAssertingWhatTheResponseStatusLineIsCanFail(): void { $this->mockHandler->append(new Response()); @@ -1493,10 +1253,6 @@ public function testAssertingWhatTheResponseStatusLineIsCanFail(): void $this->context->assertResponseStatusLineIs('200 Foobar'); } - /** - * @covers ::assertResponseStatusLineIs - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseStatusLineIsWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1504,9 +1260,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseStatusLineIsWhenN $this->context->assertResponseStatusLineIs('200 OK'); } - /** - * @covers ::assertResponseStatusLineIsNot - */ public function testAssertingWhatTheResponseStatusLineIsNotCanFail(): void { $this->mockHandler->append(new Response()); @@ -1516,10 +1269,6 @@ public function testAssertingWhatTheResponseStatusLineIsNotCanFail(): void $this->context->assertResponseStatusLineIsNot('200 OK'); } - /** - * @covers ::assertResponseStatusLineIsNot - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseStatusLineIsNotWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1527,9 +1276,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseStatusLineIsNotWh $this->context->assertResponseStatusLineIsNot('200 OK'); } - /** - * @covers ::assertResponseStatusLineMatches - */ public function testAssertingThatTheResponseStatusLineMatchesAnExpressionCanFail(): void { $this->mockHandler->append(new Response(200)); @@ -1539,10 +1285,6 @@ public function testAssertingThatTheResponseStatusLineMatchesAnExpressionCanFail $this->context->assertResponseStatusLineMatches('/200 ok/'); } - /** - * @covers ::assertResponseStatusLineMatches - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatTheResponseStatusLineMatchesAnExpressionWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1550,9 +1292,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseStatusLineMatches $this->context->assertResponseStatusLineMatches('/200 OK/'); } - /** - * @covers ::assertResponseHeaderExists - */ public function testAssertingThatAResponseHeaderExistsCanFail(): void { $this->mockHandler->append(new Response(200)); @@ -1562,10 +1301,6 @@ public function testAssertingThatAResponseHeaderExistsCanFail(): void $this->context->assertResponseHeaderExists('Content-Type'); } - /** - * @covers ::assertResponseHeaderExists - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatAResponseHeaderExistWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1573,9 +1308,6 @@ public function testThrowsExceptionWhenAssertingThatAResponseHeaderExistWhenNoRe $this->context->assertResponseHeaderExists('Connection'); } - /** - * @covers ::assertResponseHeaderDoesNotExist - */ public function testAssertingThatAResponseHeaderDoesNotExistCanFail(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => 'application/json'])); @@ -1585,10 +1317,6 @@ public function testAssertingThatAResponseHeaderDoesNotExistCanFail(): void $this->context->assertResponseHeaderDoesNotExist('Content-Type'); } - /** - * @covers ::assertResponseHeaderDoesNotExist - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatAResponseHeaderDoesNotExistWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1596,9 +1324,6 @@ public function testThrowsExceptionWhenAssertingThatAResponseHeaderDoesNotExistW $this->context->assertResponseHeaderDoesNotExist('Connection'); } - /** - * @covers ::assertResponseHeaderIs - */ public function testAssertingWhatAResponseHeaderIsCanFail(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => 'application/json'])); @@ -1608,10 +1333,6 @@ public function testAssertingWhatAResponseHeaderIsCanFail(): void $this->context->assertResponseHeaderIs('Content-Type', 'application/xml'); } - /** - * @covers ::assertResponseHeaderIs - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatAResponseHeaderIsWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1619,9 +1340,6 @@ public function testThrowsExceptionWhenAssertingWhatAResponseHeaderIsWhenNoRespo $this->context->assertResponseHeaderIs('Connection', 'close'); } - /** - * @covers ::assertResponseHeaderIsNot - */ public function testAssertingWhatAResponseHeaderIsNotCanFail(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => '123'])); @@ -1631,10 +1349,6 @@ public function testAssertingWhatAResponseHeaderIsNotCanFail(): void $this->context->assertResponseHeaderIsNot('content-type', '123'); } - /** - * @covers ::assertResponseHeaderIsNot - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatAResponseHeaderIsNotWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1642,9 +1356,6 @@ public function testThrowsExceptionWhenAssertingWhatAResponseHeaderIsNotWhenNoRe $this->context->assertResponseHeaderIsNot('header', 'value'); } - /** - * @covers ::assertResponseHeaderMatches - */ public function testAssertingThatAResponseHeaderMatchesAnExpressionCanFail(): void { $this->mockHandler->append(new Response(200, ['Content-Type' => 'application/json'])); @@ -1654,10 +1365,6 @@ public function testAssertingThatAResponseHeaderMatchesAnExpressionCanFail(): vo $this->context->assertResponseHeaderMatches('Content-Type', '#^application/xml$#'); } - /** - * @covers ::assertResponseHeaderMatches - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatAResponseHeaderMatchesAnExpressionWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1665,9 +1372,6 @@ public function testThrowsExceptionWhenAssertingThatAResponseHeaderMatchesAnExpr $this->context->assertResponseHeaderMatches('Connection', 'close'); } - /** - * @covers ::assertResponseBodyIs - */ public function testAssertingWhatTheResponseBodyIsCanFail(): void { $this->mockHandler->append(new Response(200, [], 'response body')); @@ -1677,10 +1381,6 @@ public function testAssertingWhatTheResponseBodyIsCanFail(): void $this->context->assertResponseBodyIs(new PyStringNode(['foo'], 1)); } - /** - * @covers ::assertResponseBodyIs - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseBodyIsWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1688,9 +1388,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseBodyIsWhenNoRespo $this->context->assertResponseBodyIs(new PyStringNode(['some body'], 1)); } - /** - * @covers ::assertResponseBodyIsNot - */ public function testAssertingWhatTheResponseBodyIsNotCanFail(): void { $this->mockHandler->append(new Response(200, [], 'response body')); @@ -1700,10 +1397,6 @@ public function testAssertingWhatTheResponseBodyIsNotCanFail(): void $this->context->assertResponseBodyIsNot(new PyStringNode(['response body'], 1)); } - /** - * @covers ::assertResponseBodyIsNot - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingWhatTheResponseBodyIsNotWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1711,9 +1404,6 @@ public function testThrowsExceptionWhenAssertingWhatTheResponseBodyIsNotWhenNoRe $this->context->assertResponseBodyIsNot(new PyStringNode(['some body'], 1)); } - /** - * @covers ::assertResponseBodyMatches - */ public function testAssertingThatTheResponseBodyMatchesAnExpressionCanFail(): void { $this->mockHandler->append(new Response(200, [], '{"foo":"bar"}')); @@ -1723,10 +1413,6 @@ public function testAssertingThatTheResponseBodyMatchesAnExpressionCanFail(): vo $this->context->assertResponseBodyMatches(new PyStringNode(['/^{"FOO": "BAR"}$/'], 1)); } - /** - * @covers ::assertResponseBodyMatches - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatTheResponseBodyMatchesAnExpressionWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1734,11 +1420,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseBodyMatchesAnExpr $this->context->assertResponseBodyMatches(new PyStringNode(['/foo/'], 1)); } - /** - * @covers ::assertResponseBodyIsAnEmptyJsonArray - * @covers ::getResponseBodyArray - * @covers ::getResponseBody - */ public function testAssertingThatTheResponseIsAnEmptyArrayCanFail(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode([1, 2, 3]))); @@ -1748,11 +1429,6 @@ public function testAssertingThatTheResponseIsAnEmptyArrayCanFail(): void $this->context->assertResponseBodyIsAnEmptyJsonArray(); } - /** - * @covers ::assertResponseBodyIsAnEmptyJsonArray - * @covers ::getResponseBodyArray - * @covers ::getResponseBody - */ public function testThrowsExceptionWhenAssertingThatTheResponseBodyIsAnEmptyArrayWhenTheBodyDoesNotContainAnArray(): void { $this->mockHandler->append(new Response(200, [], '123')); @@ -1762,9 +1438,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseBodyIsAnEmptyArra $this->context->assertResponseBodyIsAnEmptyJsonArray(); } - /** - * @covers ::assertResponseBodyIsAnEmptyJsonObject - */ public function testAssertingThatTheResponseIsAnEmptyObjectCanFail(): void { $object = new stdClass(); @@ -1776,10 +1449,6 @@ public function testAssertingThatTheResponseIsAnEmptyObjectCanFail(): void $this->context->assertResponseBodyIsAnEmptyJsonObject(); } - /** - * @covers ::assertResponseBodyIsAnEmptyJsonObject - * @covers ::getResponseBody - */ public function testThrowsExceptionWhenAssertingThatTheResponseBodyIsAnEmptyObjectWhenTheBodyDoesNotContainAnObject(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode([]))); @@ -1789,11 +1458,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseBodyIsAnEmptyObje $this->context->assertResponseBodyIsAnEmptyJsonObject(); } - /** - * @covers ::assertResponseBodyJsonArrayLength - * @covers ::getResponseBodyArray - * @covers ::getResponseBody - */ public function testAssertingThatTheResponseBodyIsAJsonArrayWithACertainLengthCanFail(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode([1, 2, 3]))); @@ -1803,10 +1467,6 @@ public function testAssertingThatTheResponseBodyIsAJsonArrayWithACertainLengthCa $this->context->assertResponseBodyJsonArrayLength(2); } - /** - * @covers ::assertResponseBodyJsonArrayLength - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingTheLengthOfAJsonArrayInTheResponseBodyWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1814,10 +1474,6 @@ public function testThrowsExceptionWhenAssertingTheLengthOfAJsonArrayInTheRespon $this->context->assertResponseBodyJsonArrayLength(5); } - /** - * @covers ::assertResponseBodyJsonArrayLength - * @covers ::getResponseBodyArray - */ public function testThrowsExceptionWhenAssertingTheLengthOfAJsonArrayInTheResponseBodyAndTheBodyDoesNotContainAnArray(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode(['foo' => 'bar']))); @@ -1827,10 +1483,6 @@ public function testThrowsExceptionWhenAssertingTheLengthOfAJsonArrayInTheRespon $this->context->assertResponseBodyJsonArrayLength(0); } - /** - * @covers ::assertResponseBodyJsonArrayMinLength - * @covers ::getResponseBody - */ public function testAssertingThatTheResponseBodyContainsAJsonArrayWithAMinimumLengthCanFail(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode([1, 2, 3]))); @@ -1840,10 +1492,6 @@ public function testAssertingThatTheResponseBodyContainsAJsonArrayWithAMinimumLe $this->context->assertResponseBodyJsonArrayMinLength(4); } - /** - * @covers ::assertResponseBodyJsonArrayMinLength - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingTheMinimumLengthOfAnArrayInTheResponseBodyWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1851,10 +1499,6 @@ public function testThrowsExceptionWhenAssertingTheMinimumLengthOfAnArrayInTheRe $this->context->assertResponseBodyJsonArrayMinLength(5); } - /** - * @covers ::assertResponseBodyJsonArrayMinLength - * @covers ::getResponseBody - */ public function testThrowsExceptionWhenAssertingTheMinimumLengthOfAnArrayInTheResponseBodyAndTheBodyDoesNotContainAnArray(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode(['foo' => 'bar']))); @@ -1864,10 +1508,6 @@ public function testThrowsExceptionWhenAssertingTheMinimumLengthOfAnArrayInTheRe $this->context->assertResponseBodyJsonArrayMinLength(2); } - /** - * @covers ::assertResponseBodyJsonArrayMaxLength - * @covers ::getResponseBody - */ public function testAssertingThatTheResponseBodyContainsAJsonArrayWithAMaximumLengthCanFail(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode([1, 2, 3]))); @@ -1877,10 +1517,6 @@ public function testAssertingThatTheResponseBodyContainsAJsonArrayWithAMaximumLe $this->context->assertResponseBodyJsonArrayMaxLength(2); } - /** - * @covers ::assertResponseBodyJsonArrayMaxLength - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingTheMaximumLengthOfAnArrayInTheResponseBodyWhenNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1888,10 +1524,6 @@ public function testThrowsExceptionWhenAssertingTheMaximumLengthOfAnArrayInTheRe $this->context->assertResponseBodyJsonArrayMaxLength(5); } - /** - * @covers ::assertResponseBodyJsonArrayMaxLength - * @covers ::getResponseBody - */ public function testThrowsExceptionWhenAssertingTheMaximumLengthOfAnArrayInTheResponseBodyAndTheBodyDoesNotContainAnArray(): void { $this->mockHandler->append(new Response(200, [], (string) json_encode(['foo' => 'bar']))); @@ -1901,10 +1533,6 @@ public function testThrowsExceptionWhenAssertingTheMaximumLengthOfAnArrayInTheRe $this->context->assertResponseBodyJsonArrayMaxLength(2); } - /** - * @covers ::assertResponseBodyContainsJson - * @covers ::getResponseBody - */ public function testAssertingThatTheResponseBodyContainsJsonCanFail(): void { $this->mockHandler->append(new Response(200, [], '{"foo":"bar"}')); @@ -1920,11 +1548,6 @@ public function testAssertingThatTheResponseBodyContainsJsonCanFail(): void $this->context->assertResponseBodyContainsJson(new PyStringNode(['{"bar":"foo"}'], 1)); } - /** - * @covers ::setArrayContainsComparator - * @covers ::assertResponseBodyContainsJson - * @covers ::getResponseBody - */ public function testWillThrowExceptionWhenArrayContainsComparatorDoesNotReturnInACorrectMannerWhenCheckingTheResponseBodyForJson(): void { $this->mockHandler->append(new Response(200, [], '{"foo":"bar"}')); @@ -1940,10 +1563,6 @@ public function testWillThrowExceptionWhenArrayContainsComparatorDoesNotReturnIn $this->context->assertResponseBodyContainsJson(new PyStringNode(['{"bar":"foo"}'], 1)); } - /** - * @covers ::assertResponseBodyContainsJson - * @covers ::requireResponse - */ public function testThrowsExceptionWhenAssertingThatTheResponseContainsJsonAndNoResponseExist(): void { $this->expectException(RuntimeException::class); @@ -1951,10 +1570,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseContainsJsonAndNo $this->context->assertResponseBodyContainsJson(new PyStringNode(['{"foo":"bar"}'], 1)); } - /** - * @covers ::assertResponseBodyContainsJson - * @covers ::getResponseBody - */ public function testThrowsExceptionWhenAssertingThatTheResponseContainsJsonAndTheResponseContainsInvalidData(): void { $this->mockHandler->append(new Response(200, [], "{'foo':'bar'}")); @@ -1964,10 +1579,6 @@ public function testThrowsExceptionWhenAssertingThatTheResponseContainsJsonAndTh $this->context->assertResponseBodyContainsJson(new PyStringNode(['{"foo":"bar"}'], 1)); } - /** - * @covers ::assertResponseBodyContainsJson - * @covers ::jsonDecode - */ public function testThrowsExceptionWhenAssertingThatTheBodyContainsJsonAndTheParameterFromTheTestIsInvalid(): void { $this->mockHandler->append(new Response(200, [], '{"foo":"bar"}')); @@ -1978,8 +1589,6 @@ public function testThrowsExceptionWhenAssertingThatTheBodyContainsJsonAndThePar } /** - * @covers ::requestPath - * @covers ::setRequestMethod * @see https://github.com/imbo/behat-api-extension/issues/51 */ public function testUsesHttpGetByDefaultWhenRequesting(): void diff --git a/tests/Context/Initializer/ApiClientAwareInitializerTest.php b/tests/Context/Initializer/ApiClientAwareInitializerTest.php index 09f0e35..26a7ccf 100644 --- a/tests/Context/Initializer/ApiClientAwareInitializerTest.php +++ b/tests/Context/Initializer/ApiClientAwareInitializerTest.php @@ -2,18 +2,13 @@ namespace Imbo\BehatApiExtension\Context\Initializer; use Imbo\BehatApiExtension\Context\ApiClientAwareContext; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -/** - * @coversDefaultClass Imbo\BehatApiExtension\Context\Initializer\ApiClientAwareInitializer - */ +#[CoversClass(ApiClientAwareInitializer::class)] class ApiClientAwareInitializerTest extends TestCase { - /** - * @covers ::initializeContext - * @covers ::__construct - */ public function testInjectsClientWhenInitializingContext(): void { // Set up a socket for the test case, try all ports between 8000 and 8079. If no ports are diff --git a/tests/Context/Initializer/ArrayContainsComparatorAwareInitializerTest.php b/tests/Context/Initializer/ArrayContainsComparatorAwareInitializerTest.php index 10084c1..3ee80e0 100644 --- a/tests/Context/Initializer/ArrayContainsComparatorAwareInitializerTest.php +++ b/tests/Context/Initializer/ArrayContainsComparatorAwareInitializerTest.php @@ -4,17 +4,13 @@ use Imbo\BehatApiExtension\ArrayContainsComparator; use Imbo\BehatApiExtension\ArrayContainsComparator\Matcher; use Imbo\BehatApiExtension\Context\ArrayContainsComparatorAwareContext; +use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -/** - * @coversDefaultClass Imbo\BehatApiExtension\Context\Initializer\ArrayContainsComparatorAwareInitializer - */ +#[CoversClass(ArrayContainsComparatorAwareInitializer::class)] class ArrayContainsComparatorAwareInitializerTest extends TestCase { - /** - * @covers ::__construct - */ public function testInitializerInjectsDefaultMatcherFunctions(): void { /** @var ArrayContainsComparator&MockObject */ @@ -40,9 +36,6 @@ public function testInitializerInjectsDefaultMatcherFunctions(): void new ArrayContainsComparatorAwareInitializer($comparator); } - /** - * @covers ::initializeContext - */ public function testInjectsComparatorWhenInitializingContext(): void { /** @var ArrayContainsComparator&MockObject */ diff --git a/tests/Exception/ArrayContainsComparatorExceptionTest.php b/tests/Exception/ArrayContainsComparatorExceptionTest.php index 94e492f..908109c 100644 --- a/tests/Exception/ArrayContainsComparatorExceptionTest.php +++ b/tests/Exception/ArrayContainsComparatorExceptionTest.php @@ -1,11 +1,11 @@ expectException(ArrayContainsComparatorException::class); diff --git a/tests/ServiceContainer/BehatApiExtensionTest.php b/tests/ServiceContainer/BehatApiExtensionTest.php index 70ee69e..aef7a2a 100644 --- a/tests/ServiceContainer/BehatApiExtensionTest.php +++ b/tests/ServiceContainer/BehatApiExtensionTest.php @@ -1,14 +1,13 @@ extension = new BehatApiExtension(); } - /** - * @covers ::getConfigKey - * @covers ::configure - */ public function testCanBuildConfiguration(): void { /** @var ArrayNodeDefinition */ @@ -40,9 +35,6 @@ public function testCanBuildConfiguration(): void ], $config); } - /** - * @covers ::configure - */ public function testCanOverrideDefaultValuesWhenBuildingConfiguration(): void { /** @var ArrayNodeDefinition */