Skip to content

Commit 5388880

Browse files
committed
test upper limit
1 parent 3e8f16e commit 5388880

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

src/Command/ErrorFormatter/TableErrorFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
final class TableErrorFormatter implements ErrorFormatter
3131
{
3232

33-
private const ERRORS_LIMIT = 1000;
33+
public const ERRORS_LIMIT = 1000;
3434
private const FORCE_SHOW_ALL_ERRORS = 'PHPSTAN_TABLE_ERROR_FORMATTER_FORCE_SHOW_ALL_ERRORS';
3535

3636
public function __construct(

tests/PHPStan/Command/ErrorFormatter/TableErrorFormatterTest.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -423,20 +423,25 @@ public static function dataErrorLimit(): iterable
423423
yield [
424424
'errorsBudget' => null,
425425
'usedLevel' => '8',
426-
'showAllErrors' => true,
427-
'expected' => ' ------ -------------------------------
428-
Line Foo.php (in context of trait)
429-
------ -------------------------------
430-
12 Test
431-
13 Test
432-
14 Test
433-
15 Test
434-
------ -------------------------------
426+
'showAllErrors' => false,
427+
'expected' => '
435428
429+
[ERROR] Found 1000+ errors
436430
437-
[ERROR] Found 4 errors
431+
',
432+
'generateErrorsCount' => TableErrorFormatter::ERRORS_LIMIT + 5,
433+
];
434+
435+
yield [
436+
'errorsBudget' => null,
437+
'usedLevel' => '8',
438+
'showAllErrors' => true,
439+
'expected' => '
440+
441+
[ERROR] Found 1005 errors
438442
439443
',
444+
'generateErrorsCount' => TableErrorFormatter::ERRORS_LIMIT + 5,
440445
];
441446
}
442447

@@ -446,6 +451,7 @@ public function testErrorLimit(
446451
string $usedLevel,
447452
bool $showAllErrors,
448453
string $expected,
454+
int $generateErrorsCount = 4,
449455
): void
450456
{
451457
putenv('COLUMNS=200');
@@ -464,10 +470,11 @@ public function testErrorLimit(
464470
$errorsBudget,
465471
);
466472
$errors = [];
467-
$errors[] = new Error('Test', 'Foo.php (in context of trait)', 12, filePath: 'Foo.php', traitFilePath: 'Bar.php');
468-
$errors[] = new Error('Test', 'Foo.php (in context of trait)', 13, filePath: 'Foo.php', traitFilePath: 'Bar.php');
469-
$errors[] = new Error('Test', 'Foo.php (in context of trait)', 14, filePath: 'Foo.php', traitFilePath: 'Bar.php');
470-
$errors[] = new Error('Test', 'Foo.php (in context of trait)', 15, filePath: 'Foo.php', traitFilePath: 'Bar.php');
473+
$line = 12;
474+
for ($i = 0; $i < $generateErrorsCount; $i++) {
475+
$errors[] = new Error('Test', 'Foo.php (in context of trait)', $line, filePath: 'Foo.php', traitFilePath: 'Bar.php');
476+
$line++;
477+
}
471478
$formatter->formatErrors(new AnalysisResult($errors, [], [], [], [], false, null, true, 0, false, []), $this->getOutput());
472479

473480
$this->assertStringContainsString($expected, $this->getOutputContent());

0 commit comments

Comments
 (0)