Skip to content

UtilityMethodTestCase: safeguard against duplicate test markers - #642

Merged
jrfnl merged 2 commits into
developfrom
feature/utilitymethodtestcase-add-safeguard-against-duplicate-markers
Jan 23, 2025
Merged

jrfnl merged 2 commits into
developfrom
feature/utilitymethodtestcase-add-safeguard-against-duplicate-markers

Conversation

@jrfnl

@jrfnl jrfnl commented Dec 22, 2024

Copy link
Copy Markdown
Member

GetMethodParametersTest: sync with upstream

See PR PHPCSStandards/PHP_CodeSniffer#777

UtilityMethodTestCase: safeguard against duplicate test markers

Sister-PR to upstream PHPCSStandards/PHP_CodeSniffer#777 addressing issue PHPCSStandards/PHP_CodeSniffer#773.

This commit adds a testTestMarkersAreUnique() test method to the UtilityMethodTestCase class to automatically verify that the case file in use by the child test class only contains unique test markers.

The actual logic for the test is in a custom, static, assertion assertTestMarkersAreUnique() to allow for calling the assertion directly if an additional test case file is tokenized for the test.

Includes unit tests.
Includes updating a few tests related to the UtilityMethodTestCase itself to not run the testTestMarkersAreUnique() test when the test is testing an error condition/doesn't have a valid $phpcsFile property set.

See PR PHPCSStandards/PHP_CodeSniffer 777
Sister-PR to upstream PHPCSStandards/PHP_CodeSniffer 777 addressing issue PHPCSStandards/PHP_CodeSniffer 773.

This commit adds a `testTestMarkersAreUnique()` test method to the `UtilityMethodTestCase` class to automatically verify that the case file in use by the child test class only contains unique test markers.

The actual logic for the test is in a custom, `static`, assertion `assertTestMarkersAreUnique()` to allow for calling the assertion directly if an additional test case file is tokenized for the test.

Includes unit tests.
Includes updating a few tests related to the `UtilityMethodTestCase` itself to not run the `testTestMarkersAreUnique()` test when the test is testing an error condition/doesn't have a valid `$phpcsFile` property set.
@jrfnl
jrfnl force-pushed the feature/utilitymethodtestcase-add-safeguard-against-duplicate-markers branch from 5839b47 to 41d251c Compare January 23, 2025 22:24
@jrfnl
jrfnl merged commit 1526642 into develop Jan 23, 2025
@jrfnl
jrfnl deleted the feature/utilitymethodtestcase-add-safeguard-against-duplicate-markers branch January 23, 2025 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant