Skip to content

Commit 3b047b3

Browse files
committed
revert removed global maximum duration for DefaultReporter
1 parent 22b7ce5 commit 3b047b3

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/Extension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public function __construct(array $options = [])
6969
$this->collector = new Collector\DefaultCollector();
7070
$this->reporter = new Reporter\DefaultReporter(
7171
new Formatter\DefaultDurationFormatter(),
72+
$maximumDuration,
7273
$maximumCount
7374
);
7475
}
@@ -276,6 +277,7 @@ public function __construct(array $options = [])
276277
$this->collector = new Collector\DefaultCollector();
277278
$this->reporter = new Reporter\DefaultReporter(
278279
new Formatter\DefaultDurationFormatter(),
280+
$maximumDuration,
279281
$maximumCount
280282
);
281283
}
@@ -429,6 +431,7 @@ public function bootstrap(
429431
$collector = new Collector\DefaultCollector();
430432
$reporter = new Reporter\DefaultReporter(
431433
new Formatter\DefaultDurationFormatter(),
434+
$maximumDuration,
432435
$maximumCount
433436
);
434437

src/Reporter/DefaultReporter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,23 @@ final class DefaultReporter implements Reporter
2828
*/
2929
private $durationFormatter;
3030

31+
/**
32+
* @var MaximumDuration
33+
*/
34+
private $maximumDuration;
35+
3136
/**
3237
* @var MaximumCount
3338
*/
3439
private $maximumCount;
3540

3641
public function __construct(
3742
Formatter\DurationFormatter $durationFormatter,
43+
MaximumDuration $maximumDuration,
3844
MaximumCount $maximumCount
3945
) {
4046
$this->durationFormatter = $durationFormatter;
47+
$this->maximumDuration = $maximumDuration;
4148
$this->maximumCount = $maximumCount;
4249
}
4350

test/Unit/Reporter/DefaultReporterTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function testReportReturnsEmptyStringWhenSlowTestListIsEmpty()
5252

5353
$reporter = new Reporter\DefaultReporter(
5454
new Formatter\DefaultDurationFormatter(),
55+
MaximumDuration::fromDuration(Duration::fromMilliseconds($faker->numberBetween(0))),
5556
MaximumCount::fromCount(Count::fromInt($faker->numberBetween(1)))
5657
);
5758

@@ -65,11 +66,13 @@ public function testReportReturnsEmptyStringWhenSlowTestListIsEmpty()
6566
*/
6667
public function testReportReturnsReportWhenSlowTestListHasFewerSlowTestsThanMaximumCount(
6768
string $expectedReport,
69+
MaximumDuration $maximumDuration,
6870
MaximumCount $maximumCount,
6971
SlowTestList $slowTestList
7072
) {
7173
$reporter = new Reporter\DefaultReporter(
7274
new Formatter\DefaultDurationFormatter(),
75+
$maximumDuration,
7376
$maximumCount
7477
);
7578

@@ -79,7 +82,7 @@ public function testReportReturnsReportWhenSlowTestListHasFewerSlowTestsThanMaxi
7982
}
8083

8184
/**
82-
* @return \Generator<string, array{0: string, 1: MaximumCount, 2: SlowTestList}>
85+
* @return \Generator<string, array{0: string, 1: MaximumDuration, 2: MaximumCount, 3: SlowTestList}>
8386
*/
8487
public static function provideExpectedReportMaximumCountAndSlowTestList(): iterable
8588
{
@@ -91,6 +94,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
9194
1. 00:00.300 (00:00.100) FooTest::test
9295
TXT
9396
,
97+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
9498
MaximumCount::fromCount(Count::fromInt(1)),
9599
SlowTestList::create(
96100
SlowTest::create(
@@ -109,6 +113,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
109113
2. 00:00.275 (00:00.100) BarTest::test
110114
TXT
111115
,
116+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
112117
MaximumCount::fromCount(Count::fromInt(2)),
113118
SlowTestList::create(
114119
SlowTest::create(
@@ -134,6 +139,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
134139
3. 00:00.250 (00:00.100) BazTest::test
135140
TXT
136141
,
142+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
137143
MaximumCount::fromCount(Count::fromInt(3)),
138144
SlowTestList::create(
139145
SlowTest::create(
@@ -165,6 +171,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
165171
3. 00:00.250 (00:00.100) BazTest::test
166172
TXT
167173
,
174+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
168175
MaximumCount::fromCount(Count::fromInt(3)),
169176
SlowTestList::create(
170177
SlowTest::create(
@@ -203,6 +210,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
203210
10. 00:00.110 (00:00.100) FredTest::test
204211
TXT
205212
,
213+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
206214
MaximumCount::fromCount(Count::fromInt(10)),
207215
SlowTestList::create(
208216
SlowTest::create(
@@ -276,6 +284,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
276284
There is 1 additional slow test that is not listed here.
277285
TXT
278286
,
287+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
279288
MaximumCount::fromCount(Count::fromInt(1)),
280289
SlowTestList::create(
281290
SlowTest::create(
@@ -301,6 +310,7 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
301310
There are 2 additional slow tests that are not listed here.
302311
TXT
303312
,
313+
MaximumDuration::fromDuration(Duration::fromMilliseconds(500)),
304314
MaximumCount::fromCount(Count::fromInt(1)),
305315
SlowTestList::create(
306316
SlowTest::create(
@@ -325,9 +335,10 @@ public static function provideExpectedReportMaximumCountAndSlowTestList(): itera
325335
],
326336
];
327337

328-
foreach ($values as $key => list($expected, $maximumCount, $slowTestList)) {
338+
foreach ($values as $key => list($expected, $maximumDuration, $maximumCount, $slowTestList)) {
329339
yield $key => [
330340
$expected,
341+
$maximumDuration,
331342
$maximumCount,
332343
$slowTestList,
333344
];

0 commit comments

Comments
 (0)