3939 private MetadataCollection $ metadata ;
4040 private TestDataCollection $ testData ;
4141
42+ /**
43+ * @var positive-int
44+ */
45+ private int $ repetition ;
46+
47+ /**
48+ * @var positive-int
49+ */
50+ private int $ totalRepetitions ;
51+
4252 /**
4353 * @param class-string $className
4454 * @param non-empty-string $methodName
4555 * @param non-empty-string $file
4656 * @param non-negative-int $line
57+ * @param positive-int $repetition
58+ * @param positive-int $totalRepetitions
4759 */
48- public function __construct (string $ className , string $ methodName , string $ file , int $ line , TestDox $ testDox , MetadataCollection $ metadata , TestDataCollection $ testData )
60+ public function __construct (string $ className , string $ methodName , string $ file , int $ line , TestDox $ testDox , MetadataCollection $ metadata , TestDataCollection $ testData, int $ repetition = 1 , int $ totalRepetitions = 1 )
4961 {
5062 parent ::__construct ($ file );
5163
52- $ this ->className = $ className ;
53- $ this ->methodName = $ methodName ;
54- $ this ->line = $ line ;
55- $ this ->testDox = $ testDox ;
56- $ this ->metadata = $ metadata ;
57- $ this ->testData = $ testData ;
64+ $ this ->className = $ className ;
65+ $ this ->methodName = $ methodName ;
66+ $ this ->line = $ line ;
67+ $ this ->testDox = $ testDox ;
68+ $ this ->metadata = $ metadata ;
69+ $ this ->testData = $ testData ;
70+ $ this ->repetition = $ repetition ;
71+ $ this ->totalRepetitions = $ totalRepetitions ;
5872 }
5973
6074 /**
@@ -96,6 +110,27 @@ public function testData(): TestDataCollection
96110 return $ this ->testData ;
97111 }
98112
113+ /**
114+ * @return positive-int
115+ */
116+ public function repetition (): int
117+ {
118+ return $ this ->repetition ;
119+ }
120+
121+ /**
122+ * @return positive-int
123+ */
124+ public function totalRepetitions (): int
125+ {
126+ return $ this ->totalRepetitions ;
127+ }
128+
129+ public function isRepeated (): bool
130+ {
131+ return $ this ->totalRepetitions > 1 ;
132+ }
133+
99134 public function isTestMethod (): true
100135 {
101136 return true ;
@@ -112,6 +147,14 @@ public function id(): string
112147 $ buffer .= '# ' . $ this ->testData ->dataFromDataProvider ()->dataSetName ();
113148 }
114149
150+ if ($ this ->totalRepetitions > 1 ) {
151+ $ buffer .= sprintf (
152+ ' (repetition %d of %d) ' ,
153+ $ this ->repetition ,
154+ $ this ->totalRepetitions ,
155+ );
156+ }
157+
115158 return $ buffer ;
116159 }
117160
@@ -128,24 +171,32 @@ public function nameWithClass(): string
128171 */
129172 public function name (): string
130173 {
131- if (!$ this ->testData ->hasDataFromDataProvider ()) {
132- return $ this ->methodName ;
174+ $ name = $ this ->methodName ;
175+
176+ if ($ this ->testData ->hasDataFromDataProvider ()) {
177+ $ dataSetName = $ this ->testData ->dataFromDataProvider ()->dataSetName ();
178+
179+ if (is_int ($ dataSetName )) {
180+ $ name .= sprintf (
181+ ' with data set #%d ' ,
182+ $ dataSetName ,
183+ );
184+ } else {
185+ $ name .= sprintf (
186+ ' with data set "%s" ' ,
187+ $ dataSetName ,
188+ );
189+ }
133190 }
134191
135- $ dataSetName = $ this ->testData ->dataFromDataProvider ()->dataSetName ();
136-
137- if (is_int ($ dataSetName )) {
138- $ dataSetName = sprintf (
139- ' with data set #%d ' ,
140- $ dataSetName ,
141- );
142- } else {
143- $ dataSetName = sprintf (
144- ' with data set "%s" ' ,
145- $ dataSetName ,
192+ if ($ this ->totalRepetitions > 1 ) {
193+ $ name .= sprintf (
194+ ' (repetition %d of %d) ' ,
195+ $ this ->repetition ,
196+ $ this ->totalRepetitions ,
146197 );
147198 }
148199
149- return $ this -> methodName . $ dataSetName ;
200+ return $ name ;
150201 }
151202}
0 commit comments