1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

added test

This commit is contained in:
Bruce Weirdan 2019-02-24 20:48:57 +02:00 committed by Matthew Brown
parent 24a71be425
commit 3f56f468dc

View File

@ -1,8 +1,10 @@
<?php
namespace Psalm\Tests;
use Psalm\Codebase;
use Psalm\Internal\Analyzer\FileAnalyzer;
use Psalm\Config;
use Psalm\Plugin\Hook\AfterCodebasePopulatedInterface;
use Psalm\Tests\Internal\Provider;
class ProjectAnalyzerTest extends TestCase
@ -121,6 +123,43 @@ class ProjectAnalyzerTest extends TestCase
);
}
/**
* @return void
*/
public function testAfterCodebasePopulatedIsInvoked()
{
$hook = new class implements AfterCodebasePopulatedInterface
{
/** @var bool */
public static $called = false;
/** @return void */
public static function afterCodebasePopulated(Codebase $codebase)
{
self::$called = true;
}
};
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
Config::loadFromXML(
(string)getcwd(),
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
</projectFiles>
</psalm>'
)
);
$this->project_analyzer->getCodebase()->config->after_codebase_populated[] = get_class($hook);
ob_start();
$this->project_analyzer->check('tests/DummyProject');
$output = ob_get_clean();
$this->assertTrue($hook::$called);
}
/**
* @return void
*/