From 05d1ce6dcd4219ceebdb918ab2d64d90ddb564f4 Mon Sep 17 00:00:00 2001 From: Brown Date: Mon, 29 Oct 2018 11:41:02 -0400 Subject: [PATCH] Move plugin tests into new file --- tests/ConfigTest.php | 116 ------------------------------------------- tests/PluginTest.php | 96 +++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 116 deletions(-) create mode 100644 tests/PluginTest.php diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index e96f83dbc..c198e73d3 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -562,122 +562,6 @@ class ConfigTest extends TestCase $this->analyzeFile($file_path, new Context()); } - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage InvalidClass - * - * @return void - */ - public function testStringCheckerPlugin() - { - $this->project_checker = $this->getProjectCheckerWithConfig( - TestConfig::loadFromXML( - dirname(__DIR__) . DIRECTORY_SEPARATOR, - ' - - - - - - - - ' - ) - ); - - $this->project_checker->config->initializePlugins($this->project_checker); - - $file_path = getcwd() . '/src/somefile.php'; - - $this->addFile( - $file_path, - 'analyzeFile($file_path, new Context()); - } - - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage InvalidClass - * - * @return void - */ - public function testStringCheckerPluginWithClassConstant() - { - $this->project_checker = $this->getProjectCheckerWithConfig( - TestConfig::loadFromXML( - dirname(__DIR__) . DIRECTORY_SEPARATOR, - ' - - - - - - - - ' - ) - ); - - $this->project_checker->config->initializePlugins($this->project_checker); - - $file_path = getcwd() . '/src/somefile.php'; - - $this->addFile( - $file_path, - ' "Psalm\Checker\ProjectChecker", - ]; - }' - ); - - $this->analyzeFile($file_path, new Context()); - } - - /** - * @expectedException \Psalm\Exception\CodeException - * @expectedExceptionMessage UndefinedMethod - * - * @return void - */ - public function testStringCheckerPluginWithClassConstantConcat() - { - $this->project_checker = $this->getProjectCheckerWithConfig( - TestConfig::loadFromXML( - dirname(__DIR__) . DIRECTORY_SEPARATOR, - ' - - - - - - - - ' - ) - ); - - $this->project_checker->config->initializePlugins($this->project_checker); - - $file_path = getcwd() . '/src/somefile.php'; - - $this->addFile( - $file_path, - ' \Psalm\Checker\ProjectChecker::class . "::foo", - ]; - }' - ); - - $this->analyzeFile($file_path, new Context()); - } - /** * @return void */ diff --git a/tests/PluginTest.php b/tests/PluginTest.php new file mode 100644 index 000000000..2d44e8d17 --- /dev/null +++ b/tests/PluginTest.php @@ -0,0 +1,96 @@ +file_provider = new Provider\FakeFileProvider(); + } + + /** + * @param Config $config + * + * @return \Psalm\Checker\ProjectChecker + */ + private function getProjectCheckerWithConfig(Config $config) + { + return new \Psalm\Checker\ProjectChecker( + $config, + new \Psalm\Provider\Providers( + $this->file_provider, + new Provider\FakeParserCacheProvider() + ) + ); + } + + /** + * @expectedException \Psalm\Exception\CodeException + * @expectedExceptionMessage UndefinedMethod + * + * @return void + */ + public function testStringCheckerPluginWithClassConstantConcat() + { + $this->project_checker = $this->getProjectCheckerWithConfig( + TestConfig::loadFromXML( + dirname(__DIR__) . DIRECTORY_SEPARATOR, + ' + + + + + + + + ' + ) + ); + + $this->project_checker->config->initializePlugins($this->project_checker); + + $file_path = getcwd() . '/src/somefile.php'; + + $this->addFile( + $file_path, + ' \Psalm\Checker\ProjectChecker::class . "::foo", + ]; + }' + ); + + $this->analyzeFile($file_path, new Context()); + } +}