Skip to content

Commit 43c8520

Browse files
committed
Tests/AcceptTest: use named data sets
With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblocks more specific.
1 parent 2e7518d commit 43c8520

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/Core/Filters/Filter/AcceptTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public static function initializeConfigAndRuleset()
4343
/**
4444
* Test filtering a file list for excluded paths.
4545
*
46-
* @param array $inputPaths List of file paths to be filtered.
47-
* @param array $expectedOutput Expected filtering result.
46+
* @param array<string> $inputPaths List of file paths to be filtered.
47+
* @param array<string> $expectedOutput Expected filtering result.
4848
*
4949
* @dataProvider dataExcludePatterns
5050
*
@@ -65,34 +65,34 @@ public function testExcludePatterns($inputPaths, $expectedOutput)
6565
*
6666
* @see testExcludePatterns
6767
*
68-
* @return array
68+
* @return array<string, array<string, array<string>>>
6969
*/
7070
public function dataExcludePatterns()
7171
{
7272
$testCases = [
7373
// Test top-level exclude patterns.
74-
[
75-
[
74+
'Non-sniff specific path based excludes from ruleset and command line are respected and don\'t filter out too much' => [
75+
'inputPaths' => [
7676
'/path/to/src/Main.php',
7777
'/path/to/src/Something/Main.php',
7878
'/path/to/src/Somethingelse/Main.php',
7979
'/path/to/src/SomethingelseEvenLonger/Main.php',
8080
'/path/to/src/Other/Main.php',
8181
],
82-
[
82+
'expectedOutput' => [
8383
'/path/to/src/Main.php',
8484
'/path/to/src/SomethingelseEvenLonger/Main.php',
8585
],
8686
],
8787

8888
// Test ignoring standard/sniff specific exclude patterns.
89-
[
90-
[
89+
'Filter should not act on standard/sniff specific exclude patterns' => [
90+
'inputPaths' => [
9191
'/path/to/src/generic-project/Main.php',
9292
'/path/to/src/generic/Main.php',
9393
'/path/to/src/anything-generic/Main.php',
9494
],
95-
[
95+
'expectedOutput' => [
9696
'/path/to/src/generic-project/Main.php',
9797
'/path/to/src/generic/Main.php',
9898
'/path/to/src/anything-generic/Main.php',

0 commit comments

Comments
 (0)