Skip to content

Commit

Permalink
Updated to PHPUnit 10.1 (#250)
Browse files Browse the repository at this point in the history
* Updated to PHPUnit 10.1, fixed deprecations

* Fixed usages of deprecated mock methods
  • Loading branch information
davidbyoung committed Apr 16, 2023
1 parent 9a311d5 commit 60b0d4b
Show file tree
Hide file tree
Showing 53 changed files with 185 additions and 168 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,7 @@

### Changed

- Updated to PHPUnit 10.0 ([#248](https://github.com/aphiria/aphiria/pull/248))
- Updated to PHPUnit 10.1 ([#248](https://github.com/aphiria/aphiria/pull/248), [#250](https://github.com/aphiria/aphiria/pull/250))

## [v1.0.0-alpha8](https://github.com/aphiria/aphiria/compare/v1.0.0-alpha7...v1.0.0-alpha8) (2022-12-10)

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -99,7 +99,7 @@
"friendsofphp/php-cs-fixer": "^3.6",
"mockery/mockery": "^1.5",
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^10.0",
"phpunit/phpunit": "^10.1",
"psalm/plugin-mockery": "^1.1",
"vimeo/psalm": "^5.1"
},
Expand Down
26 changes: 14 additions & 12 deletions phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/*/src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Aphiria">
<directory>src/*/tests</directory>
</testsuite>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Aphiria">
<directory>src/*/tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src/*/src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Api/composer.json
Expand Up @@ -51,7 +51,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"mockery/mockery": "^1.4",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
26 changes: 14 additions & 12 deletions src/Api/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="API">
<directory>tests</directory>
</testsuite>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="API">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Application/composer.json
Expand Up @@ -43,7 +43,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
10 changes: 6 additions & 4 deletions src/Application/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Application">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Authentication/composer.json
Expand Up @@ -45,7 +45,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
10 changes: 6 additions & 4 deletions src/Authentication/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Authentication">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Authorization/composer.json
Expand Up @@ -46,7 +46,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
10 changes: 6 additions & 4 deletions src/Authorization/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Authorization">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Collections/composer.json
Expand Up @@ -46,7 +46,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
10 changes: 6 additions & 4 deletions src/Collections/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Collections">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/Console/composer.json
Expand Up @@ -45,7 +45,7 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"mockery/mockery": "^1.4",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
10 changes: 6 additions & 4 deletions src/Console/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="Console">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
4 changes: 0 additions & 4 deletions src/Console/src/Drivers/Driver.php
Expand Up @@ -13,7 +13,6 @@
namespace Aphiria\Console\Drivers;

use Aphiria\Console\StatusCode;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;

/**
* Defines a base CLI driver that's common to multiple OS
Expand Down Expand Up @@ -91,7 +90,6 @@ abstract protected function getCliDimensionsFromOS(): ?array;
*
* @return array|null The dimensions (width x height) as a tuple if found, otherwise null
*/
#[CodeCoverageIgnore]
protected function getCliDimensionsFromStty(): ?array
{
$sttyOutput = $this->runProcess('stty -a | grep columns');
Expand All @@ -116,7 +114,6 @@ protected function getCliDimensionsFromStty(): ?array
* @param string $command The command to run in the process
* @return string|null The output of the process
*/
#[CodeCoverageIgnore]
protected function runProcess(string $command): ?string
{
$process = \proc_open(
Expand Down Expand Up @@ -145,7 +142,6 @@ protected function runProcess(string $command): ?string
*
* @return bool Whether or not STTY is supported
*/
#[CodeCoverageIgnore]
protected function supportsStty(): bool
{
if ($this->supportsStty !== null) {
Expand Down
2 changes: 0 additions & 2 deletions src/Console/src/Drivers/UnixLikeDriver.php
Expand Up @@ -13,7 +13,6 @@
namespace Aphiria\Console\Drivers;

use Aphiria\Console\Output\IOutput;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;

/**
* Defines the *nix-based CLI driver
Expand Down Expand Up @@ -48,7 +47,6 @@ public function readHiddenInput(IOutput $output): ?string
/**
* @inheritdoc
*/
#[CodeCoverageIgnore]
protected function getCliDimensionsFromOS(): ?array
{
return $this->getCliDimensionsFromStty();
Expand Down
3 changes: 0 additions & 3 deletions src/Console/src/Drivers/WindowsDriver.php
Expand Up @@ -13,7 +13,6 @@
namespace Aphiria\Console\Drivers;

use Aphiria\Console\Output\IOutput;
use PHPUnit\Framework\Attributes\CodeCoverageIgnore;

/**
* Defines the Windows OS CLI driver
Expand All @@ -27,7 +26,6 @@ class WindowsDriver extends Driver
* @inheritdoc
* @psalm-suppress ForbiddenCode We purposely are running an external executable
*/
#[CodeCoverageIgnore]
public function readHiddenInput(IOutput $output): ?string
{
// Check if we're running from a PHAR
Expand All @@ -51,7 +49,6 @@ public function readHiddenInput(IOutput $output): ?string
*
* @return array|null The dimensions (width x height) as a tuple if found, otherwise null
*/
#[CodeCoverageIgnore]
protected function getCliDimensionsFromConsoleMode(): ?array
{
$modeOutput = $this->runProcess('mode CON');
Expand Down
6 changes: 6 additions & 0 deletions src/Console/tests/Drivers/UnixLikeDriverTest.php
Expand Up @@ -12,12 +12,18 @@

namespace Aphiria\Console\Tests\Drivers;

use Aphiria\Console\Drivers\Driver;
use Aphiria\Console\Drivers\HiddenInputNotSupportedException;
use Aphiria\Console\Drivers\UnixLikeDriver;
use Aphiria\Console\Output\IOutput;
use Aphiria\Console\StatusCode;
use PHPUnit\Framework\Attributes\IgnoreMethodForCodeCoverage;
use PHPUnit\Framework\TestCase;

#[IgnoreMethodForCodeCoverage(UnixLikeDriver::class, 'getCliDimensionsFromOS')]
#[IgnoreMethodForCodeCoverage(Driver::class, 'getCliDimensionsFromStty')]
#[IgnoreMethodForCodeCoverage(Driver::class, 'runProcess')]
#[IgnoreMethodForCodeCoverage(Driver::class, 'supportsStty')]
class UnixLikeDriverTest extends TestCase
{
private UnixLikeDriver $driver;
Expand Down
8 changes: 8 additions & 0 deletions src/Console/tests/Drivers/WindowsDriverTest.php
Expand Up @@ -12,10 +12,18 @@

namespace Aphiria\Console\Tests\Drivers;

use Aphiria\Console\Drivers\Driver;
use Aphiria\Console\Drivers\WindowsDriver;
use Aphiria\Console\StatusCode;
use PHPUnit\Framework\Attributes\IgnoreMethodForCodeCoverage;
use PHPUnit\Framework\TestCase;

#[IgnoreMethodForCodeCoverage(WindowsDriver::class, 'getCliDimensionsFromOS')]
#[IgnoreMethodForCodeCoverage(WindowsDriver::class, 'readHiddenInput')]
#[IgnoreMethodForCodeCoverage(WindowsDriver::class, 'getCliDimensionsFromConsoleMode')]
#[IgnoreMethodForCodeCoverage(Driver::class, 'getCliDimensionsFromStty')]
#[IgnoreMethodForCodeCoverage(Driver::class, 'runProcess')]
#[IgnoreMethodForCodeCoverage(Driver::class, 'supportsStty')]
class WindowsDriverTest extends TestCase
{
private WindowsDriver $driver;
Expand Down
2 changes: 1 addition & 1 deletion src/ContentNegotiation/composer.json
Expand Up @@ -50,7 +50,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down
10 changes: 6 additions & 4 deletions src/ContentNegotiation/phpunit.xml.dist
@@ -1,14 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<html outputDirectory="./.coverage"/>
</report>
</coverage>
<testsuite name="ContentNegotiation">
<directory>tests</directory>
</testsuite>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
2 changes: 1 addition & 1 deletion src/DependencyInjection/composer.json
Expand Up @@ -45,7 +45,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.5",
"phpunit/phpunit": "^10.0"
"phpunit/phpunit": "^10.1"
},
"scripts": {
"phpcs-test": "@phpcs-fix --dry-run",
Expand Down

0 comments on commit 60b0d4b

Please sign in to comment.