Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.x | Tests: add attributes for annotations #189

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Sep 6, 2024

PHPUnit 10 introduced attributes as replacements for docblock annotations.
PHPUnit 11 deprecates the use of docblock annotations in favour of attributes.

If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown.

However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the failOnDeprecation is set to true (which it is for this library as the builds should fail on deprecations in PHP), builds will also fail on deprecation notices from PHPUnit itself.

This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs.
For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3.

This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2.

As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch.

Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0.
Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.

Tests: add Covers* attributes

This commit adds the Covers* attributes in all the appropriate places.

The @covers annotations remain as code coverage also still needs to be measure on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Tests: add DataProvider attributes

This commit adds the DataProvider attributes in all the appropriate places.

The @dataProvider annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Tests: add Requires* attributes

This commit adds the Requires* attributes in all the appropriate places.

The @requires annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Tests: add Before/After[Class] attributes

This commit adds the Before/After* attributes in all the appropriate places.

The @before/after* annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

PHPUnit 10 introduced attributes as replacements for docblock annotations.
PHPUnit 11 deprecates the use of docblock annotations in favour of attributes.

If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown.

However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself.

This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs.
For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3.

This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2.

As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch.

This commit adds the `Covers*` attributes in all the appropriate places.

The `@covers` annotations remain as code coverage also still needs to be measure on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0.
Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
PHPUnit 10 introduced attributes as replacements for docblock annotations.
PHPUnit 11 deprecates the use of docblock annotations in favour of attributes.

If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown.

However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself.

This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs.
For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3.

This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2.

As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch.

This commit adds the `DataProvider` attributes in all the appropriate places.

The `@dataProvider` annotations remain as the tests also still need to run on  PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0.
Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
PHPUnit 10 introduced attributes as replacements for docblock annotations.
PHPUnit 11 deprecates the use of docblock annotations in favour of attributes.

If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown.

However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself.

This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs.
For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3.

This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2.

As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch.

This commit adds the `Requires*` attributes in all the appropriate places.

The `@requires` annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0.
Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
PHPUnit 10 introduced attributes as replacements for docblock annotations.
PHPUnit 11 deprecates the use of docblock annotations in favour of attributes.

If both an attribute as well as an annotation are found, no PHPUnit deprecation warning will be thrown.

However, between PHPUnit 10.0 and PHPUnit 11.3.2, if the `failOnDeprecation` is set to `true` (which it is for this library as the builds should fail on deprecations in PHP), builds will _also_ fail on deprecation notices from PHPUnit itself.

This behaviour was (finally) changed in PHPUnit 10.5.32 and 11.3.3 (released this week), but that's insufficient for our needs.
For this library running the tests on high/low PHPUnit on each PHP version is imperative. It is also not the job of this library to decide the target PHPUnit versions for the consumer projects, so we cannot raise the minimum PHPUnit 11 version to 11.3.3.

This means that without the attributes, the test runs for the package would fail on PHPUnit 11.0.0 - 11.3.2.

As these attributes are already available in PHPUnit 10, it makes sense then to add them for both the 2.x branch, as well as the (upcoming) 3.x branch.

This commit adds the `Before/After*` attributes in all the appropriate places.

The `@before/after*` annotations remain as the tests also still need to run on PHP 5.6 - 8.0 using PHPUnit 5.x - 9.x.
These can be removed once the codebase has a PHP 8.1/PHPUnit 10 minimum requirement.

Note: due to the syntax for attributes, these can be safely added as they are ignored as comments on PHP < 8.0.
Along the same line, if there is no "listener" for the attributes (PHP 8.0/PHPUnit 9.x), they are ignored by PHP as well.
@jrfnl jrfnl added this to the 2.x Next milestone Sep 6, 2024
@coveralls
Copy link

Coverage Status

coverage: 95.846% (+0.01%) from 95.833%
when pulling 5cecae1 on feature/2.x/add-attributes-for-annotations
into da0bf11 on 2.x.

Copy link
Collaborator

@hellofromtonya hellofromtonya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jrfnl Amazing work!

@hellofromtonya hellofromtonya merged commit eb2db84 into 2.x Sep 6, 2024
158 checks passed
@hellofromtonya hellofromtonya deleted the feature/2.x/add-attributes-for-annotations branch September 6, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants