Skip to content
Permalink
Browse files

Move test fixtures to a single directory

  • Loading branch information...
muglug committed May 9, 2019
1 parent 33d4888 commit d75ac7f55d3bd3cc8c145affd2f10cf42c314a3c
@@ -12,7 +12,7 @@

<!-- These are just examples and stub classes/files, so it doesn't really matter if they're PSR-2 compliant. -->
<exclude-pattern>src/Psalm/Internal/Stubs/</exclude-pattern>
<exclude-pattern>tests/stubs/</exclude-pattern>
<exclude-pattern>tests/fixtures/stubs/</exclude-pattern>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>tests</exclude-pattern>
</rule>
@@ -18,17 +18,13 @@
<directory name="examples"/>
<ignoreFiles>
<file name="src/Psalm/Internal/CallMap.php"/>
<directory name="src/Psalm/Internal/Stubs"/>
<directory name="tests/stubs"/>
<directory name="tests/DummyProject"/>
<file name="vendor/phpunit/phpunit/src/Framework/TestCase.php"/>
<file name="vendor/symfony/console/Command/Command.php"/>
<directory name="vendor/netresearch/jsonmapper" />
<file name="src/Psalm/Internal/Traverser/CustomTraverser.php"/>
<file name="vendor/felixfbecker/advanced-json-rpc/lib/Dispatcher.php" />
<file name="tests/performance/a.test"/>
<file name="tests/performance/b.test"/>
<file name="tests/ErrorBaselineTest.php"/>
<file name="vendor/symfony/console/Command/Command.php"/>
<directory name="src/Psalm/Internal/Stubs"/>
<directory name="tests/fixtures"/>
<file name="vendor/felixfbecker/advanced-json-rpc/lib/Dispatcher.php" />
<directory name="vendor/netresearch/jsonmapper" />
<directory name="vendor/phpunit" />
</ignoreFiles>
</projectFiles>
@@ -141,7 +141,7 @@ public function testIgnoreMissingProjectDirectory()
*/
public function testIgnoreSymlinkedProjectDirectory()
{
@unlink(__DIR__ . '/symlinktest/ignored/b');
@unlink(__DIR__ . '/fixtures/symlinktest/ignored/b');
$no_symlinking_error = 'symlink(): Cannot create symlink, error code(1314)';
$last_error = error_get_last();
@@ -150,7 +150,7 @@ public function testIgnoreSymlinkedProjectDirectory()
!isset($last_error['message']) ||
$no_symlinking_error !== $last_error['message'];
@symlink(__DIR__ . '/symlinktest/a', __DIR__ . '/symlinktest/ignored/b');
@symlink(__DIR__ . '/fixtures/symlinktest/a', __DIR__ . '/fixtures/symlinktest/ignored/b');
if ($check_symlink_error) {
$last_error = error_get_last();
@@ -170,7 +170,7 @@ public function testIgnoreSymlinkedProjectDirectory()
<projectFiles>
<directory name="tests" />
<ignoreFiles>
<directory name="tests/symlinktest/ignored" />
<directory name="tests/fixtures/symlinktest/ignored" />
</ignoreFiles>
</projectFiles>
</psalm>'
@@ -180,7 +180,7 @@ public function testIgnoreSymlinkedProjectDirectory()
$config = $this->project_analyzer->getConfig();
$this->assertTrue($config->isInProjectDirs(realpath('tests/AnnotationTest.php')));
$this->assertFalse($config->isInProjectDirs(realpath('tests/symlinktest/a/ignoreme.php')));
$this->assertFalse($config->isInProjectDirs(realpath('tests/fixtures/symlinktest/a/ignoreme.php')));
$this->assertFalse($config->isInProjectDirs(realpath('examples/StringAnalyzer.php')));
$regex = '/^unlink\([^\)]+\): (?:Permission denied|No such file or directory)$/';
@@ -190,7 +190,7 @@ public function testIgnoreSymlinkedProjectDirectory()
!is_array($last_error) ||
!preg_match($regex, $last_error['message']);
@unlink(__DIR__ . '/symlinktest/ignored/b');
@unlink(__DIR__ . '/fixtures/symlinktest/ignored/b');
if ($check_unlink_error) {
$last_error = error_get_last();
@@ -543,7 +543,7 @@ public function __construct() {
'files' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
function getEndpoints() : void {
$listFile = "tests/stubs/custom_functions.php";
$listFile = "tests/fixtures/stubs/custom_functions.php";
if (!file_exists($listFile)) {
throw new RuntimeException("Endpoint list not found");
}
@@ -449,7 +449,7 @@ public function testFloatCheckerPluginIssueSuppressionByDocblock()
/** @return void */
public function testInheritedHookHandlersAreCalled()
{
require_once __DIR__ . '/stubs/extending_plugin_entrypoint.php';
require_once __DIR__ . '/fixtures/stubs/extending_plugin_entrypoint.php';
$this->project_analyzer = $this->getProjectAnalyzerWithConfig(
TestConfig::loadFromXML(
@@ -754,7 +754,7 @@ public function testAfterAnalysisHooks()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
<plugins>
<pluginClass class="Psalm\\Test\\Plugin\\AfterAnalysisPlugin" />
@@ -767,7 +767,7 @@ public function testAfterAnalysisHooks()
$this->project_analyzer->output_format = \Psalm\Internal\Analyzer\ProjectAnalyzer::TYPE_JSON;
$this->project_analyzer->check('tests/DummyProject', true);
$this->project_analyzer->check('tests/fixtures/DummyProject', true);
\Psalm\IssueBuffer::finish($this->project_analyzer, true, microtime(true));
}
@@ -70,14 +70,14 @@ public function testCheck()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
);
ob_start();
$this->project_analyzer->check('tests/DummyProject');
$this->project_analyzer->check('tests/fixtures/DummyProject');
$output = ob_get_clean();
$this->assertSame('Scanning files...' . "\n" . 'Analyzing files...' . "\n", $output);
@@ -118,7 +118,7 @@ public static function afterCodebasePopulated(Codebase $codebase)
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
@@ -130,7 +130,7 @@ public static function afterCodebasePopulated(Codebase $codebase)
$this->project_analyzer->getCodebase()->config->after_codebase_populated[] = $hook_class;
ob_start();
$this->project_analyzer->check('tests/DummyProject');
$this->project_analyzer->check('tests/fixtures/DummyProject');
ob_end_clean();
$this->assertTrue($hook::$called);
@@ -147,15 +147,15 @@ public function testCheckAfterNoChange()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
);
$this->project_analyzer->output_format = \Psalm\Internal\Analyzer\ProjectAnalyzer::TYPE_JSON;
$this->project_analyzer->check('tests/DummyProject', true);
$this->project_analyzer->check('tests/fixtures/DummyProject', true);
\Psalm\IssueBuffer::finish($this->project_analyzer, true, microtime(true));
$this->assertSame(
@@ -167,7 +167,7 @@ public function testCheckAfterNoChange()
$this->project_analyzer->getCodebase()->reloadFiles($this->project_analyzer, []);
$this->project_analyzer->check('tests/DummyProject', true);
$this->project_analyzer->check('tests/fixtures/DummyProject', true);
$this->assertSame(0, \Psalm\IssueBuffer::getErrorCount());
@@ -190,15 +190,15 @@ public function testCheckAfterFileChange()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
);
$this->project_analyzer->output_format = \Psalm\Internal\Analyzer\ProjectAnalyzer::TYPE_JSON;
$this->project_analyzer->check('tests/DummyProject', true);
$this->project_analyzer->check('tests/fixtures/DummyProject', true);
\Psalm\IssueBuffer::finish($this->project_analyzer, true, microtime(true));
$this->assertSame(
@@ -208,7 +208,11 @@ public function testCheckAfterFileChange()
)
);
$bat_file_path = getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'DummyProject' . DIRECTORY_SEPARATOR . 'Bat.php';
$bat_file_path = getcwd()
. DIRECTORY_SEPARATOR . 'tests'
. DIRECTORY_SEPARATOR . 'fixtures'
. DIRECTORY_SEPARATOR . 'DummyProject'
. DIRECTORY_SEPARATOR . 'Bat.php';
$bat_replacement_contents = '<?php
@@ -227,7 +231,7 @@ public function __construct()
$this->project_analyzer->getCodebase()->reloadFiles($this->project_analyzer, []);
$this->project_analyzer->check('tests/DummyProject', true);
$this->project_analyzer->check('tests/fixtures/DummyProject', true);
$this->assertSame(0, \Psalm\IssueBuffer::getErrorCount());
@@ -250,14 +254,14 @@ public function testCheckDir()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
);
ob_start();
$this->project_analyzer->checkDir('tests/DummyProject');
$this->project_analyzer->checkDir('tests/fixtures/DummyProject');
$output = ob_get_clean();
$this->assertSame('Scanning files...' . "\n" . 'Analyzing files...' . "\n", $output);
@@ -283,14 +287,14 @@ public function testCheckPaths()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
);
ob_start();
$this->project_analyzer->checkPaths(['tests/DummyProject/Bar.php']);
$this->project_analyzer->checkPaths(['tests/fixtures/DummyProject/Bar.php']);
$output = ob_get_clean();
$this->assertSame('Scanning files...' . "\n" . 'Analyzing files...' . "\n", $output);
@@ -316,14 +320,14 @@ public function testCheckFile()
'<?xml version="1.0"?>
<psalm>
<projectFiles>
<directory name="tests/DummyProject" />
<directory name="tests/fixtures/DummyProject" />
</projectFiles>
</psalm>'
)
);
ob_start();
$this->project_analyzer->checkFile('tests/DummyProject/Bar.php');
$this->project_analyzer->checkFile('tests/fixtures/DummyProject/Bar.php');
$output = ob_get_clean();
$this->assertSame('Scanning files...' . "\n" . 'Analyzing files...' . "\n", $output);

0 comments on commit d75ac7f

Please sign in to comment.
You can’t perform that action at this time.