Skip to content

Commit

Permalink
chore: Upgrade to PHPUnit 10 (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Jan 18, 2024
1 parent f01e3ab commit ebe236c
Show file tree
Hide file tree
Showing 53 changed files with 1,543 additions and 949 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
"php": "^8.2",
"fidry/console": "^0.6.6",
"fidry/filesystem": "^1.1",
"jetbrains/phpstorm-stubs": "^v2022.2",
"jetbrains/phpstorm-stubs": "^2022.2",
"nikic/php-parser": "^4.12",
"symfony/console": "^6.4 || ^7.0",
"symfony/deprecation-contracts": "^3.4",
"symfony/filesystem": "^6.4 || ^7.0",
"symfony/finder": "^6.4 || ^7.0",
"thecodingmachine/safe": "^2.0"
Expand All @@ -33,7 +34,7 @@
"fidry/makefile": "^1.0",
"humbug/box": "^4.5.1",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^10.0",
"symfony/yaml": "^6.4 || ^7.0"
},
"minimum-stability": "dev",
Expand Down
2,077 changes: 1,352 additions & 725 deletions composer.lock

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ file that was distributed with this source code.
colors="true"
cacheResultFile="build/.phpunit.result.cache"
>
<php>
<env name="NO_COLOR" value="1"/>
</php>

<testsuites>
<testsuite name="PHP-Scoper Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory suffix=".php">src</directory>
<directory>src</directory>
</include>
</coverage>
</source>
</phpunit>
3 changes: 3 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -32,6 +33,8 @@

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_82,
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
]);

