Skip to content

Commit

Permalink
Merge pull request #490 from jakzal/phpunit-10
Browse files Browse the repository at this point in the history
Update PHPUnit (9.x -> 10.x)
  • Loading branch information
jakzal authored Nov 28, 2023
2 parents 3c37ebd + e841cf1 commit 3d1a01b
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
php-version: "${{ matrix.php }}"
tools: composer
ini-values: "phar.readonly=0"
coverage: none
coverage: pcov

- if: matrix.deps == 'high'
run: make update test package package-devkit
Expand Down
4 changes: 3 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ build:
environment:
php:
version: 8.2
variables:
XDEBUG_MODE: coverage
tests:
override:
- make phpunit
Expand All @@ -12,7 +14,7 @@ build:
coverage:
tests:
override:
- command: make phpunit-coverage
- command: make phpunit
coverage:
file: build/coverage.xml
format: clover
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,13 @@ deptrac: tools/deptrac
.PHONY: deptrac

infection:
phpdbg -qrr ./vendor/bin/infection --no-interaction --formatter=progress --min-msi=100 --min-covered-msi=100 --only-covered --ansi
./vendor/bin/infection --no-interaction --formatter=progress --min-msi=100 --min-covered-msi=100 --only-covered --ansi
.PHONY: infection

phpunit: tools/phpunit
tools/phpunit
.PHONY: phpunit

phpunit-coverage: tools/phpunit
phpdbg -qrr tools/phpunit
.PHONY: phpunit

package: tools/box
@rm -rf build/phar && mkdir -p build/phar build/phar/bin

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"psr/container": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"zalas/phpunit-globals": "^2.1",
"infection/infection": "^0.26"
"phpunit/phpunit": "^10.4",
"zalas/phpunit-globals": "^3.2",
"infection/infection": "^0.27"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 8 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" colors="true" verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" bootstrap="vendor/autoload.php" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" colors="true">
<coverage includeUncoveredFiles="true">
<report>
<clover outputFile="build/coverage.xml"/>
<html outputDirectory="build/coverage" lowUpperBound="50" highLowerBound="95"/>
Expand All @@ -20,7 +17,12 @@
<env name="TOOLBOX_EXCLUDED_TAGS" value="" force="true"/>
</php>
<extensions>
<extension class="Zalas\PHPUnit\Globals\AnnotationExtension"/>
<bootstrap class="Zalas\PHPUnit\Globals\AttributeExtension"/>
</extensions>
<logging/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
9 changes: 3 additions & 6 deletions tests/Cli/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Zalas\PHPUnit\Globals\Attribute\Putenv;
use Zalas\Toolbox\Cli\Application;
use Zalas\Toolbox\Cli\Command\InstallCommand;
use Zalas\Toolbox\Cli\Command\ListCommand;
Expand Down Expand Up @@ -70,17 +71,13 @@ public function test_it_defines_tools_option()
);
}

/**
* @putenv TOOLBOX_JSON=resources/pre.json,resources/tools.json
*/
#[Putenv('TOOLBOX_JSON', 'resources/pre.json,resources/tools.json')]
public function test_it_takes_the_tools_option_default_from_environment_if_present()
{
$this->assertSame(['resources/pre.json', 'resources/tools.json'], $this->app->getDefinition()->getOption('tools')->getDefault());
}

/**
* @putenv TOOLBOX_JSON=resources/pre.json , resources/tools.json
*/
#[Putenv('TOOLBOX_JSON', 'resources/pre.json , resources/tools.json')]
public function test_it_trims_the_tools_option()
{
$this->assertSame(['resources/pre.json', 'resources/tools.json'], $this->app->getDefinition()->getOption('tools')->getDefault());
Expand Down
13 changes: 4 additions & 9 deletions tests/Cli/Command/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Zalas\Toolbox\Tests\Cli\Command;

use PHPUnit\Framework\MockObject\Stub;
use Zalas\PHPUnit\Globals\Attribute\Putenv;
use Zalas\Toolbox\Cli\Command\InstallCommand;
use Zalas\Toolbox\Runner\Runner;
use Zalas\Toolbox\Tool\Command;
Expand Down Expand Up @@ -77,9 +78,7 @@ public function test_it_defines_target_dir_option()
$this->assertSame('/usr/local/bin', $this->cliCommand()->getDefinition()->getOption('target-dir')->getDefault());
}

