1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
psalm/tests/IssueSuppressionTest.php
2016-10-15 13:10:05 -04:00

55 lines
1.3 KiB
PHP

<?php
namespace Psalm\Tests;
use Psalm\Type;
use PhpParser;
use PhpParser\ParserFactory;
use PHPUnit_Framework_TestCase;
class IssueSuppressionTest extends PHPUnit_Framework_TestCase
{
protected static $_parser;
protected static $_file_filter;
public static function setUpBeforeClass()
{
self::$_parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
$config = \Psalm\Config::getInstance();
$config->throw_exception = true;
$filter = new \Psalm\Config\FileFilter();
$filter->addExcludeFile('somefile.php');
$filter->makeExclusive();
self::$_file_filter = $filter;
}
public function setUp()
{
\Psalm\Checker\FileChecker::clearCache();
\Psalm\Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
}
public function testUndefinedClass()
{
$stmts = self::$_parser->parse('<?php
class A{
/**
* @psalm-suppress UndefinedClass
* @psalm-suppress MixedMethodCall
*/
public function a() {
B::foo()->bar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis();
}
}
');
$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
$file_checker->check();
}
}