1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
psalm/tests/TestCase.php
2017-10-15 11:57:44 -04:00

73 lines
1.7 KiB
PHP

<?php
namespace Psalm\Tests;
use PHPUnit_Framework_TestCase;
use Psalm\Checker\FileChecker;
class TestCase extends PHPUnit_Framework_TestCase
{
/** @var \PhpParser\Parser */
protected static $parser;
/** @var TestConfig */
protected static $config;
/** @var string */
protected static $src_dir_path;
/** @var \Psalm\Checker\ProjectChecker */
protected $project_checker;
/** @var Provider\FakeFileProvider */
protected $file_provider;
/**
* @return void
*/
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
self::$src_dir_path = getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR;
}
/**
* @return void
*/
public function setUp()
{
parent::setUp();
FileChecker::clearCache();
$this->file_provider = new Provider\FakeFileProvider();
$this->project_checker = new \Psalm\Checker\ProjectChecker(
$this->file_provider,
new Provider\FakeParserCacheProvider()
);
$this->project_checker->setConfig(new TestConfig());
$this->project_checker->infer_types_from_usage = true;
}
/**
* @return void
*/
public function tearDown()
{
$this->project_checker->classlike_storage_provider->deleteAll();
$this->project_checker->file_storage_provider->deleteAll();
}
/**
* @param string $file_path
* @param string $contents
*
* @return void
*/
public function addFile($file_path, $contents)
{
$this->file_provider->registerFile($file_path, $contents);
$this->project_checker->queueFileForScanning($file_path);
}
}