$rectorConfig->skip([
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Humbug\PhpScoper\Console\Command\InspectCommand;
use Humbug\PhpScoper\Console\Command\InspectSymbolCommand;
use Humbug\PhpScoper\Container;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
use Symfony\Component\Console\Helper\FormatterHelper;
use function Humbug\PhpScoper\get_php_scoper_version;
use function sprintf;
Expand All @@ -28,8 +29,8 @@

/**
* @private
* @codeCoverageIgnore
*/
#[CodeCoverageIgnore]
final readonly class Application implements FidryApplication
{
private const LOGO = <<<'ASCII'
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Command/ChangeableDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Fidry\Console\IO;
use Humbug\PhpScoper\NotInstantiable;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputOption;
use function chdir as native_chdir;
Expand All @@ -26,8 +27,8 @@

/**
* @private
* @codeCoverageIgnore
*/
#[CodeCoverageIgnore]
final class ChangeableDirectory
{
use NotInstantiable;
Expand Down
3 changes: 2 additions & 1 deletion src/Console/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Fidry\Console\Command\Command;
use Fidry\Console\Command\Configuration as CommandConfiguration;
use Fidry\Console\IO;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Filesystem\Filesystem;
Expand All @@ -27,8 +28,8 @@

/**
* @private
* @codeCoverageIgnore
*/
#[CodeCoverageIgnore]
final readonly class InitCommand implements Command
{
private const CONFIG_FILE_OPT = 'config';
Expand Down
3 changes: 2 additions & 1 deletion src/Console/ScoperLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Fidry\Console\Application\Application as FidryApplication;
use Fidry\Console\IO;
use Humbug\PhpScoper\Throwable\Exception\ParsingException;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -30,8 +31,8 @@
/**
* @private
* @final
* @codeCoverageIgnore
*/
#[CodeCoverageIgnore]
class ScoperLogger
{
private readonly float $startTime;
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/E2ECollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

namespace Humbug\PhpScoper\AutoReview;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function count;

/**
* @covers \Humbug\PhpScoper\AutoReview\E2ECollector
*
* @internal
*/
#[CoversClass(E2ECollector::class)]
class E2ECollectorTest extends TestCase
{
public function test_it_collects_the_e2e_test_names(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/GAE2ECollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

namespace Humbug\PhpScoper\AutoReview;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function count;

/**
* @covers \Humbug\PhpScoper\AutoReview\GAE2ECollector
*
* @internal
*/
#[CoversClass(GAE2ECollector::class)]
class GAE2ECollectorTest extends TestCase
{
public function test_it_collects_the_e2e_test_names(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/GAE2ETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

namespace Humbug\PhpScoper\AutoReview;

use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\TestCase;
use function array_diff;

/**
* @coversNothing
*
* @internal
*/
#[CoversNothing]
class GAE2ETest extends TestCase
{
private const IGNORED_E2E_TESTS = [
Expand Down
4 changes: 2 additions & 2 deletions tests/AutoReview/MakefileE2ETest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Fidry\Makefile\Parser;
use Fidry\Makefile\Rule;
use Fidry\Makefile\Test\BaseMakefileTestCase;
use PHPUnit\Framework\Attributes\CoversNothing;
use function array_filter;
use function array_map;
use function array_values;
Expand All @@ -25,10 +26,9 @@
use function str_starts_with;

/**
* @coversNothing
*
* @internal
*/
#[CoversNothing]
class MakefileE2ETest extends BaseMakefileTestCase
{
protected static function getMakefilePath(): string
Expand Down
8 changes: 4 additions & 4 deletions tests/Autoload/AutoloadDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
use Humbug\PhpScoper\Symbol\SymbolsRegistry;
use KevinGH\Box\Composer\AutoloadDumper;
use PhpParser\Node\Name\FullyQualified;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @coversNothing
* @internal
*/
#[CoversNothing]
final class AutoloadDumperTest extends TestCase
{
/**
* @dataProvider autoloadProvider
*/
#[DataProvider('autoloadProvider')]
public function test_it_can_generate_the_autoload(
SymbolsRegistry $symbolsRegistry,
array $excludedComposerAutoloadFileHashes,
Expand Down
8 changes: 4 additions & 4 deletions tests/Autoload/ComposerFileHasherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
namespace Autoload;

use Humbug\PhpScoper\Autoload\ComposerFileHasher;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @covers \Humbug\PhpScoper\Autoload\ComposerFileHasher
* @internal
*/
#[CoversClass(ComposerFileHasher::class)]
final class ComposerFileHasherTest extends TestCase
{
/**
* @dataProvider filesProvider
*/
#[DataProvider('filesProvider')]
public function test_it_can_get_the_composer_hash_of_the_files(
string $vendorDir,
string $rootDir,
Expand Down
5 changes: 2 additions & 3 deletions tests/Autoload/ScoperAutoloadGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@

use Humbug\PhpScoper\Symbol\SymbolsRegistry;
use PhpParser\Node\Name\FullyQualified;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
class ScoperAutoloadGeneratorTest extends TestCase
{
/**
* @dataProvider provideRegistry
*/
#[DataProvider('provideRegistry')]
public function test_generate_the_autoload(
SymbolsRegistry $registry,
array $fileHashes,
Expand Down
8 changes: 4 additions & 4 deletions tests/Configuration/ConfigurationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
use Humbug\PhpScoper\Symbol\NamespaceRegistry;
use Humbug\PhpScoper\Symbol\SymbolRegistry;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use function array_keys;
use function Safe\touch;
use const DIRECTORY_SEPARATOR;

/**
* @covers \Humbug\PhpScoper\Configuration\ConfigurationFactory
*
* @group integration
*
* @internal
*/
#[CoversClass(ConfigurationFactory::class)]
#[Group('integration')]
class ConfigurationFactoryTest extends FileSystemTestCase
{
private ConfigurationFactory $configFactory;
Expand Down
4 changes: 2 additions & 2 deletions tests/Configuration/ConfigurationKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

namespace Humbug\PhpScoper\Configuration;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionClassConstant;
use function array_values;

/**
* @covers \Humbug\PhpScoper\Configuration\ConfigurationKeys
*
* @internal
*/
#[CoversClass(ConfigurationKeys::class)]
final class ConfigurationKeysTest extends TestCase
{
public function test_keywords_contains_all_the_known_configuration_keys(): void
Expand Down
8 changes: 4 additions & 4 deletions tests/Configuration/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
use Humbug\PhpScoper\Patcher\Patcher;
use Humbug\PhpScoper\Patcher\PatcherChain;
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @covers \Humbug\PhpScoper\Configuration\Configuration
*
* @internal
*/
#[CoversClass(Configuration::class)]
final class ConfigurationTest extends TestCase
{
/**
* @dataProvider prefixProvider
*
* @param non-empty-string $prefix
*/
#[DataProvider('prefixProvider')]
public function test_it_validates_the_prefix(
string $prefix,
string $expectedExceptionMessage
Expand Down
7 changes: 4 additions & 3 deletions tests/Configuration/DefaultConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@

use Humbug\PhpScoper\Container;
use Isolated\Symfony\Component\Finder\Finder as IsolatedFinder;
use PHPUnit\Framework\Attributes\CoversNothing;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Finder\Finder;
use function class_alias;
use function class_exists;

/**
* @coversNothing
* @group integration
*
* @internal
*/
#[Group('integration')]
#[CoversNothing]
final class DefaultConfigurationTest extends TestCase
{
private ConfigurationFactory $configurationFactory;
Expand Down
13 changes: 5 additions & 8 deletions tests/Configuration/RegexCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

namespace Humbug\PhpScoper\Configuration;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @covers \Humbug\PhpScoper\Configuration\RegexChecker
*
* @internal
*/
#[CoversClass(RegexChecker::class)]
final class RegexCheckerTest extends TestCase
{
private RegexChecker $regexChecker;
Expand All @@ -30,9 +31,7 @@ protected function setUp(): void
$this->regexChecker = new RegexChecker();
}

/**
* @dataProvider regexLikeProvider
*/
#[DataProvider('regexLikeProvider')]
public function test_it_can_tell_if_a_string_looks_like_a_regex(
string $value,
bool $expected
Expand Down Expand Up @@ -123,9 +122,7 @@ public static function regexLikeProvider(): iterable
];
}

/**
* @dataProvider regexProvider
*/
#[DataProvider('regexProvider')]
public function test_it_can_validate_that_a_string_is_a_valid_regex_or_not(
string $regex,
?string $expected
Expand Down
Loading

0 comments on commit ebe236c

Please sign in to comment.