Skip to content

Commit d196b53

Browse files
committed
use parent identifier getAnalysisResult
1 parent b661e01 commit d196b53

File tree

2 files changed

+43
-22
lines changed

2 files changed

+43
-22
lines changed
Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
1-
---------------------------%s
1+
----------------------------------------------------------------------------------------------------------------
2+
/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:2
3+
----------------------------------------------------------------------------------------------------------------
4+
- '#Bar
5+
Bar2#'
6+
----------------------------------------------------------------------------------------------------------------
7+
8+
----------------------------------------------------------------------------------------------------------------
29
/data/folder/with space/and unicode 😃/project/folder with unicode 😃/file name with "spaces" and unicode 😃.php:4
3-
---------------------------%s
10+
----------------------------------------------------------------------------------------------------------------
411
- '#Foo#'
5-
🪪 identical.alwaysFalse
6-
---------------------------%s
12+
----------------------------------------------------------------------------------------------------------------
13+
14+
----------------------------------------------------------------------------------------------------------------
15+
/data/folder/with space/and unicode 😃/project/foo.php:
16+
----------------------------------------------------------------------------------------------------------------
17+
- '#Bar
18+
Bar2#'
19+
----------------------------------------------------------------------------------------------------------------
20+
21+
----------------------------------------------------------------------------------------------------------------
22+
/data/folder/with space/and unicode 😃/project/foo.php:1
23+
----------------------------------------------------------------------------------------------------------------
24+
- '#Foo<Bar>#'
25+
----------------------------------------------------------------------------------------------------------------
26+
27+
----------------------------------------------------------------------------------------------------------------
28+
/data/folder/with space/and unicode 😃/project/foo.php:5
29+
----------------------------------------------------------------------------------------------------------------
30+
- '#Bar
31+
Bar2#'
32+
----------------------------------------------------------------------------------------------------------------
33+
34+
----------------------------------------------------------------------------------------------------------------
35+
/data/folder/with space/and unicode 😃/project/foo.php:5
36+
----------------------------------------------------------------------------------------------------------------
37+
- '#Foobar\\Buz#'
38+
🪪 foobar.buz
39+
----------------------------------------------------------------------------------------------------------------
740

841

9-
[ERROR] Found 1 errors
42+
[ERROR] Found 6 errors
1043

tests/ErrorFormatter/SymplifyErrorFormatterVerboseTest.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
namespace Symplify\PHPStanExtensions\Tests\ErrorFormatter;
66

77
use Iterator;
8-
use PHPStan\Analyser\Error;
9-
use PHPStan\Command\AnalysisResult;
10-
use PHPStan\ShouldNotHappenException;
118
use PHPStan\Testing\ErrorFormatterTestCase;
129
use PHPUnit\Framework\Attributes\DataProvider;
1310
use Symplify\PHPStanExtensions\ErrorFormatter\SymplifyErrorFormatter;
@@ -20,9 +17,9 @@ final class SymplifyErrorFormatterVerboseTest extends ErrorFormatterTestCase
2017
#[DataProvider('provideData')]
2118
public function testFormatErrors(
2219
string $message,
23-
int $expectedExitCode,
24-
int $numFileErrors,
25-
int $numGenericErrors,
20+
int $expectedExitCode,
21+
int $numFileErrors,
22+
int $numGenericErrors,
2623
string $expectedOutputFile,
2724
): void {
2825
$symplifyErrorFormatter = self::getContainer()->getByType(SymplifyErrorFormatter::class);
@@ -33,15 +30,15 @@ public function testFormatErrors(
3330

3431
$this->assertSame($expectedExitCode, $resultCode);
3532

36-
$this->assertStringMatchesFormatFile($expectedOutputFile, $this->getOutputContent(verbose: true));
33+
$this->assertStringMatchesFormatFile($expectedOutputFile, str_replace("\r", "\r\n",$this->getOutputContent(verbose: true)));
3734
}
3835

3936
/**
4037
* @return Iterator<mixed>
4138
*/
4239
public static function provideData(): Iterator
4340
{
44-
yield ['Some message', 1, 1, 1, __DIR__ . '/Fixture/expected_single_message_many_files_report_verbose.txt'];
41+
yield ['Some message', 1, 6, 0, __DIR__ . '/Fixture/expected_single_message_many_files_report_verbose.txt'];
4542
}
4643

4744
/**
@@ -51,13 +48,4 @@ public static function getAdditionalConfigFiles(): array
5148
{
5249
return [__DIR__ . '/../../config/config.neon'];
5350
}
54-
55-
protected function getAnalysisResult($numFileErrors, int $numGenericErrors): AnalysisResult
56-
{
57-
// @phpstan-ignore phpstanApi.constructor
58-
$fileErrors = [new Error('Foo', self::DIRECTORY_PATH . '/folder with unicode 😃/file name with "spaces" and unicode 😃.php', 4, identifier: 'identical.alwaysFalse')];
59-
60-
// @phpstan-ignore phpstanApi.constructor
61-
return new AnalysisResult($fileErrors, [], [], [], [], \false, null, \true, 0, \false, []);
62-
}
6351
}

0 commit comments

Comments
 (0)