1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
psalm/tests/IssueSuppressionTest.php

54 lines
1.3 KiB
PHP
Raw Normal View History

2016-07-25 00:02:15 +02:00
<?php
2016-07-26 00:37:44 +02:00
namespace Psalm\Tests;
2016-07-25 00:02:15 +02:00
2016-07-26 00:37:44 +02:00
use Psalm\Type;
2016-07-25 00:02:15 +02:00
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);
2016-07-26 00:37:44 +02:00
$config = \Psalm\Config::getInstance();
2016-07-25 00:02:15 +02:00
$config->throw_exception = true;
2016-07-26 00:37:44 +02:00
$filter = new \Psalm\Config\FileFilter();
2016-07-25 00:02:15 +02:00
$filter->addExcludeFile('somefile.php');
$filter->makeExclusive();
self::$_file_filter = $filter;
}
public function setUp()
{
2016-08-15 17:01:50 +02:00
\Psalm\Checker\FileChecker::clearCache();
2016-07-26 00:37:44 +02:00
\Psalm\Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
2016-07-25 00:02:15 +02:00
}
public function testUndefinedClass()
{
$stmts = self::$_parser->parse('<?php
class A{
/**
* @suppress UndefinedClass
*/
public function a() {
B::foo()->bar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis();
}
}
');
$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
2016-07-25 00:02:15 +02:00
$file_checker->check();
}
}