From 3f56ce1003283f4a5fd97a6324d76cb5f060ed4a Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 23 Jun 2025 15:53:34 -0300 Subject: [PATCH 1/2] Add a note about using data providers to the CONTRIBUTING.md guide PHPCS convention is to define data providers below the test method and to name them using the "data" prefix. This commit is an attempt to document this convention in the CONTRIBUTING.md guide. --- .github/CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b30845046c..45976ea9ea 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -384,6 +384,7 @@ To run the tests specific to the use of `PHP_CODESNIFFER_CBF === true`: In such cases, the `PHP_CodeSniffer\Tests\Core\Config\AbstractRealConfigTestCase` should be used as the base test class. * Tests for the `Runner` class often can't create their own `Config` object in the tests, so run into the same issue. Those tests should use the `PHP_CodeSniffer\Tests\Core\Runner\AbstractRunnerTestCase` base class, which will ensure the Config is clean. +* When using data providers, define them immediately below the corresponding test method. The data provider's name should match the test method name, replacing the "test" prefix with "data". For example, the data provider for a method named `testSomething()` should be `dataSomething()`. ### Submitting Your Pull Request From ad9bcc093f079a08ea9d5b215b71d74e56f4d81a Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 24 Jun 2025 11:20:43 -0300 Subject: [PATCH 2/2] Update .github/CONTRIBUTING.md Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com> --- .github/CONTRIBUTING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 45976ea9ea..e9af9149ca 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -384,7 +384,8 @@ To run the tests specific to the use of `PHP_CODESNIFFER_CBF === true`: In such cases, the `PHP_CodeSniffer\Tests\Core\Config\AbstractRealConfigTestCase` should be used as the base test class. * Tests for the `Runner` class often can't create their own `Config` object in the tests, so run into the same issue. Those tests should use the `PHP_CodeSniffer\Tests\Core\Runner\AbstractRunnerTestCase` base class, which will ensure the Config is clean. -* When using data providers, define them immediately below the corresponding test method. The data provider's name should match the test method name, replacing the "test" prefix with "data". For example, the data provider for a method named `testSomething()` should be `dataSomething()`. +* When using data providers, define them immediately below the corresponding test method. +* When a test method has only one data provider, it is considered best practice to closely couple the test and data provider methods via their names. I.e. the data provider's name should match the test method name, replacing the "test" prefix with "data". For example, the data provider for a method named `testSomething()` should be `dataSomething()`. ### Submitting Your Pull Request