Skip to content

Commit 6b01fc8

Browse files
staabmsebastianbergmann
authored andcommitted
Refactor: extract dataSetAsFilterString
1 parent 5f7eccb commit 6b01fc8

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/Framework/TestCase.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,28 @@ final public function dataSetAsString(): string
845845
{
846846
if ($this->data !== []) {
847847
if (is_int($this->dataName)) {
848-
return sprintf(' with data set #%d', $this->dataName);
848+
return sprintf(' with data set %s', $this->dataSetAsFilterString());
849849
}
850850

851-
return sprintf(' with data set "%s"', $this->dataName);
851+
return sprintf(' with data set "%s"', $this->dataSetAsFilterString());
852+
}
853+
854+
return '';
855+
}
856+
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);
852870
}
853871

854872
return '';

0 commit comments

Comments
 (0)