Implement #[WithoutErrorHandler] attribute to disable PHPUnit's error handler for a test method#5430
Merged
sebastianbergmann merged 3 commits intomainfrom Jun 27, 2023
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5430 +/- ##
============================================
+ Coverage 85.01% 85.02% +0.01%
- Complexity 6164 6169 +5
============================================
Files 653 654 +1
Lines 19634 19650 +16
============================================
+ Hits 16692 16708 +16
Misses 2942 2942
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
#[WithoutErrorHandler] attribute to disable PHPUnit's error handler for a test method
reviewtypo3org
pushed a commit
to TYPO3/typo3
that referenced
this pull request
Dec 28, 2023
PHPUnit has changed the behavior of the error handler in
several ways, for example introducing a PHP attribute to
disable the PHPUnit error handler for tests dealing with
`error_get_last()` [1], throwing an exception and stopping
the script execution on `E_*_ERROR` or clearing the error
result [2] - which breaks the ability to use the native
`error_get_last()` method to test custom error handler
implementation.
Something which TYPO3 needs to do for the provided custom
error handler.
An additional change [3] to check and restore error handlers
with levels has been reverted due to issues in the Laravel
world.
This change modifies the related test to use the introduced
PHP attribute `#[WithoutErrorHandler]` and raises PHPUnit.
Note: PHPUnit does not recognize the `@test` doc-block
annotation if the `#[WithoutErrorHandler]` attribute
is used. Therefore, the attribute counterparts for
`@test` and `@dataProvider` has been added on top
and not exclusively for now, albeit looking weird
and fishy. This needs to be addressed in a more
generic way in a dedicated change.
Used command(s):
> composer update typo3/testing-framework
> composer require --dev "phpunit/phpunit":"^10.5.5"
[1] sebastianbergmann/phpunit#5430
[2] sebastianbergmann/phpunit#5592
[3] sebastianbergmann/phpunit#5619
Resolves: #102724
Releases: main, 12.4
Change-Id: I77f750ef2eba53b5f8caa51651f36321ae5d1224
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82282
Tested-by: Oliver Klee <[email protected]>
Reviewed-by: Simon Schaufelberger <[email protected]>
Tested-by: core-ci <[email protected]>
Reviewed-by: Oliver Klee <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Simon Schaufelberger <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
reviewtypo3org
pushed a commit
to TYPO3/typo3
that referenced
this pull request
Dec 28, 2023
PHPUnit has changed the behavior of the error handler in
several ways, for example introducing a PHP attribute to
disable the PHPUnit error handler for tests dealing with
`error_get_last()` [1], throwing an exception and stopping
the script execution on `E_*_ERROR` or clearing the error
result [2] - which breaks the ability to use the native
`error_get_last()` method to test custom error handler
implementation.
Something which TYPO3 needs to do for the provided custom
error handler.
An additional change [3] to check and restore error handlers
with levels has been reverted due to issues in the Laravel
world.
This change modifies the related test to use the introduced
PHP attribute `#[WithoutErrorHandler]` and raises PHPUnit.
Note: PHPUnit does not recognize the `@test` doc-block
annotation if the `#[WithoutErrorHandler]` attribute
is used. Therefore, the attribute counterparts for
`@test` and `@dataProvider` has been added on top
and not exclusively for now, albeit looking weird
and fishy. This needs to be addressed in a more
generic way in a dedicated change.
Used command(s):
> composer require --dev \
"phpunit/phpunit":"^10.5.5" \
"typo3/testing-framework":"^8.0.8"
[1] sebastianbergmann/phpunit#5430
[2] sebastianbergmann/phpunit#5592
[3] sebastianbergmann/phpunit#5619
Resolves: #102724
Releases: main, 12.4
Change-Id: I77f750ef2eba53b5f8caa51651f36321ae5d1224
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82283
Reviewed-by: Oliver Klee <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Oliver Klee <[email protected]>
Tested-by: core-ci <[email protected]>
Tested-by: Simon Schaufelberger <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Reviewed-by: Simon Schaufelberger <[email protected]>
TYPO3IncTeam
pushed a commit
to TYPO3-CMS/core
that referenced
this pull request
Dec 28, 2023
PHPUnit has changed the behavior of the error handler in
several ways, for example introducing a PHP attribute to
disable the PHPUnit error handler for tests dealing with
`error_get_last()` [1], throwing an exception and stopping
the script execution on `E_*_ERROR` or clearing the error
result [2] - which breaks the ability to use the native
`error_get_last()` method to test custom error handler
implementation.
Something which TYPO3 needs to do for the provided custom
error handler.
An additional change [3] to check and restore error handlers
with levels has been reverted due to issues in the Laravel
world.
This change modifies the related test to use the introduced
PHP attribute `#[WithoutErrorHandler]` and raises PHPUnit.
Note: PHPUnit does not recognize the `@test` doc-block
annotation if the `#[WithoutErrorHandler]` attribute
is used. Therefore, the attribute counterparts for
`@test` and `@dataProvider` has been added on top
and not exclusively for now, albeit looking weird
and fishy. This needs to be addressed in a more
generic way in a dedicated change.
Used command(s):
> composer update typo3/testing-framework
> composer require --dev "phpunit/phpunit":"^10.5.5"
[1] sebastianbergmann/phpunit#5430
[2] sebastianbergmann/phpunit#5592
[3] sebastianbergmann/phpunit#5619
Resolves: #102724
Releases: main, 12.4
Change-Id: I77f750ef2eba53b5f8caa51651f36321ae5d1224
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82282
Tested-by: Oliver Klee <[email protected]>
Reviewed-by: Simon Schaufelberger <[email protected]>
Tested-by: core-ci <[email protected]>
Reviewed-by: Oliver Klee <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Simon Schaufelberger <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
TYPO3IncTeam
pushed a commit
to TYPO3-CMS/core
that referenced
this pull request
Dec 28, 2023
PHPUnit has changed the behavior of the error handler in
several ways, for example introducing a PHP attribute to
disable the PHPUnit error handler for tests dealing with
`error_get_last()` [1], throwing an exception and stopping
the script execution on `E_*_ERROR` or clearing the error
result [2] - which breaks the ability to use the native
`error_get_last()` method to test custom error handler
implementation.
Something which TYPO3 needs to do for the provided custom
error handler.
An additional change [3] to check and restore error handlers
with levels has been reverted due to issues in the Laravel
world.
This change modifies the related test to use the introduced
PHP attribute `#[WithoutErrorHandler]` and raises PHPUnit.
Note: PHPUnit does not recognize the `@test` doc-block
annotation if the `#[WithoutErrorHandler]` attribute
is used. Therefore, the attribute counterparts for
`@test` and `@dataProvider` has been added on top
and not exclusively for now, albeit looking weird
and fishy. This needs to be addressed in a more
generic way in a dedicated change.
Used command(s):
> composer require --dev \
"phpunit/phpunit":"^10.5.5" \
"typo3/testing-framework":"^8.0.8"
[1] sebastianbergmann/phpunit#5430
[2] sebastianbergmann/phpunit#5592
[3] sebastianbergmann/phpunit#5619
Resolves: #102724
Releases: main, 12.4
Change-Id: I77f750ef2eba53b5f8caa51651f36321ae5d1224
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82283
Reviewed-by: Oliver Klee <[email protected]>
Reviewed-by: Anja Leichsenring <[email protected]>
Tested-by: Oliver Klee <[email protected]>
Tested-by: core-ci <[email protected]>
Tested-by: Simon Schaufelberger <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Tested-by: Anja Leichsenring <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Reviewed-by: Simon Schaufelberger <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#[WithoutErrorHandler]attribute#[WithoutErrorHandler]attribute#[WithoutErrorHandler]attribute phpunit-documentation-english#317