|  | 
| 2 | 2 | 
 | 
| 3 | 3 | namespace PHPStan\Command\ErrorFormatter; | 
| 4 | 4 | 
 | 
|  | 5 | +use Nette\Utils\Json; | 
|  | 6 | +use PHPStan\Analyser\Error; | 
|  | 7 | +use PHPStan\Command\AnalysisResult; | 
| 5 | 8 | use PHPStan\Testing\ErrorFormatterTestCase; | 
| 6 | 9 | use function sprintf; | 
| 7 | 10 | 
 | 
| @@ -235,4 +238,26 @@ public function testFormatErrors( | 
| 235 | 238 | $this->assertJsonStringEqualsJsonString($expected, $this->getOutputContent(), sprintf('%s: JSON do not match', $message)); | 
| 236 | 239 | } | 
| 237 | 240 | 
 | 
|  | 241 | +public function dataFormatTip(): iterable | 
|  | 242 | +{ | 
|  | 243 | +yield ['tip', 'tip']; | 
|  | 244 | +yield ['<fg=cyan>%configurationFile%</>', '%configurationFile%']; | 
|  | 245 | +yield ['this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.', 'this check by setting treatPhpDocTypesAsCertain: false in your %configurationFile%.']; | 
|  | 246 | +} | 
|  | 247 | + | 
|  | 248 | +/** | 
|  | 249 | + * @dataProvider dataFormatTip | 
|  | 250 | + */ | 
|  | 251 | +public function testFormatTip(string $tip, string $expectedTip): void | 
|  | 252 | +{ | 
|  | 253 | +$formatter = new JsonErrorFormatter(false); | 
|  | 254 | +$formatter->formatErrors(new AnalysisResult([ | 
|  | 255 | +new Error('Foo', '/foo/bar.php', 1, true, null, null, $tip), | 
|  | 256 | +], [], [], [], [], false, null, true, 0), $this->getOutput()); | 
|  | 257 | + | 
|  | 258 | +$content = $this->getOutputContent(); | 
|  | 259 | +$json = Json::decode($content, Json::FORCE_ARRAY); | 
|  | 260 | +$this->assertSame($expectedTip, $json['files']['/foo/bar.php']['messages'][0]['tip']); | 
|  | 261 | +} | 
|  | 262 | + | 
| 238 | 263 | } | 
0 commit comments