Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="tests/bootstrap.php" cacheResult="false" colors="true" executionOrder="random" failOnRisky="true" failOnWarning="true" failOnEmptyTestSuite="true" beStrictAboutChangesToGlobalState="true" beStrictAboutOutputDuringTests="true" cacheDirectory="tmp/.phpunit.cache" beStrictAboutCoverageMetadata="true">
<extensions>
<bootstrap class="PHPStan\Testing\PHPUnit\PHPUnitExtension"/>
</extensions>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case extension developer have to deal with the same race condition problems, we could instruct them to use the extension, which takes care of bootstrapping/re-building the container for them

<testsuites>
<testsuite name="PHPStan">
<directory suffix="Test.php">tests/PHPStan</directory>
Expand Down
7 changes: 0 additions & 7 deletions src/Testing/PHPStanTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PHPStan\Testing;

use Override;
use PHPStan\Analyser\ConstantResolver;
use PHPStan\Analyser\DirectInternalScopeFactory;
use PHPStan\Analyser\Error;
Expand Down Expand Up @@ -97,12 +96,6 @@ public static function getContainer(): Container
return self::$containers[$cacheKey];
}

#[Override]
public static function setUpBeforeClass(): void
{
self::getContainer();
}

/**
* @return string[]
*/
Expand Down
26 changes: 26 additions & 0 deletions src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace PHPStan\Testing\PHPUnit;

use Override;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Event\Test\DataProviderMethodCalled;
use PHPUnit\Event\Test\DataProviderMethodCalledSubscriber;
use function is_a;

final class InitContainerBeforeDataProviderSubscriber implements DataProviderMethodCalledSubscriber

Check failure on line 11 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Class PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber implements unknown interface PHPUnit\Event\Test\DataProviderMethodCalledSubscriber.

Check failure on line 11 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Class PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber implements unknown interface PHPUnit\Event\Test\DataProviderMethodCalledSubscriber.

Check failure on line 11 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Class PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber implements unknown interface PHPUnit\Event\Test\DataProviderMethodCalledSubscriber.

Check failure on line 11 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Class PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber implements unknown interface PHPUnit\Event\Test\DataProviderMethodCalledSubscriber.

Check failure on line 11 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Class PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber implements unknown interface PHPUnit\Event\Test\DataProviderMethodCalledSubscriber.

Check failure on line 11 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Class PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber implements unknown interface PHPUnit\Event\Test\DataProviderMethodCalledSubscriber.
{

#[Override]
public function notify(DataProviderMethodCalled $event): void

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Unused PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Parameter $event of method PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify() has invalid type PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Unused PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Parameter $event of method PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify() has invalid type PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Unused PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Parameter $event of method PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify() has invalid type PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Unused PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Parameter $event of method PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify() has invalid type PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Unused PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Parameter $event of method PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify() has invalid type PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Unused PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify

Check failure on line 15 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Parameter $event of method PHPStan\Testing\PHPUnit\InitContainerBeforeDataProviderSubscriber::notify() has invalid type PHPUnit\Event\Test\DataProviderMethodCalled.
{
$testClassName = $event->testMethod()->className();

Check failure on line 17 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Call to method testMethod() on an unknown class PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 17 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Call to method testMethod() on an unknown class PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 17 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Call to method testMethod() on an unknown class PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 17 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Call to method testMethod() on an unknown class PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 17 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Call to method testMethod() on an unknown class PHPUnit\Event\Test\DataProviderMethodCalled.

Check failure on line 17 in src/Testing/PHPUnit/InitContainerBeforeDataProviderSubscriber.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Call to method testMethod() on an unknown class PHPUnit\Event\Test\DataProviderMethodCalled.

if (!is_a($testClassName, PhpStanTestCase::class, true)) {
return;
}

$testClassName::getContainer();
}

}
26 changes: 26 additions & 0 deletions src/Testing/PHPUnit/PHPUnitExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace PHPStan\Testing\PHPUnit;

