Skip to content

Commit

Permalink
Update tools, PHPUnit 10 (#5571)
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Feb 12, 2023
1 parent d328059 commit fc673ea
Show file tree
Hide file tree
Showing 39 changed files with 246 additions and 322 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
.php-cs-fixer.cache
/.htaccess
/.phpunit.result.cache
/composer.lock
/.phpunit.cache/
/assets/
/media/
/node_modules/
Expand Down
2 changes: 0 additions & 2 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions .idea/redaxo.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions .tools/bin/update-all
Expand Up @@ -96,20 +96,20 @@ find redaxo/src/addons/phpmailer/vendor -name "*.md" ! -name "LICENSE.md" -type

printf "\nUpdate root composer.json and vendor/\n"
.tools/bin/update-root-composer
# https://github.com/composer/composer/issues/11247
# composer require --dev --ansi --fixed \
# friendsofredaxo/linter \
# phpstan/extension-installer \
# phpstan/phpstan \
# phpstan/phpstan-deprecation-rules \
# phpstan/phpstan-phpunit \
# phpstan/phpstan-symfony \
# psalm/plugin-phpunit \
# psalm/plugin-symfony \
# rector/rector \
# redaxo/php-cs-fixer-config \
# redaxo/psalm-plugin \
# vimeo/psalm
composer require --dev --ansi --fixed \
friendsofphp/php-cs-fixer \
friendsofredaxo/linter \
phpstan/extension-installer \
phpstan/phpstan \
phpstan/phpstan-deprecation-rules \
phpstan/phpstan-phpunit \
phpstan/phpstan-symfony \
psalm/plugin-phpunit \
psalm/plugin-symfony \
rector/rector \
redaxo/php-cs-fixer-config \
redaxo/psalm-plugin \
vimeo/psalm
composer update --ansi

printf "\nUpdate redaxo/src/core/assets/jquery.min.js\n"
Expand Down
46 changes: 23 additions & 23 deletions .tools/phpstan/baseline.neon
Expand Up @@ -1576,7 +1576,7 @@ parameters:
path: ../../redaxo/src/addons/structure/plugins/version/lib/revision.php

-
message: "#^Method class@anonymous/addons/structure/tests/category_test\\.php\\:176\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
message: "#^Method class@anonymous/addons/structure/tests/category_test\\.php\\:171\\:\\:__construct\\(\\) has parameter \\$params with no value type specified in iterable type array\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/tests/category_test.php

Expand Down Expand Up @@ -1628,7 +1628,7 @@ parameters:
-
message: "#^Method rex_structure_function_url_test\\:\\:testRedirectException\\(\\) has parameter \\$articleId with no type specified\\.$#"
count: 1
path: ../../redaxo/src/addons/structure/tests/function_rex_url_test.php
path: ../../redaxo/src/addons/structure/tests/function_url_test.php

-
message: "#^Method rex_user_role\\:\\:__construct\\(\\) has parameter \\$roles with no value type specified in iterable type array\\.$#"
Expand Down Expand Up @@ -3376,7 +3376,7 @@ parameters:
path: ../../redaxo/src/core/tests/sql/sql_test.php

-
message: "#^Property class@anonymous/core/tests/sql/sql_test\\.php\\:129\\:\\:\\$version has no type specified\\.$#"
message: "#^Property class@anonymous/core/tests/sql/sql_test\\.php\\:126\\:\\:\\$version has no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/sql/sql_test.php

Expand Down Expand Up @@ -3600,26 +3600,6 @@ parameters:
count: 1
path: ../../redaxo/src/core/tests/util/version_test.php

-
message: "#^Method rex_var_base_test\\:\\:assertParseOutputEquals\\(\\) has parameter \\$content with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_base_test.php

-
message: "#^Method rex_var_base_test\\:\\:assertParseOutputEquals\\(\\) has parameter \\$expected with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_base_test.php

-
message: "#^Method rex_var_base_test\\:\\:assertParseOutputEquals\\(\\) has parameter \\$msg with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_base_test.php

-
message: "#^Method rex_var_base_test\\:\\:getParseOutput\\(\\) has parameter \\$content with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_base_test.php

-
message: "#^Method rex_var_config_test\\:\\:testConfigReplace\\(\\) has parameter \\$content with no type specified\\.$#"
count: 1
Expand Down Expand Up @@ -3675,3 +3655,23 @@ parameters:
count: 1
path: ../../redaxo/src/core/tests/var/var_test.php

-
message: "#^Method rex_var_test_base\\:\\:assertParseOutputEquals\\(\\) has parameter \\$content with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_test_base.php

-
message: "#^Method rex_var_test_base\\:\\:assertParseOutputEquals\\(\\) has parameter \\$expected with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_test_base.php

-
message: "#^Method rex_var_test_base\\:\\:assertParseOutputEquals\\(\\) has parameter \\$msg with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_test_base.php

-
message: "#^Method rex_var_test_base\\:\\:getParseOutput\\(\\) has parameter \\$content with no type specified\\.$#"
count: 1
path: ../../redaxo/src/core/tests/var/var_test_base.php

41 changes: 10 additions & 31 deletions .tools/psalm/baseline.xml
Expand Up @@ -2624,13 +2624,8 @@
<MixedAssignment>
<code>$value</code>
</MixedAssignment>
<MixedInferredReturnType>
<code>iterable</code>
<code>iterable</code>
<code>iterable</code>
</MixedInferredReturnType>
</file>
<file src="redaxo/src/addons/structure/tests/function_rex_url_test.php">
<file src="redaxo/src/addons/structure/tests/function_url_test.php">
<MixedArgument>
<code>$articleId</code>
</MixedArgument>
Expand Down Expand Up @@ -5707,11 +5702,6 @@
<code>$rule</code>
</MixedAssignment>
</file>
<file src="redaxo/src/core/tests/packages/package_test.php">
<MixedInferredReturnType>
<code>iterable</code>
</MixedInferredReturnType>
</file>
<file src="redaxo/src/core/tests/path_test.php">
<MixedArgument>
<code>$basePath</code>
Expand Down Expand Up @@ -5762,12 +5752,6 @@
<MixedArgumentTypeCoercion>
<code>$values</code>
</MixedArgumentTypeCoercion>
<MixedInferredReturnType>
<code>array</code>
<code>array</code>
<code>array</code>
<code>iterable</code>
</MixedInferredReturnType>
</file>
<file src="redaxo/src/core/tests/util/file_test.php">
<MixedArgument>
Expand All @@ -5786,19 +5770,14 @@
</file>
<file src="redaxo/src/core/tests/util/formatter_test.php">
<InvalidDocblock>
<code>public function dataIntlDate(): array</code>
<code>public function dataIntlDateTime(): array</code>
<code>public function dataIntlTime(): array</code>
<code>public static function dataIntlDate(): array</code>
<code>public static function dataIntlDateTime(): array</code>
<code>public static function dataIntlTime(): array</code>
</InvalidDocblock>
<MixedArrayAccess>
<code>$params['some']</code>
<code>$params['subject']</code>
</MixedArrayAccess>
<MixedInferredReturnType>
<code>list&lt;array{string, string|int|DateTimeInterface|null, 3?: null|int|array{int, int}|string}&gt;</code>
<code>list&lt;array{string, string|int|DateTimeInterface|null, 3?: null|int|string}&gt;</code>
<code>list&lt;array{string, string|int|DateTimeInterface|null, 3?: null|int|string}&gt;</code>
</MixedInferredReturnType>
<MixedOperand>
<code>$params['some']</code>
<code>$params['subject']</code>
Expand Down Expand Up @@ -5873,12 +5852,6 @@
<code>$version</code>
</MixedArgument>
</file>
<file src="redaxo/src/core/tests/var/var_base_test.php">
<MixedArgument>
<code>$content</code>
<code>$msg</code>
</MixedArgument>
</file>
<file src="redaxo/src/core/tests/var/var_test.php">
<MixedArgument>
<code>$params['class']</code>
Expand All @@ -5895,6 +5868,12 @@
<code>$params['var']</code>
</MixedArrayAccess>
</file>
<file src="redaxo/src/core/tests/var/var_test_base.php">
<MixedArgument>
<code>$content</code>
<code>$msg</code>
</MixedArgument>
</file>
<file src="redaxo/src/core/update.php">
<MixedArrayAccess>
<code>$_SESSION[rex::getProperty('instname')]['backend_login']</code>
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Expand Up @@ -11,19 +11,19 @@
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "3.14.3",
"friendsofphp/php-cs-fixer": "v3.14.4",
"friendsofredaxo/linter": "1.4.0",
"j13k/yaml-lint": "@dev",
"jetbrains/phpstorm-attributes": "^1.0",
"phpstan/extension-installer": "1.2.0",
"phpstan/phpstan": "1.9.14",
"phpstan/phpstan": "1.9.17",
"phpstan/phpstan-deprecation-rules": "1.1.1",
"phpstan/phpstan-phpunit": "1.3.3",
"phpstan/phpstan-symfony": "1.2.21",
"phpunit/phpunit": "^9.5",
"phpstan/phpstan-phpunit": "1.3.4",
"phpstan/phpstan-symfony": "1.2.23",
"phpunit/phpunit": "^10.0.7",
"psalm/plugin-phpunit": "0.18.4",
"psalm/plugin-symfony": "v5.0.1",
"rector/rector": "0.15.10",
"rector/rector": "0.15.13",
"redaxo/php-cs-fixer-config": "2.0.0",
"redaxo/psalm-plugin": "2.0.0",
"vimeo/psalm": "5.6.0"
Expand Down
7 changes: 3 additions & 4 deletions phpunit.xml.dist
@@ -1,15 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap=".tools/bootstrap.php"
beStrictAboutCoversAnnotation="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnWarning="true"
failOnRisky="true"
verbose="true"
colors="true"
stderr="true"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="error_reporting" value="E_ALL"/>
Expand Down
31 changes: 21 additions & 10 deletions redaxo/src/addons/media_manager/tests/media_manager_test.php
@@ -1,5 +1,6 @@
<?php

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

/**
Expand Down Expand Up @@ -54,9 +55,7 @@ public function testCreate(): void
}
}

/**
* @dataProvider dataGetUrl
*/
#[DataProvider('dataGetUrl')]
public function testGetUrl($expectedBuster, $type, $file, $timestamp = null): void
{
$url = rex_media_manager::getUrl($type, $file, $timestamp);
Expand All @@ -69,13 +68,26 @@ public function testGetUrl($expectedBuster, $type, $file, $timestamp = null): vo
}

/** @return iterable<int, array{0: false|int, 1: string, 2: string|rex_media, 3?: int}> */
public function dataGetUrl(): iterable
public static function dataGetUrl(): iterable
{
yield [false, 'non_existing', 'test.jpg', time()];

$media = $this->getMockBuilder(rex_media::class)->disableOriginalConstructor()->getMock();
$media->method('getFileName')->willReturn('test.jpg');
$media->method('getUpdatedate')->willReturn(time());
$media = new class() extends rex_media {
public int $fakeUpdateDate = 0;

public function __construct() {}

public function getFileName()
{
return 'test.jpg';
}

public function getUpdateDate()
{
return $this->fakeUpdateDate;
}
};
$media->fakeUpdateDate = time();

yield [false, 'non_existing', $media];

Expand All @@ -92,9 +104,8 @@ public function dataGetUrl(): iterable

yield [$expectedBuster, $type, 'test.jpg', $fileTimestamp];

$media = $this->getMockBuilder(rex_media::class)->disableOriginalConstructor()->getMock();
$media->method('getFileName')->willReturn('test.jpg');
$media->method('getUpdatedate')->willReturn($fileTimestamp);
$media = clone $media;
$media->fakeUpdateDate = $fileTimestamp;

yield [$expectedBuster, $type, $media];
}
Expand Down

0 comments on commit fc673ea

Please sign in to comment.