/**
* @putenv TOOLBOX_TARGET_DIR=/tmp
*/
#[Putenv('TOOLBOX_TARGET_DIR', '/tmp')]
public function test_it_takes_the_target_dir_option_default_from_environment_if_present()
{
$this->assertSame('/tmp', $this->cliCommand()->getDefinition()->getOption('target-dir')->getDefault());
Expand All @@ -91,9 +90,7 @@ public function test_it_defines_exclude_tag_option()
$this->assertSame([], $this->cliCommand()->getDefinition()->getOption('exclude-tag')->getDefault());
}

/**
* @putenv TOOLBOX_EXCLUDED_TAGS=foo,bar,baz
*/
#[Putenv('TOOLBOX_EXCLUDED_TAGS', 'foo,bar,baz')]
public function test_it_takes_the_excluded_tag_option_default_from_environment_if_present()
{
$this->assertSame(['foo', 'bar', 'baz'], $this->cliCommand()->getDefinition()->getOption('exclude-tag')->getDefault());
Expand All @@ -105,9 +102,7 @@ public function test_it_defines_tag_option()
$this->assertSame([], $this->cliCommand()->getDefinition()->getOption('tag')->getDefault());
}

/**
* @putenv TOOLBOX_TAGS=foo,bar,baz
*/
#[Putenv('TOOLBOX_TAGS', 'foo,bar,baz')]
public function test_it_takes_the_tag_option_default_from_environment_if_present()
{
$this->assertSame(['foo', 'bar', 'baz'], $this->cliCommand()->getDefinition()->getOption('tag')->getDefault());
Expand Down
9 changes: 3 additions & 6 deletions tests/Cli/Command/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Zalas\Toolbox\Tests\Cli\Command;

use PHPUnit\Framework\MockObject\Stub;
use Zalas\PHPUnit\Globals\Attribute\Putenv;
use Zalas\Toolbox\Cli\Command\ListCommand;
use Zalas\Toolbox\Tool\Collection;
use Zalas\Toolbox\Tool\Command\ShCommand;
Expand Down Expand Up @@ -59,9 +60,7 @@ public function test_it_defines_exclude_tag_option()
$this->assertSame([], $this->cliCommand()->getDefinition()->getOption('exclude-tag')->getDefault());
}

/**
* @putenv TOOLBOX_EXCLUDED_TAGS=foo,bar,baz
*/
#[Putenv('TOOLBOX_EXCLUDED_TAGS', 'foo,bar,baz')]
public function test_it_takes_the_excluded_tag_option_default_from_environment_if_present()
{
$this->assertSame(['foo', 'bar', 'baz'], $this->cliCommand()->getDefinition()->getOption('exclude-tag')->getDefault());
Expand All @@ -72,9 +71,7 @@ public function test_it_defines_tag_option()
$this->assertTrue($this->cliCommand()->getDefinition()->hasOption('tag'));
}

/**
* @putenv TOOLBOX_TAGS=foo,bar,baz
*/
#[Putenv('TOOLBOX_TAGS', 'foo,bar,baz')]
public function test_it_takes_the_tag_option_default_from_environment_if_present()
{
$this->assertSame(['foo', 'bar', 'baz'], $this->cliCommand()->getDefinition()->getOption('tag')->getDefault());
Expand Down
13 changes: 4 additions & 9 deletions tests/Cli/Command/TestCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Zalas\Toolbox\Tests\Cli\Command;

use PHPUnit\Framework\MockObject\Stub;
use Zalas\PHPUnit\Globals\Attribute\Putenv;
use Zalas\Toolbox\Cli\Command\TestCommand;
use Zalas\Toolbox\Runner\Runner;
use Zalas\Toolbox\Tool\Command;
Expand Down Expand Up @@ -74,9 +75,7 @@ public function test_it_defines_target_dir_option()
$this->assertTrue($this->cliCommand()->getDefinition()->hasOption('target-dir'));
}

/**
* @putenv TOOLBOX_TARGET_DIR=/tmp
*/
#[Putenv('TOOLBOX_TARGET_DIR', '/tmp')]
public function test_it_takes_the_target_dir_option_default_from_environment_if_present()
{
$this->assertSame('/tmp', $this->cliCommand()->getDefinition()->getOption('target-dir')->getDefault());
Expand All @@ -88,9 +87,7 @@ public function test_it_defines_exclude_tag_option()
$this->assertSame([], $this->cliCommand()->getDefinition()->getOption('exclude-tag')->getDefault());
}

