Skip to content

Commit

Permalink
Fix some more tests when running phpunit with args
Browse files Browse the repository at this point in the history
e.g:
./vendor/bin/phpunit --filter 'Psalm\\Tests\\VariadicTest'
  • Loading branch information
MoonE committed Nov 11, 2024
1 parent bfbd53c commit bc2d66c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
9 changes: 9 additions & 0 deletions tests/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@

class CacheTest extends TestCase
{
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

// hack to isolate Psalm from PHPUnit cli arguments
global $argv;
$argv = [];
}

public function setUp(): void
{
parent::setUp();
Expand Down
9 changes: 9 additions & 0 deletions tests/Config/ConfigFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ class ConfigFileTest extends TestCase
{
private string $file_path;

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

// hack to isolate Psalm from PHPUnit cli arguments
global $argv;
$argv = [];
}

public function setUp(): void
{
RuntimeCaches::clearAll();
Expand Down
8 changes: 4 additions & 4 deletions tests/Config/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class ConfigTest extends TestCase

public static function setUpBeforeClass(): void
{
// hack to isolate Psalm from PHPUnit cli arguments
global $argv;
$argv = [];

self::$config = new TestConfig();

if (!defined('PSALM_VERSION')) {
Expand Down Expand Up @@ -1334,10 +1338,6 @@ function handleThrow(I $e) : void {

public function testModularConfig(): void
{
// hack to isolate Psalm from PHPUnit arguments
global $argv;
$argv = [];

$root = __DIR__ . '/../fixtures/ModularConfig';
$config = Config::loadFromXMLFile($root . '/psalm.xml', $root);
$this->assertEquals(
Expand Down
9 changes: 9 additions & 0 deletions tests/ForbiddenCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class ForbiddenCodeTest extends TestCase
use InvalidCodeAnalysisTestTrait;
use ValidCodeAnalysisTestTrait;

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

// hack to isolate Psalm from PHPUnit cli arguments
global $argv;
$argv = [];
}

public function providerInvalidCodeParse(): iterable
{
return [
Expand Down
4 changes: 4 additions & 0 deletions tests/StubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class StubTest extends TestCase

public static function setUpBeforeClass(): void
{
// hack to isolate Psalm from PHPUnit cli arguments
global $argv;
$argv = [];

self::$config = new TestConfig();

if (!defined('PSALM_VERSION')) {
Expand Down
9 changes: 9 additions & 0 deletions tests/VariadicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class VariadicTest extends TestCase
{
use ValidCodeAnalysisTestTrait;

public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();

// hack to isolate Psalm from PHPUnit cli arguments
global $argv;
$argv = [];
}

public function testVariadicArrayBadParam(): void
{
$this->expectExceptionMessage('InvalidScalarArgument');
Expand Down

0 comments on commit bc2d66c

Please sign in to comment.