1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00
psalm/tests/IssueSuppressionTest.php
Radosław Kowalewski 15c1a82d8c Few fixes to make tests pass on windows
* changed / to DIRECTORY_SEPARATOR in expected messages
* cahnged most occurences PHP_EOL to "\n" in tests and src
* added output buffering in test to avoid marking test as risky
2018-04-12 22:41:13 -04:00

86 lines
2.6 KiB
PHP

<?php
namespace Psalm\Tests;
class IssueSuppressionTest extends TestCase
{
use Traits\FileCheckerValidCodeParseTestTrait;
use Traits\FileCheckerInvalidCodeParseTestTrait;
/**
* @return array
*/
public function providerFileCheckerValidCodeParse()
{
return [
'undefinedClass' => [
'<?php
class A {
/**
* @psalm-suppress UndefinedClass
* @psalm-suppress MixedMethodCall
* @psalm-suppress MissingReturnType
*/
public function b() {
B::fooFoo()->barBar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis();
}
}',
],
'undefinedClassOneLine' => [
'<?php
class A {
public function b(): void {
/**
* @psalm-suppress UndefinedClass
*/
new B();
}
}',
],
'undefinedClassOneLineInFile' => [
'<?php
/**
* @psalm-suppress UndefinedClass
*/
new B();',
],
'excludeIssue' => [
'<?php
fooFoo();',
'assertions' => [],
'error_levels' => ['UndefinedFunction'],
],
];
}
/**
* @return array
*/
public function providerFileCheckerInvalidCodeParse()
{
return [
'undefinedClassOneLineWithLineAfter' => [
'<?php
class A {
public function b() {
/**
* @psalm-suppress UndefinedClass
*/
new B();
new C();
}
}',
'error_message' => 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:8 - Class or interface C',
],
'undefinedClassOneLineInFileAfter' => [
'<?php
/**
* @psalm-suppress UndefinedClass
*/
new B();
new C();',
'error_message' => 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:6 - Class or interface C',
],
];
}
}