Skip to content

Commit

Permalink
Merge pull request #67 from laminas/renovate/phpunit-phpunit-10.x
Browse files Browse the repository at this point in the history
Update dependency phpunit/phpunit to v10
  • Loading branch information
Xerkus committed Nov 21, 2023
2 parents b34fed2 + f5b50a7 commit e4c15d5
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 464 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,5 +1,5 @@
/.phpcs-cache
/.phpunit.result.cache
/.phpunit.cache
/.psalm-cache/
/clover.xml
/coveralls-upload.json
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -38,7 +38,7 @@
"composer/composer": "^2.6.4",
"laminas/laminas-coding-standard": "~2.5.0",
"mikey179/vfsstream": "^1.6.11",
"phpunit/phpunit": "^9.5.26",
"phpunit/phpunit": "^10.4",
"psalm/plugin-phpunit": "^0.18.0",
"vimeo/psalm": "^5.15.0",
"webmozart/assert": "^1.11.0"
Expand Down
587 changes: 234 additions & 353 deletions composer.lock

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions phpunit.xml.dist
Expand Up @@ -3,17 +3,24 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
convertDeprecationsToExceptions="true"
colors="true">
cacheDirectory=".phpunit.cache"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
colors="true"
>
<testsuites>
<testsuite name="Laminas\\ComponentInstaller Tests">
<directory>./test</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
6 changes: 0 additions & 6 deletions psalm-baseline.xml
Expand Up @@ -72,12 +72,6 @@
<code>__construct</code>
</PossiblyUnusedMethod>
</file>
<file src="test/ComponentInstallerTest.php">
<DeprecatedMethod>
<code>withConsecutive</code>
<code>withConsecutive</code>
</DeprecatedMethod>
</file>
<file src="test/ConfigDiscoveryTest.php">
<InvalidPropertyAssignmentValue>
<code>new Collection([
Expand Down
90 changes: 69 additions & 21 deletions test/ComponentInstallerTest.php
Expand Up @@ -22,16 +22,20 @@
use Laminas\ComponentInstaller\ComponentInstaller;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamDirectory;
use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\Constraint\IsAnything;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionObject;

use function count;
use function current;
use function dirname;
use function file_get_contents;
use function implode;
use function method_exists;
use function mkdir;
use function next;
use function preg_match;
use function preg_quote;
use function sprintf;
Expand Down Expand Up @@ -191,20 +195,40 @@ private function createOutputAssertions(array $informations): void
$consecutiveArguments = [];

foreach ($informations as $information) {
$consecutiveArguments[] = [
self::callback(static function (string $argument) use ($information): bool {
return preg_match(
sprintf('/%s/', preg_quote($argument, '/')),
$information
) !== false;
}),
];
$consecutiveArguments[] = self::callback(static function (string $argument) use ($information): bool {
return preg_match(
sprintf('/%s/', preg_quote($argument, '/')),
$information
) !== false;
});
}

$consecutive = new class ($consecutiveArguments) extends Constraint {
/**
* @param list<Constraint> $assertions
*/
public function __construct(private array $assertions)
{
$this->assertions[] = new IsAnything();
}

public function matches(mixed $other): bool
{
$assertion = current($this->assertions);
next($this->assertions);
return $assertion->matches($other);
}

public function toString(): string
{
return current($this->assertions)->toString();
}
};

$this->io
->expects(self::exactly(count($consecutiveArguments)))
->method('write')
->withConsecutive(...$consecutiveArguments);
->with($consecutive);
}

/**
Expand All @@ -214,22 +238,46 @@ private function createInputAssertions(array $questionsAssertions): void
{
$consecutiveReturnValues = $consecutiveArguments = [];
foreach ($questionsAssertions as $questionAssertion) {
$consecutiveArguments[] = [
self::callback($questionAssertion->assertion()),
];
$consecutiveArguments[] = self::callback($questionAssertion->assertion());
$consecutiveReturnValues[] = $questionAssertion->expectedAnswer;

if ($questionAssertion instanceof RememberedAnswerQuestionAssertion) {
$consecutiveArguments[] = [self::callback($questionAssertion->rememberAnswerAssertion())];
$consecutiveArguments[] = self::callback($questionAssertion->rememberAnswerAssertion());
$consecutiveReturnValues[] = $questionAssertion->remember ? 'y' : 'n';
}
}

$consecutive = new class ($consecutiveArguments) extends Constraint {
/**
* @param list<Constraint> $assertions
*/
public function __construct(private array $assertions)
{
$this->assertions[] = new IsAnything();
}

public function matches(mixed $other): bool
{
$assertion = current($this->assertions);
next($this->assertions);
return $assertion->matches($other);
}

public function toString(): string
{
return current($this->assertions)->toString();
}
};