use Override;
use PHPUnit\Runner\Extension\Extension;
use PHPUnit\Runner\Extension\Facade;
use PHPUnit\Runner\Extension\ParameterCollection;
use PHPUnit\TextUI\Configuration\Configuration;

final class PHPUnitExtension implements Extension

Check failure on line 11 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Class PHPStan\Testing\PHPUnit\PHPUnitExtension implements unknown interface PHPUnit\Runner\Extension\Extension.

Check failure on line 11 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Class PHPStan\Testing\PHPUnit\PHPUnitExtension implements unknown interface PHPUnit\Runner\Extension\Extension.

Check failure on line 11 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Class PHPStan\Testing\PHPUnit\PHPUnitExtension implements unknown interface PHPUnit\Runner\Extension\Extension.

Check failure on line 11 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Class PHPStan\Testing\PHPUnit\PHPUnitExtension implements unknown interface PHPUnit\Runner\Extension\Extension.

Check failure on line 11 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Class PHPStan\Testing\PHPUnit\PHPUnitExtension implements unknown interface PHPUnit\Runner\Extension\Extension.

Check failure on line 11 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Class PHPStan\Testing\PHPUnit\PHPUnitExtension implements unknown interface PHPUnit\Runner\Extension\Extension.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should be PHPStanPHPUnitExtension

{

#[Override]
public function bootstrap(

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Unused PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Unused PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Unused PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Unused PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Unused PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Parameter $parameters of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\ParameterCollection.

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Parameter $facade of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\Facade.

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Parameter $configuration of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\TextUI\Configuration\Configuration.

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Unused PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Parameter $parameters of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\ParameterCollection.

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Parameter $facade of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\Facade.

Check failure on line 15 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Parameter $configuration of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\TextUI\Configuration\Configuration.
Configuration $configuration,

Check failure on line 16 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Parameter $configuration of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\TextUI\Configuration\Configuration.

Check failure on line 16 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Parameter $configuration of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\TextUI\Configuration\Configuration.

Check failure on line 16 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Parameter $configuration of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\TextUI\Configuration\Configuration.

Check failure on line 16 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Parameter $configuration of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\TextUI\Configuration\Configuration.
Facade $facade,

Check failure on line 17 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Parameter $facade of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\Facade.

Check failure on line 17 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Parameter $facade of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\Facade.

Check failure on line 17 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Parameter $facade of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\Facade.

Check failure on line 17 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Parameter $facade of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\Facade.

Check failure on line 17 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, ubuntu-latest)

Call to method registerSubscriber() on an unknown class PHPUnit\Runner\Extension\Facade.

Check failure on line 17 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, windows-latest)

Call to method registerSubscriber() on an unknown class PHPUnit\Runner\Extension\Facade.
ParameterCollection $parameters,

Check failure on line 18 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Parameter $parameters of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\ParameterCollection.

Check failure on line 18 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Parameter $parameters of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\ParameterCollection.

Check failure on line 18 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Parameter $parameters of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\ParameterCollection.

Check failure on line 18 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Parameter $parameters of method PHPStan\Testing\PHPUnit\PHPUnitExtension::bootstrap() has invalid type PHPUnit\Runner\Extension\ParameterCollection.
): void
{
$facade->registerSubscriber(

Check failure on line 21 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, ubuntu-latest)

Call to method registerSubscriber() on an unknown class PHPUnit\Runner\Extension\Facade.

Check failure on line 21 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, ubuntu-latest)

Call to method registerSubscriber() on an unknown class PHPUnit\Runner\Extension\Facade.

Check failure on line 21 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, windows-latest)

Call to method registerSubscriber() on an unknown class PHPUnit\Runner\Extension\Facade.

Check failure on line 21 in src/Testing/PHPUnit/PHPUnitExtension.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, windows-latest)

Call to method registerSubscriber() on an unknown class PHPUnit\Runner\Extension\Facade.
new InitContainerBeforeDataProviderSubscriber(),
);
}

}
Loading