Skip to content

Commit 04fc61f

Browse files
staabmsebastianbergmann
authored andcommitted
Use "@<data-set-name>" --filter CLI option compatible error format
1 parent 6b01fc8 commit 04fc61f

14 files changed

+66
-65
lines changed

src/Framework/TestCase.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -854,24 +854,6 @@ final public function dataSetAsString(): string
854854
return '';
855855
}
856856

857-
/**
858-
* Returns the data set as a string compatible with the --filter CLI option.
859-
*
860-
* @internal This method is not covered by the backward compatibility promise for PHPUnit
861-
*/
862-
final public function dataSetAsFilterString(): string
863-
{
864-
if ($this->data !== []) {
865-
if (is_int($this->dataName)) {
866-
return sprintf('#%d', $this->dataName);
867-
}
868-
869-
return sprintf('%s', $this->dataName);
870-
}
871-
872-
return '';
873-
}
874-
875857
/**
876858
* @internal This method is not covered by the backward compatibility promise for PHPUnit
877859
*/
@@ -881,8 +863,9 @@ final public function dataSetAsStringWithData(): string
881863
return '';
882864
}
883865

884-
return $this->dataSetAsString() . sprintf(
885-
' (%s)',
866+
return sprintf(
867+
'%s with data (%s)',
868+
$this->dataSetAsFilterString(),
886869
Exporter::shortenedRecursiveExport($this->data),
887870
);
888871
}
@@ -1284,6 +1267,24 @@ protected function onNotSuccessfulTest(Throwable $t): never
12841267
throw $t;
12851268
}
12861269

1270+
/**
1271+
* Returns the data set as a string compatible with the --filter CLI option.
1272+
*
1273+
* @internal This method is not covered by the backward compatibility promise for PHPUnit
1274+
*/
1275+
private function dataSetAsFilterString(): string
1276+
{
1277+
if ($this->data !== []) {
1278+
if (is_int($this->dataName)) {
1279+
return sprintf('#%d', $this->dataName);
1280+
}
1281+
1282+
return sprintf('@%s', $this->dataName);
1283+
}
1284+
1285+
return '';
1286+
}
1287+
12871288
/**
12881289
* @throws AssertionFailedError
12891290
* @throws Exception

src/Runner/Filter/NameFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function prepareFilter(string $filter): array
109109
// * testDetermineJsonError@JSON.*
110110
elseif (preg_match('/^(.*?)@(.+)$/', $filter, $matches)) {
111111
$filter = sprintf(
112-
'%s.*with data set "%s"$',
112+
'%s.*with data set "@%s"$',
113113
$matches[1],
114114
$matches[2],
115115
);

tests/end-to-end/data-provider/dependency-result.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Time: %s, Memory: %s
1919

2020
There was 1 error:
2121

22-
1) PHPUnit\TestFixture\DataProviderDependencyResultTest::testAdd with data set #2 (2, 0)
22+
1) PHPUnit\TestFixture\DataProviderDependencyResultTest::testAdd#2 with data (2, 0)
2323
Error: Cannot use positional argument after named argument during unpacking
2424

2525
ERRORS!

tests/end-to-end/logging/teamcity/teamcity-data-provider.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Time: %s, Memory: %s
2929

3030
There was 1 failure:
3131

32-
1) PHPUnit\TestFixture\TeamCity\DataProviderTest::testOne with data set #1 (false)
32+
1) PHPUnit\TestFixture\TeamCity\DataProviderTest::testOne#1 with data (false)
3333
Failed asserting that false is true.
3434

3535
%sDataProviderTest.php:28

tests/end-to-end/regression/5616.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Time: %s, Memory: %s MB
1919

2020
There was 1 failure:
2121

22-
1) PHPUnit\TestFixture\Issue5616\Issue5616Test::testOne with data set #0 (1, '2', 3.0, true)
22+
1) PHPUnit\TestFixture\Issue5616\Issue5616Test::testOne#0 with data (1, '2', 3.0, true)
2323
Failed asserting that false is true.
2424

2525
%sIssue5616Test.php:%d

tests/end-to-end/regression/6222.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ Failed asserting that false is true.
2626

2727
%sIssue6222Test.php:%d
2828

29-
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing with data set #1 (2)
29+
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing#1 with data (2)
3030
Failed asserting that 2 is identical to 1.
3131

3232
%sIssue6222Test.php:%d
3333

34-
3) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing with data set #0 (1)
34+
3) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing#0 with data (1)
3535
Failed asserting that 1 is identical to 3.
3636

3737
%sIssue6222Test.php:%d
3838

39-
4) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing with data set #1 (2)
39+
4) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing#1 with data (2)
4040
Failed asserting that 2 is identical to 3.
4141

4242
%sIssue6222Test.php:%d

tests/end-to-end/testdox/data-provider-with-string-data-set-name.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Runtime: %s
2020
Time: %s, Memory: %s
2121

2222
Data Provider With String Data Set Name (PHPUnit\TestFixture\TestDox\DataProviderWithStringDataSetName)
23-
✔ Something that works with data set "data set name"
24-
✘ Something that does not work with data set "data set name"
23+
✔ Something that works with data set "@data set name"
24+
✘ Something that does not work with data set "@data set name"
2525
2626
│ Failed asserting that false is true.
2727

tests/end-to-end/testdox/formatter-method-does-not-exist.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Formatter Method Does Not Exist (PHPUnit\TestFixture\TestDox\FormatterMethodDoes
2424

2525
There was 1 PHPUnit error:
2626

27-
1) PHPUnit\TestFixture\TestDox\FormatterMethodDoesNotExistTest::testOne with data set #0 ('string')
27+
1) PHPUnit\TestFixture\TestDox\FormatterMethodDoesNotExistTest::testOne#0 with data ('string')
2828
Method PHPUnit\TestFixture\TestDox\FormatterMethodDoesNotExistTest::formatter() cannot be used as a TestDox formatter because it does not exist
2929

3030
%sFormatterMethodDoesNotExistTest.php:%d

tests/end-to-end/testdox/formatter-method-is-not-public.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Formatter Method Is Not Public (PHPUnit\TestFixture\TestDox\FormatterMethodIsNot
2424

2525
There was 1 PHPUnit error:
2626

27-
1) PHPUnit\TestFixture\TestDox\FormatterMethodIsNotPublicTest::testOne with data set #0 ('string')
27+
1) PHPUnit\TestFixture\TestDox\FormatterMethodIsNotPublicTest::testOne#0 with data ('string')
2828
Method PHPUnit\TestFixture\TestDox\FormatterMethodIsNotPublicTest::formatter() cannot be used as a TestDox formatter because it is not public
2929

3030
%sFormatterMethodIsNotPublicTest.php:%d

tests/end-to-end/testdox/formatter-method-is-not-static.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Formatter Method Is Not Static (PHPUnit\TestFixture\TestDox\FormatterMethodIsNot
2424

2525
There was 1 PHPUnit error:
2626

27-
1) PHPUnit\TestFixture\TestDox\FormatterMethodIsNotStaticTest::testOne with data set #0 ('string')
27+
1) PHPUnit\TestFixture\TestDox\FormatterMethodIsNotStaticTest::testOne#0 with data ('string')
2828
Method PHPUnit\TestFixture\TestDox\FormatterMethodIsNotStaticTest::formatter() cannot be used as a TestDox formatter because it is not static
2929

3030
%sFormatterMethodIsNotStaticTest.php:%d

0 commit comments

Comments
 (0)