$matcher = self::exactly(count($consecutiveReturnValues));

$this->io
->expects(self::exactly(count($consecutiveArguments)))
->expects($matcher)
->method('ask')
->withConsecutive(...$consecutiveArguments)
->willReturnOnConsecutiveCalls(...$consecutiveReturnValues);
->with($consecutive)
->willReturnCallback(function () use ($matcher, $consecutiveReturnValues) {
return $consecutiveReturnValues[$matcher->numberOfInvocations() - 1];
});
}

/**
Expand Down Expand Up @@ -332,7 +380,7 @@ public function getModuleDependencies()
* 5: null|string
* }>
*/
public function dependency(): array
public static function dependency(): array
{
return [
// 'description' => [
Expand Down Expand Up @@ -706,7 +754,7 @@ public function getModuleDependencies()
* 2: list<non-empty-string>
* }>
*/
public function modules(): array
public static function modules(): array
{
return [
// 'description' => [
Expand Down Expand Up @@ -1347,7 +1395,7 @@ public function testAppendModuleAndPrependComponent(): void
* 1: array<string, array<array-key, string>>
* }>
*/
public function moduleClass(): array
public static function moduleClass(): array
{
return [
[__DIR__ . '/TestAsset/ModuleBadlyFormatted.php', ['BadlyFormatted\Application' => ['Dependency1']]],
Expand Down Expand Up @@ -1744,7 +1792,7 @@ public function testOnPostPackageInstallDoesNotPromptForIgnoredPackages(): void
* non-empty-string
* }>
*/
public function injectorConfigProvider(): array
public static function injectorConfigProvider(): array
{
$config = <<<'CONFIG'
<?php
Expand Down Expand Up @@ -1932,7 +1980,7 @@ public function testDoesNotModifyRootPackageOnPluginActivation(): void
* 5:list<non-empty-string>
* }>
*/
public function packageUpdateScenarios(): Generator
public static function packageUpdateScenarios(): Generator
{
yield 'package introduces module' => [
[], // Initially installed application modules
Expand Down
2 changes: 1 addition & 1 deletion test/ConfigDiscovery/AbstractConfigAggregatorTestCase.php
Expand Up @@ -46,7 +46,7 @@ public function testLocateReturnsFalseWhenFileDoesNotHaveExpectedContents(): voi
* 0: string
* }>
*/
public function validMezzioConfigContents(): array
public static function validMezzioConfigContents(): array
{
// @codingStandardsIgnoreStart
return [
Expand Down
2 changes: 1 addition & 1 deletion test/ConfigDiscovery/ApplicationConfigTest.php
Expand Up @@ -41,7 +41,7 @@ public function testLocateReturnsFalseWhenFileDoesNotHaveExpectedContents(): voi
/**
* @psalm-return array<string, array{0: string}>
*/
public function validApplicationConfigContents(): array
public static function validApplicationConfigContents(): array
{
return [
'long-array' => ['<' . "?php\nreturn array(\n 'modules' => array(\n )\n);"],
Expand Down
2 changes: 1 addition & 1 deletion test/ConfigDiscovery/DevelopmentConfigTest.php
Expand Up @@ -41,7 +41,7 @@ public function testLocateReturnsFalseWhenFileDoesNotHaveExpectedContents(): voi
/**
* @psalm-return array<string, array{0: string}>
*/
public function validDevelopmentConfigContents(): array
public static function validDevelopmentConfigContents(): array
{
return [
'long-array' => ['<' . "?php\nreturn array(\n 'modules' => array(\n )\n);"],
Expand Down
2 changes: 1 addition & 1 deletion test/ConfigDiscovery/MezzioConfigTest.php
Expand Up @@ -41,7 +41,7 @@ public function testLocateReturnsFalseWhenFileDoesNotHaveExpectedContents(): voi
/**
* @psalm-return array<string, array{0: string}>
*/
public function validMezzioConfigContents(): array
public static function validMezzioConfigContents(): array
{
// @codingStandardsIgnoreStart
return [
Expand Down
2 changes: 1 addition & 1 deletion test/ConfigDiscovery/ModulesConfigTest.php
Expand Up @@ -41,7 +41,7 @@ public function testLocateReturnsFalseWhenFileDoesNotHaveExpectedContents(): voi
/**
* @psalm-return array<string, array{0: string}>
*/
public function validModulesConfigContents(): array
public static function validModulesConfigContents(): array
{
return [
'long-array' => ['<' . "?php\nreturn array(\n);"],
Expand Down

0 comments on commit e4c15d5

Please sign in to comment.