/**
* @putenv TOOLBOX_EXCLUDED_TAGS=foo,bar,baz
*/
#[Putenv('TOOLBOX_EXCLUDED_TAGS', 'foo,bar,baz')]
public function test_it_takes_the_excluded_tag_option_default_from_environment_if_present()
{
$this->assertSame(['foo', 'bar', 'baz'], $this->cliCommand()->getDefinition()->getOption('exclude-tag')->getDefault());
Expand All @@ -101,9 +98,7 @@ public function test_it_defines_tag_option()
$this->assertTrue($this->cliCommand()->getDefinition()->hasOption('tag'));
}

/**
* @putenv TOOLBOX_TAGS=foo,bar,baz
*/
#[Putenv('TOOLBOX_TAGS', 'foo,bar,baz')]
public function test_it_takes_the_tag_option_default_from_environment_if_present()
{
$this->assertSame(['foo', 'bar', 'baz'], $this->cliCommand()->getDefinition()->getOption('tag')->getDefault());
Expand Down
3 changes: 3 additions & 0 deletions tests/Cli/ServiceContainer/RunnerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Zalas\Toolbox\Tests\Cli\ServiceContainer;

use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerExceptionInterface;
Expand Down Expand Up @@ -89,6 +90,7 @@ public function test_it_creates_the_parametrised_runner_if_target_dir_option_is_
$this->assertInstanceOf(ParametrisedRunner::class, $runner);
}

#[DoesNotPerformAssertions]
public function test_the_parametrised_runner_includes_the_target_dir_parameter()
{
$this->givenInput(['--target-dir' => '/usr/local/bin', '--dry-run' => true]);
Expand All @@ -114,6 +116,7 @@ public function test_it_throws_an_exception_if_target_dir_does_not_exist()
$this->runnerFactory->createRunner();
}

#[DoesNotPerformAssertions]
public function test_it_uses_the_real_path_as_target_dir()
{
$this->givenInput(['--target-dir' => __DIR__.'/../../../bin', '--dry-run' => true]);
Expand Down
2 changes: 1 addition & 1 deletion tests/Cli/ServiceContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function test_it_creates_application_services(string $serviceId, string $
$this->assertInstanceOf($expectedType, $this->container->get($serviceId));
}

public function provideApplicationServices()
public static function provideApplicationServices()
{
yield [InstallCommand::class, InstallCommand::class];
yield [ListCommand::class, ListCommand::class];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/BoxBuildCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function test_it_complains_if_any_of_required_properties_is_missing(strin
BoxBuildCommandFactory::import($properties);
}

public function provideRequiredProperties(): \Generator
public static function provideRequiredProperties(): \Generator
{
yield ['repository'];
yield ['phar'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/ComposerBinPluginCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function test_it_complains_if_any_of_required_properties_is_missing(strin
ComposerBinPluginCommandFactory::import($properties);
}

public function provideRequiredProperties(): \Generator
public static function provideRequiredProperties(): \Generator
{
yield ['package'];
yield ['namespace'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/ComposerInstallCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function test_it_complains_if_a_required_property_is_missing(string $prop
ComposerInstallCommandFactory::import($properties);
}

public function provideRequiredProperties()
public static function provideRequiredProperties()
{
yield ['repository'];
yield ['target-dir'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/FileDownloadCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function test_it_complains_if_any_of_required_properties_is_missing(strin
FileDownloadCommandFactory::import($properties);
}

public function provideRequiredProperties(): \Generator
public static function provideRequiredProperties(): \Generator
{
yield ['url'];
yield ['file'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/PharDownloadCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function test_it_complains_if_any_of_required_properties_is_missing(strin
PharDownloadCommandFactory::import($properties);
}

public function provideRequiredProperties(): \Generator
public static function provideRequiredProperties(): \Generator
{
yield ['phar'];
yield ['bin'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/PhiveInstallCommandFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function test_it_accepts_unsigned_phars()
$this->assertStringContainsString('unsigned', (string)$command);
}

public function provideRequiredProperties(): \Generator
public static function provideRequiredProperties(): \Generator
{
yield ['alias'];
yield ['bin'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/Factory/ToolFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function test_it_complains_if_any_of_required_properties_is_missing(strin
ToolFactory::import($properties);
}

public function provideRequiredProperties(): \Generator
public static function provideRequiredProperties(): \Generator
{
yield ['name'];
yield ['summary'];
Expand Down

0 comments on commit 3d1a01b

Please sign in to comment.