diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index ab6f6677dc..84856a3118 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -46,8 +46,8 @@ jobs: - name: Install PHP dependencies run: | - if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev; fi - if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev; fi + if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit atk4/ergebnis-phpunit-slow-test-detector --dev; fi + if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev; fi if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* behat/\* --dev; fi composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader @@ -55,7 +55,7 @@ jobs: if: startsWith(matrix.type, 'Phpunit') run: | php demos/_demo-data/create-db.php - vendor/bin/phpunit --exclude-group none --no-coverage -v + vendor/bin/phpunit --exclude-group none --no-coverage --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) - name: Check Coding Style (only for CodingStyle) if: matrix.type == 'CodingStyle' @@ -133,13 +133,13 @@ jobs: - name: Install PHP dependencies run: | - if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "Phpunit Lowest" ] && [ "${{ matrix.type }}" != "Phpunit Burn" ]; then composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev; fi - if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev; fi + if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "Phpunit Lowest" ] && [ "${{ matrix.type }}" != "Phpunit Burn" ]; then composer remove --no-interaction --no-update phpunit/phpunit atk4/ergebnis-phpunit-slow-test-detector --dev; fi + if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev; fi if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* behat/\* --dev; fi if [ -n "$LOG_COVERAGE" ]; then composer require --no-interaction --no-install phpunit/phpcov; fi composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader if [ "${{ matrix.type }}" = "Phpunit Lowest" ]; then composer update --ansi --prefer-dist --prefer-lowest --prefer-stable --no-interaction --no-progress --optimize-autoloader; fi - if [ "${{ matrix.type }}" = "Phpunit Burn" ]; then sed -i 's~ *public function runBare(): void~public function runBare(): void { gc_collect_cycles(); gc_collect_cycles(); $memDiffs = array_fill(0, '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 64; else echo 16; fi)"', 0); for ($i = -1; $i < count($memDiffs); ++$i) { $this->_runBare(); gc_collect_cycles(); gc_collect_cycles(); $mem = memory_get_usage(); if ($i !== -1) { $memDiffs[$i] = $mem - $memPrev; } $memPrev = $mem; rsort($memDiffs); if (array_sum($memDiffs) >= 4096 * 1024 || $memDiffs[2] > 0) { $this->onNotSuccessfulTest(new AssertionFailedError("Memory leak detected! (" . implode(" + ", array_map(static fn ($v) => number_format($v / 1024, 3, ".", " "), array_filter($memDiffs))) . " KB, " . ($i + 2) . " iterations)")); } } } private function _runBare(): void~' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare('; fi + if [ "${{ matrix.type }}" = "Phpunit Burn" ]; then sed -i 's~public function runBare(): void~public function runBare(): void { gc_collect_cycles(); gc_collect_cycles(); $memDiffs = array_fill(0, '"$(if [ \"$GITHUB_EVENT_NAME\" == \"schedule\" ]; then echo 64; else echo 16; fi)"', 0); for ($i = -1; $i < count($memDiffs); ++$i) { $this->_runBare(); gc_collect_cycles(); gc_collect_cycles(); $mem = memory_get_usage(); if ($i !== -1) { $memDiffs[$i] = $mem - $memPrev; } $memPrev = $mem; rsort($memDiffs); if (array_sum($memDiffs) >= 4096 * 1024 || $memDiffs[2] > 0) { $this->onNotSuccessfulTest(new AssertionFailedError("Memory leak detected! (" . implode(" + ", array_map(static fn ($v) => number_format($v / 1024, 3, ".", " "), array_filter($memDiffs))) . " KB, " . ($i + 2) . " iterations)")); } } } private function _runBare(): void~' vendor/phpunit/phpunit/src/Framework/TestCase.php && cat vendor/phpunit/phpunit/src/Framework/TestCase.php | grep '_runBare('; fi - name: Init run: | @@ -152,11 +152,11 @@ jobs: - name: "Run tests: SQLite" run: | php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-sqlite.cov; fi - - name: "Run tests: MySQL" - if: success() || failure() + - name: "Run tests: MySQL (only for cron)" + if: (success() || failure()) && github.event_name == 'schedule' env: DB_DSN: "mysql:host=mysql;dbname=atk4_test" DB_USER: atk4_test_user @@ -164,11 +164,11 @@ jobs: run: | sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mysql.cov; fi - - name: "Run tests: MariaDB (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' + - name: "Run tests: MariaDB" + if: success() || failure() env: DB_DSN: "mysql:host=mariadb;dbname=atk4_test" DB_USER: atk4_test_user @@ -176,7 +176,7 @@ jobs: run: | sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mariadb.cov; fi - name: "Run tests: PostgreSQL (only for cron)" @@ -188,7 +188,7 @@ jobs: run: | sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-postgres.cov; fi - name: "Run tests: MSSQL (only for cron)" @@ -200,20 +200,20 @@ jobs: run: | sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-mssql.cov; fi - name: "Run tests: Oracle (only for cron)" if: (success() || failure()) && github.event_name == 'schedule' env: - DB_DSN: "oci:dbname=oracle/xe" + DB_DSN: "oci:dbname=oracle/free" DB_USER: system DB_PASSWORD: atk4_pass NLS_LANG: AMERICAN_AMERICA.AL32UTF8 run: | sed -E "s~(\\\$db = new.+Persistence\\\\Sql)\(.+\);~\\1('$DB_DSN', '$DB_USER', '$DB_PASSWORD');~g" -i demos/db.default.php php demos/_demo-data/create-db.php - php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v + php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) --fail-on-warning --fail-on-risky $(if vendor/bin/phpunit --version | grep -q '^PHPUnit 9\.'; then echo -v; else echo --fail-on-notice --fail-on-deprecation --display-notices --display-deprecations --display-warnings --display-errors --display-incomplete --display-skipped; fi) if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-oracle.cov; fi - name: Upload coverage logs 1/2 (only for latest Phpunit) @@ -353,8 +353,8 @@ jobs: - name: Install PHP dependencies run: | - composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev - composer remove --no-interaction --no-update friendsofphp/php-cs-fixer --dev + composer remove --no-interaction --no-update phpunit/phpunit atk4/ergebnis-phpunit-slow-test-detector --dev + composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev composer remove --no-interaction --no-update phpstan/\* --dev if [ -n "$LOG_COVERAGE" ]; then composer require --no-interaction --no-install phpunit/phpcov; fi composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader @@ -383,8 +383,8 @@ jobs: php demos/_demo-data/create-db.php vendor/bin/behat -vv --config behat.yml.dist - - name: "Run tests: MySQL (only for coverage or cron)" - if: (success() || failure()) && (env.LOG_COVERAGE || github.event_name == 'schedule') + - name: "Run tests: MySQL (only for cron)" + if: (success() || failure()) && github.event_name == 'schedule' env: DB_DSN: "mysql:host=mysql;dbname=atk4_test" DB_USER: atk4_test_user @@ -394,8 +394,8 @@ jobs: php demos/_demo-data/create-db.php vendor/bin/behat -vv --config behat.yml.dist - - name: "Run tests: MariaDB (only for cron)" - if: (success() || failure()) && github.event_name == 'schedule' + - name: "Run tests: MariaDB (only for coverage or cron)" + if: (success() || failure()) && (env.LOG_COVERAGE || github.event_name == 'schedule') env: DB_DSN: "mysql:host=mariadb;dbname=atk4_test" DB_USER: atk4_test_user @@ -430,7 +430,7 @@ jobs: - name: "Run tests: Oracle (only for cron)" if: (success() || failure()) && github.event_name == 'schedule' env: - DB_DSN: "oci:dbname=oracle/xe" + DB_DSN: "oci:dbname=oracle/free" DB_USER: system DB_PASSWORD: atk4_pass NLS_LANG: AMERICAN_AMERICA.AL32UTF8 diff --git a/composer.json b/composer.json index 46a50acdf7..470797856a 100644 --- a/composer.json +++ b/composer.json @@ -68,17 +68,17 @@ }, "require-dev": { "atk4/behat-mink-selenium2-driver": "^1.6.2", + "atk4/ergebnis-phpunit-slow-test-detector": "^2.4", "behat/mink-extension": "^2.3.1", "ergebnis/composer-normalize": "^2.13", "friendsofphp/php-cs-fixer": "^3.0", "fzaninotto/faker": "^1.6", "guzzlehttp/guzzle": "^7.3", - "johnkary/phpunit-speedtrap": "^3.3", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.0", "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-strict-rules": "^1.3", - "phpunit/phpunit": "^9.5.5", + "phpunit/phpunit": "^9.5.5 || ^10.0", "symfony/process": "^4.4.30 || ^5.3.7 || ^6.0" }, "conflict": { diff --git a/phpstan.neon.dist b/phpstan.neon.dist index df112c68cf..d35a3ff7e4 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -16,6 +16,16 @@ parameters: - '~^Only booleans are allowed in .+, .+ given( on the (left|right) side)?\.~' - '~^Variable (static )?(property access|method call) on .+\.~' + # remove once PHPUnit 9.x support is removed + - + path: 'tests/DemosTest.php' + message: '~^Access to constant (STATUS_PASSED|STATUS_INCOMPLETE|STATUS_SKIPPED) on an unknown class PHPUnit\\Runner\\BaseTestRunner\.$~' + count: 3 + - + path: 'tests/DemosTest.php' + message: '~^Call to an undefined method Atk4\\Ui\\Tests\\DemosTest::(getName|getStatus)\(\)\.$~' + count: 4 + # TODO these rules are generated, this ignores should be fixed in the code # for level = 2 - diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a673114cd4..e61b4c2afa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,4 @@ - + tests @@ -16,10 +16,10 @@ require_session - - - - + + + + src tests @@ -27,6 +27,8 @@ src/Behat + + diff --git a/src/App.php b/src/App.php index 5d0246f4a1..5dda75d0bb 100644 --- a/src/App.php +++ b/src/App.php @@ -182,7 +182,7 @@ public function __construct(array $defaults = []) if ($this->catchExceptions) { set_exception_handler(\Closure::fromCallable([$this, 'caughtException'])); set_error_handler(static function (int $severity, string $msg, string $file, int $line): bool { - if ((error_reporting() & ~(\PHP_MAJOR_VERSION >= 8 ? 4437 : 0)) === 0) { + if ((error_reporting() & ~(\PHP_MAJOR_VERSION >= 8 ? (\E_ERROR | \E_PARSE | \E_CORE_ERROR | \E_COMPILE_ERROR | \E_USER_ERROR | \E_RECOVERABLE_ERROR) : 0)) === 0) { $isFirstFrame = true; foreach (array_slice(debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 10), 1) as $frame) { // allow to suppress any warning outside Atk4 diff --git a/src/Behat/CoverageUtil.php b/src/Behat/CoverageUtil.php index 1f801ebe38..096f122486 100644 --- a/src/Behat/CoverageUtil.php +++ b/src/Behat/CoverageUtil.php @@ -34,18 +34,18 @@ public static function startFromPhpunitConfig(string $phpunitConfigDir): void { $filter = new Filter(); - $phpunitCoverageConfig = simplexml_load_file($phpunitConfigDir . '/phpunit.xml.dist')->coverage; + $phpunitCoverageConfig = simplexml_load_file($phpunitConfigDir . '/phpunit.xml.dist')->source; foreach ($phpunitCoverageConfig->include->directory ?? [] as $path) { - $filter->includeDirectory($phpunitConfigDir . '/' . $path); + $filter->includeDirectory($phpunitConfigDir . '/' . $path); // @phpstan-ignore-line } foreach ($phpunitCoverageConfig->include->file ?? [] as $path) { $filter->includeFile($phpunitConfigDir . '/' . $path); } foreach ($phpunitCoverageConfig->exclude->directory ?? [] as $path) { - $filter->excludeDirectory($phpunitConfigDir . '/' . $path); + $filter->excludeDirectory($phpunitConfigDir . '/' . $path); // @phpstan-ignore-line } foreach ($phpunitCoverageConfig->exclude->file ?? [] as $path) { - $filter->excludeFile($phpunitConfigDir . '/' . $path); + $filter->excludeFile($phpunitConfigDir . '/' . $path); // @phpstan-ignore-line } static::start($filter); diff --git a/tests/AppTest.php b/tests/AppTest.php index 5cb57408cc..b0912fb6de 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -122,7 +122,7 @@ public function testEmptyRequestPathException(): void $this->createApp(['request' => $request]); } - public function provideUrlCases(): iterable + public static function provideUrlCases(): iterable { foreach (['/', '/page.html', '/d/', '/0/index.php'] as $requestPage) { yield [$requestPage, [], ['x'], [], 'x.php']; diff --git a/tests/DemosHttpTest.php b/tests/DemosHttpTest.php index 0266b3ec0a..ffd693fbad 100644 --- a/tests/DemosHttpTest.php +++ b/tests/DemosHttpTest.php @@ -135,7 +135,7 @@ public function testDemoLateOutputError(string $urlTrigger, string $expectedOutp self::assertSame($expectedOutput, $response->getBody()->getContents()); } - public function provideDemoLateOutputErrorCases(): iterable + public static function provideDemoLateOutputErrorCases(): iterable { $hOutput = "\n" . '!! FATAL UI ERROR: Headers already sent, more headers cannot be set at this stage !!' . "\n"; $oOutput = 'unmanaged output' . "\n" . '!! FATAL UI ERROR: Unexpected output detected !!' . "\n"; diff --git a/tests/DemosTest.php b/tests/DemosTest.php index 00747b6c9f..dccb9ef86e 100644 --- a/tests/DemosTest.php +++ b/tests/DemosTest.php @@ -14,6 +14,7 @@ use Atk4\Ui\Layout; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; +use PHPUnit\Runner\BaseTestRunner; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -31,6 +32,7 @@ class DemosTest extends TestCase private static ?Persistence $_db = null; + /** @var array */ private static array $_failedParentTests = []; public static function setUpBeforeClass(): void @@ -72,15 +74,12 @@ protected function setUp(): void } } - protected function onNotSuccessfulTest(\Throwable $t): void + #[\Override] + protected function _onNotSuccessfulTest(\Throwable $t): void { - if (!in_array($this->getStatus(), [ - \PHPUnit\Runner\BaseTestRunner::STATUS_PASSED, - \PHPUnit\Runner\BaseTestRunner::STATUS_SKIPPED, - \PHPUnit\Runner\BaseTestRunner::STATUS_INCOMPLETE, - ], true)) { - if (!isset(self::$_failedParentTests[$this->getName()])) { - self::$_failedParentTests[$this->getName()] = $this->getStatus(); + if (self::isPhpunit9x() ? !in_array($this->getStatus(), [BaseTestRunner::STATUS_PASSED, BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE], true) : !$this->status()->isSuccess() && !$this->status()->isSkipped() && !$this->status()->isIncomplete()) { + if (!isset(self::$_failedParentTests[self::isPhpunit9x() ? $this->getName() : $this->nameWithDataSet()])) { + self::$_failedParentTests[self::isPhpunit9x() ? $this->getName() : $this->nameWithDataSet()] = self::isPhpunit9x() ? $this->getStatus() : $this->status()->asInt(); } else { self::markTestIncomplete('Test failed, but non-HTTP test failed too, fix it first'); } @@ -262,7 +261,7 @@ protected function getPathWithAppVars(string $path): string /** @var string */ protected $regexSse = '~^(id|event|data).*$~m'; - public function provideDemosStatusAndHtmlResponseCases(): iterable + public static function provideDemosStatusAndHtmlResponseCases(): iterable { $excludeDirs = ['_demo-data', '_includes']; $excludeFiles = ['_unit-test/stream.php', 'layout/layouts_error.php']; @@ -331,7 +330,7 @@ public function testDemoResponseError(): void self::assertStringContainsString('Property for specified object is not defined', $response->getBody()->getContents()); } - public function provideDemoGetCases(): iterable + public static function provideDemoGetCases(): iterable { yield ['others/sticky.php?xx=YEY']; yield ['others/sticky.php?c=OHO']; @@ -401,7 +400,7 @@ public function testWizard(): void self::assertMatchesRegularExpression($this->regexHtml, $response->getBody()->getContents()); } - public function provideDemoAssertJsonResponseCases(): iterable + public static function provideDemoAssertJsonResponseCases(): iterable { // simple reload yield ['_unit-test/reload.php?__atk_reload=reload']; @@ -442,7 +441,7 @@ public function testDemoAssertJsonResponse(string $path, string $expectedExcepti } } - public function provideDemoAssertSseResponseCases(): iterable + public static function provideDemoAssertSseResponseCases(): iterable { yield ['_unit-test/sse.php?' . Callback::URL_QUERY_TRIGGER_PREFIX . 'see_test=ajax&' . Callback::URL_QUERY_TARGET . '=1&__atk_sse=1']; yield ['_unit-test/console.php?' . Callback::URL_QUERY_TRIGGER_PREFIX . 'console_test=ajax&' . Callback::URL_QUERY_TARGET . '=1&__atk_sse=1']; @@ -481,7 +480,7 @@ public function testDemoAssertSseResponse(string $path): void } } - public function provideDemoAssertJsonResponsePostCases(): iterable + public static function provideDemoAssertJsonResponsePostCases(): iterable { yield [ '_unit-test/post.php?' . Callback::URL_QUERY_TRIGGER_PREFIX . 'test_submit=ajax&' . Callback::URL_QUERY_TARGET . '=test_submit', @@ -518,7 +517,7 @@ public function testDemoCallbackError(string $path, string $expectedExceptionMes self::assertStringContainsString($expectedExceptionMessage, $responseBodyStr); } - public function provideDemoCallbackErrorCases(): iterable + public static function provideDemoCallbackErrorCases(): iterable { yield [ '_unit-test/callback-nested.php?err_sub_loader&' . Callback::URL_QUERY_TRIGGER_PREFIX . 'trigger_main_loader=callback&' . Callback::URL_QUERY_TARGET . '=non_existing_target', diff --git a/tests/PaginatorTest.php b/tests/PaginatorTest.php index c2d84ce0ab..7ddb27369c 100644 --- a/tests/PaginatorTest.php +++ b/tests/PaginatorTest.php @@ -9,7 +9,7 @@ class PaginatorTest extends TestCase { - public function providePaginatorCases(): iterable + public static function providePaginatorCases(): iterable { yield [1, 1, 1, [1]]; yield [1, 4, 1, [1]]; diff --git a/tests/PersistenceUiTest.php b/tests/PersistenceUiTest.php index 5551fe48b7..bedc7de66e 100644 --- a/tests/PersistenceUiTest.php +++ b/tests/PersistenceUiTest.php @@ -46,7 +46,7 @@ public function testTypecast(array $persistenceSeed, array $fieldSeed, $phpValue } } - public function providerTypecastBidirectional(): iterable + public static function providerTypecastBidirectional(): iterable { $fixSpaceToNbspFx = static fn (string $v) => str_replace(' ', "\u{00a0}", $v); @@ -131,7 +131,7 @@ public function providerTypecastBidirectional(): iterable } } - public function providerTypecastLoadOnly(): iterable + public static function providerTypecastLoadOnly(): iterable { foreach (['integer', 'float', 'boolean', 'date', 'time', 'datetime', 'atk4_money'] as $type) { yield [[], ['type' => $type], null, '', false]; diff --git a/tests/ViewTest.php b/tests/ViewTest.php index 3dc3959b89..8122c8275b 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -141,7 +141,7 @@ public function testSetNotClosureError(string $class): void /** * @return iterable}> */ - public function provideSetNotClosureErrorCases(): iterable + public static function provideSetNotClosureErrorCases(): iterable { yield [Console::class]; yield [JsCallback::class];