diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 314fd0ba1ba..56ec158b031 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,7 +26,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.3 - extensions: none, curl, dom, json, libxml, mbstring, openssl, phar, soap, tokenizer, xml, xmlwriter + extensions: none, ctype, curl, dom, json, libxml, mbstring, openssl, phar, soap, tokenizer, xml, xmlwriter coverage: none tools: none @@ -94,7 +94,7 @@ jobs: runs-on: ${{ matrix.os }} env: - PHP_EXTENSIONS: none, curl, dom, json, libxml, mbstring, openssl, phar, soap, tokenizer, xml, xmlwriter + PHP_EXTENSIONS: none, ctype, curl, dom, json, libxml, mbstring, openssl, phar, soap, tokenizer, xml, xmlwriter PHP_INI_VALUES: memory_limit=-1, assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On strategy: @@ -141,7 +141,7 @@ jobs: runs-on: ${{ matrix.os }} env: - PHP_EXTENSIONS: none, curl, dom, json, libxml, mbstring, openssl, phar, soap, tokenizer, xml, xmlwriter + PHP_EXTENSIONS: none, ctype, curl, dom, json, libxml, mbstring, openssl, phar, soap, tokenizer, xml, xmlwriter PHP_INI_VALUES: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On strategy: @@ -197,7 +197,7 @@ jobs: with: php-version: 8.3 coverage: pcov - extensions: none, curl, dom, json, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter + extensions: none, ctype, curl, dom, json, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On tools: none @@ -221,7 +221,7 @@ jobs: runs-on: ubuntu-latest env: - PHP_EXTENSIONS: none, dom, json, fileinfo, iconv, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter + PHP_EXTENSIONS: none, ctype, dom, json, fileinfo, iconv, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter PHP_INI_VALUES: assert.exception=1, phar.readonly=0, zend.assertions=1 steps: @@ -265,7 +265,7 @@ jobs: runs-on: ubuntu-latest env: - PHP_EXTENSIONS: none, curl, dom, json, fileinfo, iconv, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter + PHP_EXTENSIONS: none, ctype, curl, dom, json, fileinfo, iconv, libxml, mbstring, phar, soap, tokenizer, xml, xmlwriter PHP_INI_VALUES: assert.exception=1, phar.readonly=0, zend.assertions=1 strategy: diff --git a/.phive/phars.xml b/.phive/phars.xml index 88a0f10a4f5..d1193aa9517 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,8 +1,8 @@ - - + + diff --git a/.psalm/baseline.xml b/.psalm/baseline.xml index 9bf62d54447..8fce0ef6c11 100644 --- a/.psalm/baseline.xml +++ b/.psalm/baseline.xml @@ -1,5 +1,5 @@ - + notify @@ -1122,6 +1122,14 @@ hasCacheResultFile + + + $result + + + ]]> + + diff --git a/ChangeLog-10.5.md b/ChangeLog-10.5.md index af8e707128d..067699db94d 100644 --- a/ChangeLog-10.5.md +++ b/ChangeLog-10.5.md @@ -2,6 +2,35 @@ All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [10.5.8] - 2024-01-19 + +### Fixed + +* [#5673](https://github.com/sebastianbergmann/phpunit/issues/5673): Confusing error message when migration of a configuration is requested that does not need to be migrated + +## [10.5.7] - 2024-01-14 + +### Fixed + +* [#5662](https://github.com/sebastianbergmann/phpunit/issues/5662): PHPUnit errors out on startup when the `ctype` extension is not loaded but a polyfill for it was installed + +## [10.5.6] - 2024-01-13 + +### Added + +* Added the `--debug` CLI option as an alias for `--no-output --log-events-text php://stdout` + +### Fixed + +* [#5455](https://github.com/sebastianbergmann/phpunit/issues/5455): `willReturnCallback()` does not pass unknown named variadic arguments to callback +* [#5488](https://github.com/sebastianbergmann/phpunit/issues/5488): Details about tests that are considered risky are not displayed when the TestDox result printer is used +* [#5516](https://github.com/sebastianbergmann/phpunit/issues/5516): Assertions that use the `LogicalNot` constraint (`assertNotEquals()`, `assertStringNotContainsString()`, ...) can generate confusing failure messages +* [#5518](https://github.com/sebastianbergmann/phpunit/issues/5518): Details about deprecations, notices, and warnings are not displayed when the TestDox result printer is used +* [#5574](https://github.com/sebastianbergmann/phpunit/issues/5574): Wrong backtrace line is reported +* [#5633](https://github.com/sebastianbergmann/phpunit/pull/5633): `--log-events-text` and `--log-events-verbose-text` CLI options do not handle absolute and relative paths +* [#5634](https://github.com/sebastianbergmann/phpunit/pull/5634): Exceptions in the destructor of a test double are ignored +* [#5641](https://github.com/sebastianbergmann/phpunit/issues/5641): The `TestSuite` value object returned by `TestSuite\Filtered::testSuite()` contains all tests instead of only the filtered tests + ## [10.5.5] - 2023-12-27 ### Fixed @@ -62,6 +91,9 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi * [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification +[10.5.8]: https://github.com/sebastianbergmann/phpunit/compare/10.5.7...10.5.8 +[10.5.7]: https://github.com/sebastianbergmann/phpunit/compare/10.5.6...10.5.7 +[10.5.6]: https://github.com/sebastianbergmann/phpunit/compare/10.5.5...10.5.6 [10.5.5]: https://github.com/sebastianbergmann/phpunit/compare/10.5.4...10.5.5 [10.5.4]: https://github.com/sebastianbergmann/phpunit/compare/10.5.3...10.5.4 [10.5.3]: https://github.com/sebastianbergmann/phpunit/compare/10.5.2...10.5.3 diff --git a/LICENSE b/LICENSE index 73e955128f6..bdb57ec66f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2001-2023, Sebastian Bergmann +Copyright (c) 2001-2024, Sebastian Bergmann All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/build.xml b/build.xml index ef98e0dee7d..9b452126184 100644 --- a/build.xml +++ b/build.xml @@ -325,6 +325,7 @@ + @@ -344,6 +345,7 @@ + diff --git a/build/templates/binary-phar-autoload.php.in b/build/templates/binary-phar-autoload.php.in index e6595ae0f77..9d2e77cad1f 100644 --- a/build/templates/binary-phar-autoload.php.in +++ b/build/templates/binary-phar-autoload.php.in @@ -30,7 +30,7 @@ if (version_compare('8.1.0', PHP_VERSION, '>')) { die(1); } -$requiredExtensions = ['dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter']; +$requiredExtensions = ['ctype', 'dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter']; $unavailableExtensions = array_filter( $requiredExtensions, diff --git a/composer.lock b/composer.lock index d41087fdae7..f0eebd96f99 100644 --- a/composer.lock +++ b/composer.lock @@ -67,25 +67,27 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v5.0.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4a21235f7e56e713259a6f76bf4b5ea08502b9dc", + "reference": "4a21235f7e56e713259a6f76bf4b5ea08502b9dc", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -93,7 +95,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -117,9 +119,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.0" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-01-07T17:17:35+00:00" }, { "name": "phar-io/manifest", diff --git a/phpunit b/phpunit index 624c8b4d7b0..95aaf92d9ea 100755 --- a/phpunit +++ b/phpunit @@ -38,31 +38,6 @@ if (version_compare('8.1.0', PHP_VERSION, '>')) { die(1); } -$requiredExtensions = ['dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter']; - -$unavailableExtensions = array_filter( - $requiredExtensions, - static function ($extension) { - return !extension_loaded($extension); - } -); - -if ([] !== $unavailableExtensions) { - fwrite( - STDERR, - sprintf( - 'PHPUnit requires the "%s" extensions, but the "%s" %s not available.' . PHP_EOL, - implode('", "', $requiredExtensions), - implode('", "', $unavailableExtensions), - count($unavailableExtensions) === 1 ? 'extension is' : 'extensions are' - ) - ); - - die(1); -} - -unset($requiredExtensions, $unavailableExtensions); - if (!ini_get('date.timezone')) { ini_set('date.timezone', 'UTC'); } @@ -96,4 +71,34 @@ if (!defined('PHPUNIT_COMPOSER_INSTALL')) { require PHPUNIT_COMPOSER_INSTALL; +$requiredExtensions = ['dom', 'json', 'libxml', 'mbstring', 'tokenizer', 'xml', 'xmlwriter']; + +$unavailableExtensions = array_filter( + $requiredExtensions, + static function ($extension) { + return !extension_loaded($extension); + } +); + +// Workaround for https://github.com/sebastianbergmann/phpunit/issues/5662 +if (!function_exists('ctype_alnum')) { + $unavailableExtensions[] = 'ctype'; +} + +if ([] !== $unavailableExtensions) { + fwrite( + STDERR, + sprintf( + 'PHPUnit requires the "%s" extensions, but the "%s" %s not available.' . PHP_EOL, + implode('", "', $requiredExtensions), + implode('", "', $unavailableExtensions), + count($unavailableExtensions) === 1 ? 'extension is' : 'extensions are' + ) + ); + + die(1); +} + +unset($requiredExtensions, $unavailableExtensions); + exit((new PHPUnit\TextUI\Application)->run($_SERVER['argv'])); diff --git a/schema/10.1.xsd b/schema/10.1.xsd new file mode 100644 index 00000000000..1b190c21b90 --- /dev/null +++ b/schema/10.1.xsd @@ -0,0 +1,312 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 10.1 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/10.2.xsd b/schema/10.2.xsd new file mode 100644 index 00000000000..269b7a3aeb4 --- /dev/null +++ b/schema/10.2.xsd @@ -0,0 +1,319 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 10.2 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/10.3.xsd b/schema/10.3.xsd new file mode 100644 index 00000000000..03a54ee0b08 --- /dev/null +++ b/schema/10.3.xsd @@ -0,0 +1,321 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 10.3 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/10.4.xsd b/schema/10.4.xsd new file mode 100644 index 00000000000..bd22b2ca2a7 --- /dev/null +++ b/schema/10.4.xsd @@ -0,0 +1,322 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 10.4 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/8.5.xsd b/schema/8.5.xsd index 5881bafec62..75e22289471 100644 --- a/schema/8.5.xsd +++ b/schema/8.5.xsd @@ -244,7 +244,7 @@ - + @@ -309,8 +309,10 @@ - - + + + + diff --git a/schema/9.0.xsd b/schema/9.0.xsd new file mode 100644 index 00000000000..6db04c09789 --- /dev/null +++ b/schema/9.0.xsd @@ -0,0 +1,315 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 9.0 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/9.1.xsd b/schema/9.1.xsd new file mode 100644 index 00000000000..b10d30b4619 --- /dev/null +++ b/schema/9.1.xsd @@ -0,0 +1,317 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 9.0 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/9.2.xsd b/schema/9.2.xsd index 883f21bc0d1..d770e8b03bd 100644 --- a/schema/9.2.xsd +++ b/schema/9.2.xsd @@ -163,7 +163,7 @@ - + @@ -248,7 +248,7 @@ - + @@ -282,7 +282,7 @@ - + @@ -310,7 +310,7 @@ - + diff --git a/schema/9.3.xsd b/schema/9.3.xsd new file mode 100644 index 00000000000..638f663ac7b --- /dev/null +++ b/schema/9.3.xsd @@ -0,0 +1,327 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 9.3 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/9.4.xsd b/schema/9.4.xsd new file mode 100644 index 00000000000..75a91e832f8 --- /dev/null +++ b/schema/9.4.xsd @@ -0,0 +1,328 @@ + + + + + This Schema file defines the rules by which the XML configuration file of PHPUnit 9.4 may be structured. + + + + + + Root Element + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The main type specifying the document structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/9.5.xsd b/schema/9.5.xsd index a25d683a434..eabefac30b0 100644 --- a/schema/9.5.xsd +++ b/schema/9.5.xsd @@ -213,7 +213,7 @@ - + @@ -279,8 +279,10 @@ - - + + + + diff --git a/src/Event/Dispatcher/DirectDispatcher.php b/src/Event/Dispatcher/DirectDispatcher.php index 042b24180c2..8176229dc10 100644 --- a/src/Event/Dispatcher/DirectDispatcher.php +++ b/src/Event/Dispatcher/DirectDispatcher.php @@ -86,9 +86,11 @@ public function dispatch(Event $event): void foreach ($this->tracers as $tracer) { try { $tracer->trace($event); + // @codeCoverageIgnoreStart } catch (Throwable $t) { $this->handleThrowable($t); } + // @codeCoverageIgnoreEnd } if (!array_key_exists($eventClassName, $this->subscribers)) { @@ -122,7 +124,9 @@ public function handleThrowable(Throwable $t): void return; } + // @codeCoverageIgnoreStart throw $t; + // @codeCoverageIgnoreEnd } private function isThrowableFromThirdPartySubscriber(Throwable $t): bool diff --git a/src/Event/Emitter/DispatchingEmitter.php b/src/Event/Emitter/DispatchingEmitter.php index 254b722544a..27af2c586ec 100644 --- a/src/Event/Emitter/DispatchingEmitter.php +++ b/src/Event/Emitter/DispatchingEmitter.php @@ -336,7 +336,7 @@ public function testPreparationFailed(Code\Test $test): void * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testBeforeFirstTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void + public function testBeforeFirstTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void { $this->dispatcher->dispatch( new Test\BeforeFirstTestMethodCalled( @@ -353,7 +353,7 @@ public function testBeforeFirstTestMethodCalled(string $testClassName, Code\Clas * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testBeforeFirstTestMethodErrored(string $testClassName, Code\ClassMethod $calledMethod, Throwable $throwable): void + public function testBeforeFirstTestMethodErrored(string $testClassName, ClassMethod $calledMethod, Throwable $throwable): void { $this->dispatcher->dispatch( new Test\BeforeFirstTestMethodErrored( @@ -371,7 +371,7 @@ public function testBeforeFirstTestMethodErrored(string $testClassName, Code\Cla * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testBeforeFirstTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void + public function testBeforeFirstTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void { $this->dispatcher->dispatch( new Test\BeforeFirstTestMethodFinished( @@ -388,7 +388,7 @@ public function testBeforeFirstTestMethodFinished(string $testClassName, Code\Cl * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testBeforeTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void + public function testBeforeTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void { $this->dispatcher->dispatch( new Test\BeforeTestMethodCalled( @@ -405,7 +405,7 @@ public function testBeforeTestMethodCalled(string $testClassName, Code\ClassMeth * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testBeforeTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void + public function testBeforeTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void { $this->dispatcher->dispatch( new Test\BeforeTestMethodFinished( @@ -422,7 +422,7 @@ public function testBeforeTestMethodFinished(string $testClassName, Code\ClassMe * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testPreConditionCalled(string $testClassName, Code\ClassMethod $calledMethod): void + public function testPreConditionCalled(string $testClassName, ClassMethod $calledMethod): void { $this->dispatcher->dispatch( new Test\PreConditionCalled( @@ -439,7 +439,7 @@ public function testPreConditionCalled(string $testClassName, Code\ClassMethod $ * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testPreConditionFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void + public function testPreConditionFinished(string $testClassName, ClassMethod ...$calledMethods): void { $this->dispatcher->dispatch( new Test\PreConditionFinished( @@ -1010,7 +1010,7 @@ public function testFinished(Code\Test $test, int $numberOfAssertionsPerformed): * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testPostConditionCalled(string $testClassName, Code\ClassMethod $calledMethod): void + public function testPostConditionCalled(string $testClassName, ClassMethod $calledMethod): void { $this->dispatcher->dispatch( new Test\PostConditionCalled( @@ -1027,7 +1027,7 @@ public function testPostConditionCalled(string $testClassName, Code\ClassMethod * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testPostConditionFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void + public function testPostConditionFinished(string $testClassName, ClassMethod ...$calledMethods): void { $this->dispatcher->dispatch( new Test\PostConditionFinished( @@ -1044,7 +1044,7 @@ public function testPostConditionFinished(string $testClassName, Code\ClassMetho * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testAfterTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void + public function testAfterTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void { $this->dispatcher->dispatch( new Test\AfterTestMethodCalled( @@ -1061,7 +1061,7 @@ public function testAfterTestMethodCalled(string $testClassName, Code\ClassMetho * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testAfterTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void + public function testAfterTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void { $this->dispatcher->dispatch( new Test\AfterTestMethodFinished( @@ -1078,7 +1078,7 @@ public function testAfterTestMethodFinished(string $testClassName, Code\ClassMet * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testAfterLastTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void + public function testAfterLastTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void { $this->dispatcher->dispatch( new Test\AfterLastTestMethodCalled( @@ -1095,7 +1095,7 @@ public function testAfterLastTestMethodCalled(string $testClassName, Code\ClassM * @throws InvalidArgumentException * @throws UnknownEventTypeException */ - public function testAfterLastTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void + public function testAfterLastTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void { $this->dispatcher->dispatch( new Test\AfterLastTestMethodFinished( diff --git a/src/Event/Emitter/Emitter.php b/src/Event/Emitter/Emitter.php index f56d64b8c9d..c85b267526e 100644 --- a/src/Event/Emitter/Emitter.php +++ b/src/Event/Emitter/Emitter.php @@ -76,37 +76,37 @@ public function testPreparationFailed(Code\Test $test): void; /** * @psalm-param class-string $testClassName */ - public function testBeforeFirstTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void; + public function testBeforeFirstTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void; /** * @psalm-param class-string $testClassName */ - public function testBeforeFirstTestMethodErrored(string $testClassName, Code\ClassMethod $calledMethod, Throwable $throwable): void; + public function testBeforeFirstTestMethodErrored(string $testClassName, ClassMethod $calledMethod, Throwable $throwable): void; /** * @psalm-param class-string $testClassName */ - public function testBeforeFirstTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void; + public function testBeforeFirstTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void; /** * @psalm-param class-string $testClassName */ - public function testBeforeTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void; + public function testBeforeTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void; /** * @psalm-param class-string $testClassName */ - public function testBeforeTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void; + public function testBeforeTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void; /** * @psalm-param class-string $testClassName */ - public function testPreConditionCalled(string $testClassName, Code\ClassMethod $calledMethod): void; + public function testPreConditionCalled(string $testClassName, ClassMethod $calledMethod): void; /** * @psalm-param class-string $testClassName */ - public function testPreConditionFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void; + public function testPreConditionFinished(string $testClassName, ClassMethod ...$calledMethods): void; public function testPrepared(Code\Test $test): void; @@ -263,32 +263,32 @@ public function testFinished(Code\Test $test, int $numberOfAssertionsPerformed): /** * @psalm-param class-string $testClassName */ - public function testPostConditionCalled(string $testClassName, Code\ClassMethod $calledMethod): void; + public function testPostConditionCalled(string $testClassName, ClassMethod $calledMethod): void; /** * @psalm-param class-string $testClassName */ - public function testPostConditionFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void; + public function testPostConditionFinished(string $testClassName, ClassMethod ...$calledMethods): void; /** * @psalm-param class-string $testClassName */ - public function testAfterTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void; + public function testAfterTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void; /** * @psalm-param class-string $testClassName */ - public function testAfterTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void; + public function testAfterTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void; /** * @psalm-param class-string $testClassName */ - public function testAfterLastTestMethodCalled(string $testClassName, Code\ClassMethod $calledMethod): void; + public function testAfterLastTestMethodCalled(string $testClassName, ClassMethod $calledMethod): void; /** * @psalm-param class-string $testClassName */ - public function testAfterLastTestMethodFinished(string $testClassName, Code\ClassMethod ...$calledMethods): void; + public function testAfterLastTestMethodFinished(string $testClassName, ClassMethod ...$calledMethods): void; public function testSuiteFinished(TestSuite $testSuite): void; diff --git a/src/Event/Facade.php b/src/Event/Facade.php index bda44484acd..cd1e1ff9534 100644 --- a/src/Event/Facade.php +++ b/src/Event/Facade.php @@ -81,7 +81,11 @@ public function registerTracer(Tracer\Tracer $tracer): void $this->deferredDispatcher()->registerTracer($tracer); } - /** @noinspection PhpUnused */ + /** + * @codeCoverageIgnore + * + * @noinspection PhpUnused + */ public function initForIsolation(HRTime $offset, bool $exportObjects): CollectingDispatcher { $dispatcher = new CollectingDispatcher; @@ -258,7 +262,9 @@ private function registerDefaultTypes(TypeMap $typeMap): void private function garbageCollectorStatusProvider(): Telemetry\GarbageCollectorStatusProvider { if (!isset(gc_status()['running'])) { + // @codeCoverageIgnoreStart return new Php81GarbageCollectorStatusProvider; + // @codeCoverageIgnoreEnd } return new Php83GarbageCollectorStatusProvider; diff --git a/src/Event/Value/Telemetry/Php81GarbageCollectorStatusProvider.php b/src/Event/Value/Telemetry/Php81GarbageCollectorStatusProvider.php index 335a7e245ef..48d2afab8f6 100644 --- a/src/Event/Value/Telemetry/Php81GarbageCollectorStatusProvider.php +++ b/src/Event/Value/Telemetry/Php81GarbageCollectorStatusProvider.php @@ -13,6 +13,8 @@ /** * @internal This class is not covered by the backward compatibility promise for PHPUnit + * + * @codeCoverageIgnore */ final class Php81GarbageCollectorStatusProvider implements GarbageCollectorStatusProvider { diff --git a/src/Event/Value/Telemetry/SystemStopWatchWithOffset.php b/src/Event/Value/Telemetry/SystemStopWatchWithOffset.php index f4515787f36..86696afe628 100644 --- a/src/Event/Value/Telemetry/SystemStopWatchWithOffset.php +++ b/src/Event/Value/Telemetry/SystemStopWatchWithOffset.php @@ -14,6 +14,8 @@ /** * @internal This class is not covered by the backward compatibility promise for PHPUnit + * + * @codeCoverageIgnore */ final class SystemStopWatchWithOffset implements StopWatch { diff --git a/src/Event/Value/TestSuite/TestSuiteBuilder.php b/src/Event/Value/TestSuite/TestSuiteBuilder.php index c8988693076..1687d5aa041 100644 --- a/src/Event/Value/TestSuite/TestSuiteBuilder.php +++ b/src/Event/Value/TestSuite/TestSuiteBuilder.php @@ -105,9 +105,9 @@ public static function from(FrameworkTestSuite $testSuite): TestSuite /** * @psalm-param list $tests */ - private static function process(FrameworkTestSuite $testSuite, &$tests): void + private static function process(FrameworkTestSuite $testSuite, array &$tests): void { - foreach ($testSuite->tests() as $test) { + foreach ($testSuite->getIterator() as $test) { if ($test instanceof FrameworkTestSuite) { self::process($test, $tests); diff --git a/src/Event/Value/ThrowableBuilder.php b/src/Event/Value/ThrowableBuilder.php index aed9144fb88..8d3b634ebdb 100644 --- a/src/Event/Value/ThrowableBuilder.php +++ b/src/Event/Value/ThrowableBuilder.php @@ -35,7 +35,7 @@ public static function from(\Throwable $t): Throwable $t::class, $t->getMessage(), ThrowableToStringMapper::map($t), - Filter::getFilteredStacktrace($t), + Filter::getFilteredStacktrace($t, false), $previous, ); } diff --git a/src/Framework/Constraint/IsIdentical.php b/src/Framework/Constraint/IsIdentical.php index 48be631731e..48ef3d64830 100644 --- a/src/Framework/Constraint/IsIdentical.php +++ b/src/Framework/Constraint/IsIdentical.php @@ -9,6 +9,8 @@ */ namespace PHPUnit\Framework\Constraint; +use function explode; +use function gettype; use function is_array; use function is_object; use function is_string; @@ -104,6 +106,10 @@ protected function failureDescription(mixed $other): string return 'two variables reference the same object'; } + if (explode(' ', gettype($this->value), 2)[0] === 'resource' && explode(' ', gettype($other), 2)[0] === 'resource') { + return 'two variables reference the same resource'; + } + if (is_string($this->value) && is_string($other)) { return 'two strings are identical'; } diff --git a/src/Framework/Constraint/Operator/LogicalNot.php b/src/Framework/Constraint/Operator/LogicalNot.php index 021afddd517..837e3a50ac1 100644 --- a/src/Framework/Constraint/Operator/LogicalNot.php +++ b/src/Framework/Constraint/Operator/LogicalNot.php @@ -51,6 +51,10 @@ public static function negate(string $string): string preg_match('/(\'[\w\W]*\')([\w\W]*)("[\w\W]*")/i', $string, $matches); + if (count($matches) === 0) { + preg_match('/(\'[\w\W]*\')([\w\W]*)(\'[\w\W]*\')/i', $string, $matches); + } + $positives = array_map( static fn (string $s) => '/\\b' . preg_quote($s, '/') . '/', $positives, diff --git a/src/Framework/MockObject/Generator/templates/doubled_method.tpl b/src/Framework/MockObject/Generator/templates/doubled_method.tpl index 8b4af38b3ed..8ecd412c213 100644 --- a/src/Framework/MockObject/Generator/templates/doubled_method.tpl +++ b/src/Framework/MockObject/Generator/templates/doubled_method.tpl @@ -1,6 +1,19 @@ {modifier} function {reference}{method_name}({arguments_decl}){return_declaration} {{deprecation} + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [{arguments_call}]; $__phpunit_count = func_num_args(); @@ -12,6 +25,8 @@ } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( '{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments} diff --git a/src/Framework/MockObject/Generator/templates/proxied_method.tpl b/src/Framework/MockObject/Generator/templates/proxied_method.tpl index 330cdcfc0b3..94db4665e83 100644 --- a/src/Framework/MockObject/Generator/templates/proxied_method.tpl +++ b/src/Framework/MockObject/Generator/templates/proxied_method.tpl @@ -1,6 +1,19 @@ {modifier} function {reference}{method_name}({arguments_decl}){return_declaration} { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [{arguments_call}]; $__phpunit_count = func_num_args(); @@ -12,6 +25,8 @@ } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( '{class_name}', '{method_name}', $__phpunit_arguments, '{return_type}', $this, {clone_arguments}, true diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 9f9c0b0dcdb..021336f305f 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -733,7 +733,14 @@ final public function runBare(): void } } - $this->mockObjects = []; + try { + $this->mockObjects = []; + } catch (Throwable $t) { + Event\Facade::emitter()->testErrored( + $this->valueObjectForEvents(), + Event\Code\ThrowableBuilder::from($t), + ); + } // Tear down the fixture. An exception raised in tearDown() will be // caught and passed on when no exception was raised before. diff --git a/src/Framework/TestStatus/Deprecation.php b/src/Framework/TestStatus/Deprecation.php index 2711760dc15..67ef6375966 100644 --- a/src/Framework/TestStatus/Deprecation.php +++ b/src/Framework/TestStatus/Deprecation.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Deprecation extends Known { diff --git a/src/Framework/TestStatus/Error.php b/src/Framework/TestStatus/Error.php index 6ddb3b1b35d..c7124295c00 100644 --- a/src/Framework/TestStatus/Error.php +++ b/src/Framework/TestStatus/Error.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Error extends Known { diff --git a/src/Framework/TestStatus/Failure.php b/src/Framework/TestStatus/Failure.php index 1bb1b0379a3..a6028a08419 100644 --- a/src/Framework/TestStatus/Failure.php +++ b/src/Framework/TestStatus/Failure.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Failure extends Known { diff --git a/src/Framework/TestStatus/Incomplete.php b/src/Framework/TestStatus/Incomplete.php index eff26721f1b..6305a5ccf5c 100644 --- a/src/Framework/TestStatus/Incomplete.php +++ b/src/Framework/TestStatus/Incomplete.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Incomplete extends Known { diff --git a/src/Framework/TestStatus/Known.php b/src/Framework/TestStatus/Known.php index b5d92b39857..b44955ea4d3 100644 --- a/src/Framework/TestStatus/Known.php +++ b/src/Framework/TestStatus/Known.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ abstract class Known extends TestStatus { diff --git a/src/Framework/TestStatus/Notice.php b/src/Framework/TestStatus/Notice.php index 1eb10761e22..28ab650e3d1 100644 --- a/src/Framework/TestStatus/Notice.php +++ b/src/Framework/TestStatus/Notice.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Notice extends Known { diff --git a/src/Framework/TestStatus/Risky.php b/src/Framework/TestStatus/Risky.php index bd0cb889028..b9708023f61 100644 --- a/src/Framework/TestStatus/Risky.php +++ b/src/Framework/TestStatus/Risky.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Risky extends Known { diff --git a/src/Framework/TestStatus/Skipped.php b/src/Framework/TestStatus/Skipped.php index 4c8aeaf9f5b..30dae7e480b 100644 --- a/src/Framework/TestStatus/Skipped.php +++ b/src/Framework/TestStatus/Skipped.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Skipped extends Known { diff --git a/src/Framework/TestStatus/Success.php b/src/Framework/TestStatus/Success.php index fb5c945ed69..18cc7c9397b 100644 --- a/src/Framework/TestStatus/Success.php +++ b/src/Framework/TestStatus/Success.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Success extends Known { diff --git a/src/Framework/TestStatus/TestStatus.php b/src/Framework/TestStatus/TestStatus.php index ab957de130e..fff96a546df 100644 --- a/src/Framework/TestStatus/TestStatus.php +++ b/src/Framework/TestStatus/TestStatus.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ abstract class TestStatus { diff --git a/src/Framework/TestStatus/Unknown.php b/src/Framework/TestStatus/Unknown.php index 245ec67ee30..258c75b75e7 100644 --- a/src/Framework/TestStatus/Unknown.php +++ b/src/Framework/TestStatus/Unknown.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Unknown extends TestStatus { diff --git a/src/Framework/TestStatus/Warning.php b/src/Framework/TestStatus/Warning.php index 7c31fa8f6bb..a07b5498f49 100644 --- a/src/Framework/TestStatus/Warning.php +++ b/src/Framework/TestStatus/Warning.php @@ -10,9 +10,9 @@ namespace PHPUnit\Framework\TestStatus; /** - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * * @psalm-immutable + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit */ final class Warning extends Known { diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index 15a144cfb2f..839a23e049f 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -463,7 +463,7 @@ public function isForTestClass(): bool } /** - * @throws \PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException + * @throws Event\TestData\MoreThanOneDataSetFromDataProviderException * @throws Exception */ protected function addTestMethod(ReflectionClass $class, ReflectionMethod $method): void diff --git a/src/Logging/EventLogger.php b/src/Logging/EventLogger.php index 559fb5ec83f..ced39945f16 100644 --- a/src/Logging/EventLogger.php +++ b/src/Logging/EventLogger.php @@ -12,9 +12,9 @@ use const FILE_APPEND; use const LOCK_EX; use const PHP_EOL; -use function explode; use function file_put_contents; use function implode; +use function preg_split; use function str_repeat; use function strlen; use PHPUnit\Event\Event; @@ -38,7 +38,7 @@ public function trace(Event $event): void { $telemetryInfo = $this->telemetryInfo($event); $indentation = PHP_EOL . str_repeat(' ', strlen($telemetryInfo)); - $lines = explode(PHP_EOL, $event->asString()); + $lines = preg_split('/\r\n|\r|\n/', $event->asString()); file_put_contents( $this->path, diff --git a/src/Logging/TestDox/PlainTextRenderer.php b/src/Logging/TestDox/PlainTextRenderer.php index 45d0c81df0d..9ddd8776993 100644 --- a/src/Logging/TestDox/PlainTextRenderer.php +++ b/src/Logging/TestDox/PlainTextRenderer.php @@ -50,13 +50,22 @@ private function reduce(TestResultCollection $tests): array foreach ($tests as $test) { $prettifiedMethodName = $test->test()->testDox()->prettifiedMethodName(); + $success = true; + + if ($test->status()->isError() || + $test->status()->isFailure() || + $test->status()->isIncomplete() || + $test->status()->isSkipped()) { + $success = false; + } + if (!isset($result[$prettifiedMethodName])) { - $result[$prettifiedMethodName] = $test->status()->isSuccess() ? 'x' : ' '; + $result[$prettifiedMethodName] = $success ? 'x' : ' '; continue; } - if ($test->status()->isSuccess()) { + if ($success) { continue; } diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredDeprecationSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredDeprecationSubscriber.php new file mode 100644 index 00000000000..43cde139b71 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredDeprecationSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\DeprecationTriggered; +use PHPUnit\Event\Test\DeprecationTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredDeprecationSubscriber extends Subscriber implements DeprecationTriggeredSubscriber +{ + public function notify(DeprecationTriggered $event): void + { + $this->collector()->testTriggeredDeprecation($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredNoticeSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredNoticeSubscriber.php new file mode 100644 index 00000000000..0346b3bc928 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredNoticeSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\NoticeTriggered; +use PHPUnit\Event\Test\NoticeTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredNoticeSubscriber extends Subscriber implements NoticeTriggeredSubscriber +{ + public function notify(NoticeTriggered $event): void + { + $this->collector()->testTriggeredNotice($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpDeprecationSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpDeprecationSubscriber.php new file mode 100644 index 00000000000..6b99e1b65f5 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpDeprecationSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\PhpDeprecationTriggered; +use PHPUnit\Event\Test\PhpDeprecationTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredPhpDeprecationSubscriber extends Subscriber implements PhpDeprecationTriggeredSubscriber +{ + public function notify(PhpDeprecationTriggered $event): void + { + $this->collector()->testTriggeredPhpDeprecation($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpNoticeSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpNoticeSubscriber.php new file mode 100644 index 00000000000..31c19f9d4b6 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpNoticeSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\PhpNoticeTriggered; +use PHPUnit\Event\Test\PhpNoticeTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredPhpNoticeSubscriber extends Subscriber implements PhpNoticeTriggeredSubscriber +{ + public function notify(PhpNoticeTriggered $event): void + { + $this->collector()->testTriggeredPhpNotice($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpWarningSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpWarningSubscriber.php new file mode 100644 index 00000000000..f479bd5f938 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpWarningSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\PhpWarningTriggered; +use PHPUnit\Event\Test\PhpWarningTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredPhpWarningSubscriber extends Subscriber implements PhpWarningTriggeredSubscriber +{ + public function notify(PhpWarningTriggered $event): void + { + $this->collector()->testTriggeredPhpWarning($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitDeprecationSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitDeprecationSubscriber.php new file mode 100644 index 00000000000..d6615b2c7e5 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitDeprecationSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\PhpunitDeprecationTriggered; +use PHPUnit\Event\Test\PhpunitDeprecationTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredPhpunitDeprecationSubscriber extends Subscriber implements PhpunitDeprecationTriggeredSubscriber +{ + public function notify(PhpunitDeprecationTriggered $event): void + { + $this->collector()->testTriggeredPhpunitDeprecation($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitErrorSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitErrorSubscriber.php new file mode 100644 index 00000000000..85020c54206 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitErrorSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\PhpunitErrorTriggered; +use PHPUnit\Event\Test\PhpunitErrorTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredPhpunitErrorSubscriber extends Subscriber implements PhpunitErrorTriggeredSubscriber +{ + public function notify(PhpunitErrorTriggered $event): void + { + $this->collector()->testTriggeredPhpunitError($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitWarningSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitWarningSubscriber.php new file mode 100644 index 00000000000..28294e8f89a --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredPhpunitWarningSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\PhpunitWarningTriggered; +use PHPUnit\Event\Test\PhpunitWarningTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredPhpunitWarningSubscriber extends Subscriber implements PhpunitWarningTriggeredSubscriber +{ + public function notify(PhpunitWarningTriggered $event): void + { + $this->collector()->testTriggeredPhpunitWarning($event); + } +} diff --git a/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredWarningSubscriber.php b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredWarningSubscriber.php new file mode 100644 index 00000000000..600ceb07264 --- /dev/null +++ b/src/Logging/TestDox/TestResult/Subscriber/TestTriggeredWarningSubscriber.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Logging\TestDox; + +use PHPUnit\Event\Test\WarningTriggered; +use PHPUnit\Event\Test\WarningTriggeredSubscriber; + +/** + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final class TestTriggeredWarningSubscriber extends Subscriber implements WarningTriggeredSubscriber +{ + public function notify(WarningTriggered $event): void + { + $this->collector()->testTriggeredWarning($event); + } +} diff --git a/src/Logging/TestDox/TestResult/TestResultCollector.php b/src/Logging/TestDox/TestResult/TestResultCollector.php index 63ba35d4b6c..4417854d943 100644 --- a/src/Logging/TestDox/TestResult/TestResultCollector.php +++ b/src/Logging/TestDox/TestResult/TestResultCollector.php @@ -22,13 +22,22 @@ use PHPUnit\Event\Facade; use PHPUnit\Event\InvalidArgumentException; use PHPUnit\Event\Test\ConsideredRisky; +use PHPUnit\Event\Test\DeprecationTriggered; use PHPUnit\Event\Test\Errored; use PHPUnit\Event\Test\Failed; use PHPUnit\Event\Test\Finished; use PHPUnit\Event\Test\MarkedIncomplete; +use PHPUnit\Event\Test\NoticeTriggered; use PHPUnit\Event\Test\Passed; +use PHPUnit\Event\Test\PhpDeprecationTriggered; +use PHPUnit\Event\Test\PhpNoticeTriggered; +use PHPUnit\Event\Test\PhpunitDeprecationTriggered; +use PHPUnit\Event\Test\PhpunitErrorTriggered; +use PHPUnit\Event\Test\PhpunitWarningTriggered; +use PHPUnit\Event\Test\PhpWarningTriggered; use PHPUnit\Event\Test\Prepared; use PHPUnit\Event\Test\Skipped; +use PHPUnit\Event\Test\WarningTriggered; use PHPUnit\Event\UnknownSubscriberTypeException; use PHPUnit\Framework\TestStatus\TestStatus; use PHPUnit\Logging\TestDox\TestResult as TestDoxTestMethod; @@ -155,23 +164,117 @@ public function testPassed(Passed $event): void return; } - $this->status = TestStatus::success(); + $this->updateTestStatus(TestStatus::success()); } public function testSkipped(Skipped $event): void { - $this->status = TestStatus::skipped($event->message()); + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::skipped($event->message())); } public function testMarkedIncomplete(MarkedIncomplete $event): void { - $this->status = TestStatus::incomplete($event->throwable()->message()); + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::incomplete($event->throwable()->message())); + $this->throwable = $event->throwable(); } public function testConsideredRisky(ConsideredRisky $event): void { - $this->status = TestStatus::risky($event->message()); + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::risky()); + } + + public function testTriggeredDeprecation(DeprecationTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::deprecation()); + } + + public function testTriggeredNotice(NoticeTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::notice()); + } + + public function testTriggeredWarning(WarningTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::warning()); + } + + public function testTriggeredPhpDeprecation(PhpDeprecationTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::deprecation()); + } + + public function testTriggeredPhpNotice(PhpNoticeTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::notice()); + } + + public function testTriggeredPhpWarning(PhpWarningTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::warning()); + } + + public function testTriggeredPhpunitDeprecation(PhpunitDeprecationTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::deprecation()); + } + + public function testTriggeredPhpunitError(PhpunitErrorTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::error()); + } + + public function testTriggeredPhpunitWarning(PhpunitWarningTriggered $event): void + { + if (!$event->test()->isTestMethod()) { + return; + } + + $this->updateTestStatus(TestStatus::warning()); } /** @@ -216,6 +319,25 @@ private function registerSubscribers(Facade $facade): void new TestPassedSubscriber($this), new TestPreparedSubscriber($this), new TestSkippedSubscriber($this), + new TestTriggeredDeprecationSubscriber($this), + new TestTriggeredNoticeSubscriber($this), + new TestTriggeredPhpDeprecationSubscriber($this), + new TestTriggeredPhpNoticeSubscriber($this), + new TestTriggeredPhpunitDeprecationSubscriber($this), + new TestTriggeredPhpunitErrorSubscriber($this), + new TestTriggeredPhpunitWarningSubscriber($this), + new TestTriggeredPhpWarningSubscriber($this), + new TestTriggeredWarningSubscriber($this), ); } + + private function updateTestStatus(TestStatus $status): void + { + if ($this->status !== null && + $this->status->isMoreImportantThan($status)) { + return; + } + + $this->status = $status; + } } diff --git a/src/Runner/Extension/ExtensionBootstrapper.php b/src/Runner/Extension/ExtensionBootstrapper.php index fc8f317502a..5ee7306a861 100644 --- a/src/Runner/Extension/ExtensionBootstrapper.php +++ b/src/Runner/Extension/ExtensionBootstrapper.php @@ -14,7 +14,6 @@ use function class_implements; use function in_array; use function sprintf; -use PHPUnit\Event; use PHPUnit\Event\Facade as EventFacade; use PHPUnit\TextUI\Configuration\Configuration; use ReflectionClass; @@ -87,7 +86,7 @@ public function bootstrap(string $className, array $parameters): void return; } - Event\Facade::emitter()->testRunnerBootstrappedExtension( + EventFacade::emitter()->testRunnerBootstrappedExtension( $className, $parameters, ); diff --git a/src/Runner/Version.php b/src/Runner/Version.php index bcabd74a2b2..c93a7b7d46f 100644 --- a/src/Runner/Version.php +++ b/src/Runner/Version.php @@ -34,7 +34,7 @@ public static function id(): string } if (self::$version === '') { - self::$version = (new VersionId('10.5.5', dirname(__DIR__, 2)))->asString(); + self::$version = (new VersionId('10.5.8', dirname(__DIR__, 2)))->asString(); } return self::$version; diff --git a/src/TextUI/Application.php b/src/TextUI/Application.php index 7dc77d134bf..fc64589c6a8 100644 --- a/src/TextUI/Application.php +++ b/src/TextUI/Application.php @@ -154,7 +154,7 @@ public function run(array $argv): int $extensionReplacesResultOutput, ); - if (!$extensionReplacesOutput) { + if (!$configuration->debug() && !$extensionReplacesOutput) { $this->writeRuntimeInformation($printer, $configuration); $this->writePharExtensionInformation($printer, $pharExtensions); $this->writeRandomSeedInformation($printer, $configuration); @@ -162,6 +162,15 @@ public function run(array $argv): int $printer->print(PHP_EOL); } + if ($configuration->debug()) { + EventFacade::instance()->registerTracer( + new EventLogger( + 'php://stdout', + false, + ), + ); + } + $this->registerLogfileWriters($configuration); $testDoxResultCollector = $this->testDoxResultCollector($configuration); diff --git a/src/TextUI/Command/Commands/MigrateConfigurationCommand.php b/src/TextUI/Command/Commands/MigrateConfigurationCommand.php index 50001940e35..781de3e9fa2 100644 --- a/src/TextUI/Command/Commands/MigrateConfigurationCommand.php +++ b/src/TextUI/Command/Commands/MigrateConfigurationCommand.php @@ -11,6 +11,7 @@ use function copy; use function file_put_contents; +use function sprintf; use PHPUnit\TextUI\XmlConfiguration\Migrator; use Throwable; @@ -28,24 +29,33 @@ public function __construct(string $filename) public function execute(): Result { - copy($this->filename, $this->filename . '.bak'); + try { + $migrated = (new Migrator)->migrate($this->filename); - $buffer = 'Created backup: ' . $this->filename . '.bak' . PHP_EOL; - $shellExitCode = Result::SUCCESS; + copy($this->filename, $this->filename . '.bak'); - try { - file_put_contents( - $this->filename, - (new Migrator)->migrate($this->filename), - ); + file_put_contents($this->filename, $migrated); - $buffer .= 'Migrated configuration: ' . $this->filename . PHP_EOL; + return Result::from( + sprintf( + 'Created backup: %s.bak%sMigrated configuration: %s%s', + $this->filename, + PHP_EOL, + $this->filename, + PHP_EOL, + ), + ); } catch (Throwable $t) { - $buffer .= 'Migration failed: ' . $t->getMessage() . PHP_EOL; - - $shellExitCode = Result::FAILURE; + return Result::from( + sprintf( + 'Migration of %s failed:%s%s%s', + $this->filename, + PHP_EOL, + $t->getMessage(), + PHP_EOL, + ), + Result::FAILURE, + ); } - - return Result::from($buffer, $shellExitCode); } } diff --git a/src/TextUI/Configuration/Cli/Builder.php b/src/TextUI/Configuration/Cli/Builder.php index 034656bf7a6..8e88c70c922 100644 --- a/src/TextUI/Configuration/Cli/Builder.php +++ b/src/TextUI/Configuration/Cli/Builder.php @@ -17,6 +17,7 @@ use function is_numeric; use function sprintf; use PHPUnit\Runner\TestSuiteSorter; +use PHPUnit\Util\Filesystem; use SebastianBergmann\CliParser\Exception as CliParserException; use SebastianBergmann\CliParser\Parser as CliParser; @@ -122,6 +123,7 @@ final class Builder 'log-events-text=', 'log-events-verbose-text=', 'version', + 'debug', ]; private const SHORT_OPTIONS = 'd:c:h'; @@ -240,6 +242,7 @@ public function fromParameters(array $parameters): Configuration $logEventsVerboseText = null; $printerTeamCity = null; $printerTestDox = null; + $debug = false; foreach ($options[0] as $option) { switch ($option[0]) { @@ -803,12 +806,35 @@ public function fromParameters(array $parameters): Configuration break; case '--log-events-text': - $logEventsText = $option[1]; + $logEventsText = Filesystem::resolvePathOrStream($option[1]); + + if (!$logEventsText) { + throw new Exception( + sprintf( + 'The path "%s" specified for the --log-events-text option could not be resolved', + $option[1], + ), + ); + } break; case '--log-events-verbose-text': - $logEventsVerboseText = $option[1]; + $logEventsVerboseText = Filesystem::resolvePathOrStream($option[1]); + + if (!$logEventsVerboseText) { + throw new Exception( + sprintf( + 'The path "%s" specified for the --log-events-verbose-text option could not be resolved', + $option[1], + ), + ); + } + + break; + + case '--debug': + $debug = true; break; } @@ -920,6 +946,7 @@ public function fromParameters(array $parameters): Configuration $logEventsVerboseText, $printerTeamCity, $printerTestDox, + $debug, ); } } diff --git a/src/TextUI/Configuration/Cli/Configuration.php b/src/TextUI/Configuration/Cli/Configuration.php index cca980eadaa..b4058e1e9d6 100644 --- a/src/TextUI/Configuration/Cli/Configuration.php +++ b/src/TextUI/Configuration/Cli/Configuration.php @@ -120,12 +120,13 @@ final class Configuration private readonly bool $version; private readonly ?string $logEventsText; private readonly ?string $logEventsVerboseText; + private readonly bool $debug; /** * @psalm-param list $arguments * @psalm-param ?non-empty-list $testSuffixes */ - public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configurationFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox) + public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configurationFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox, bool $debug) { $this->arguments = $arguments; $this->atLeastVersion = $atLeastVersion; @@ -224,6 +225,7 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba $this->logEventsVerboseText = $logEventsVerboseText; $this->teamCityPrinter = $printerTeamCity; $this->testdoxPrinter = $printerTestDox; + $this->debug = $debug; } /** @@ -1998,4 +2000,9 @@ public function logEventsVerboseText(): string return $this->logEventsVerboseText; } + + public function debug(): bool + { + return $this->debug; + } } diff --git a/src/TextUI/Configuration/Configuration.php b/src/TextUI/Configuration/Configuration.php index ae18bbb6412..12b0cbd06bf 100644 --- a/src/TextUI/Configuration/Configuration.php +++ b/src/TextUI/Configuration/Configuration.php @@ -138,6 +138,7 @@ final class Configuration private readonly bool $controlGarbageCollector; private readonly int $numberOfTestsBeforeGarbageCollection; private readonly ?string $generateBaseline; + private readonly bool $debug; /** * @psalm-param list $cliArguments @@ -145,7 +146,7 @@ final class Configuration * @psalm-param non-empty-list $testSuffixes * @psalm-param list}> $extensionBootstrappers */ - public function __construct(array $cliArguments, ?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, Source $source, string $testResultCacheFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4j, int $coverageCrap4jThreshold, ?string $coverageHtml, int $coverageHtmlLowUpperBound, int $coverageHtmlHighLowerBound, string $coverageHtmlColorSuccessLow, string $coverageHtmlColorSuccessMedium, string $coverageHtmlColorSuccessHigh, string $coverageHtmlColorWarning, string $coverageHtmlColorDanger, ?string $coverageHtmlCustomCssFile, ?string $coveragePhp, ?string $coverageText, bool $coverageTextShowUncoveredFiles, bool $coverageTextShowOnlySummary, ?string $coverageXml, bool $pathCoverage, bool $ignoreDeprecatedCodeUnitsFromCodeCoverage, bool $disableCodeCoverageIgnore, bool $failOnDeprecation, bool $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnNotice, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $stopOnDefect, bool $stopOnDeprecation, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int|string $columns, bool $noExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $registerMockObjectsFromTestArgumentsRecursively, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?array $groups, ?array $excludeGroups, int $randomOrderSeed, bool $includeUncoveredFiles, TestSuiteCollection $testSuite, string $includeTestSuite, string $excludeTestSuite, ?string $defaultTestSuite, array $testSuffixes, Php $php, bool $controlGarbageCollector, int $numberOfTestsBeforeGarbageCollection, ?string $generateBaseline) + public function __construct(array $cliArguments, ?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, Source $source, string $testResultCacheFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4j, int $coverageCrap4jThreshold, ?string $coverageHtml, int $coverageHtmlLowUpperBound, int $coverageHtmlHighLowerBound, string $coverageHtmlColorSuccessLow, string $coverageHtmlColorSuccessMedium, string $coverageHtmlColorSuccessHigh, string $coverageHtmlColorWarning, string $coverageHtmlColorDanger, ?string $coverageHtmlCustomCssFile, ?string $coveragePhp, ?string $coverageText, bool $coverageTextShowUncoveredFiles, bool $coverageTextShowOnlySummary, ?string $coverageXml, bool $pathCoverage, bool $ignoreDeprecatedCodeUnitsFromCodeCoverage, bool $disableCodeCoverageIgnore, bool $failOnDeprecation, bool $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnNotice, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $stopOnDefect, bool $stopOnDeprecation, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int|string $columns, bool $noExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $registerMockObjectsFromTestArgumentsRecursively, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?array $groups, ?array $excludeGroups, int $randomOrderSeed, bool $includeUncoveredFiles, TestSuiteCollection $testSuite, string $includeTestSuite, string $excludeTestSuite, ?string $defaultTestSuite, array $testSuffixes, Php $php, bool $controlGarbageCollector, int $numberOfTestsBeforeGarbageCollection, ?string $generateBaseline, bool $debug) { $this->cliArguments = $cliArguments; $this->configurationFile = $configurationFile; @@ -249,6 +250,7 @@ public function __construct(array $cliArguments, ?string $configurationFile, ?st $this->controlGarbageCollector = $controlGarbageCollector; $this->numberOfTestsBeforeGarbageCollection = $numberOfTestsBeforeGarbageCollection; $this->generateBaseline = $generateBaseline; + $this->debug = $debug; } /** @@ -1285,4 +1287,9 @@ public function generateBaseline(): string return $this->generateBaseline; } + + public function debug(): bool + { + return $this->debug; + } } diff --git a/src/TextUI/Configuration/Merger.php b/src/TextUI/Configuration/Merger.php index 95f595a4551..4698c8da2e0 100644 --- a/src/TextUI/Configuration/Merger.php +++ b/src/TextUI/Configuration/Merger.php @@ -847,6 +847,7 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC $xmlConfiguration->phpunit()->controlGarbageCollector(), $xmlConfiguration->phpunit()->numberOfTestsBeforeGarbageCollection(), $generateBaseline, + $cliConfiguration->debug(), ); } } diff --git a/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php b/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php index 47729221733..86b92e766b1 100644 --- a/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php +++ b/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php @@ -9,8 +9,6 @@ */ namespace PHPUnit\TextUI\XmlConfiguration; -use function array_key_exists; -use function sprintf; use function version_compare; /** @@ -70,15 +68,6 @@ final class MigrationBuilder */ public function build(string $fromVersion): array { - if (!array_key_exists($fromVersion, self::AVAILABLE_MIGRATIONS)) { - throw new MigrationBuilderException( - sprintf( - 'Migration from schema version %s is not supported', - $fromVersion, - ), - ); - } - $stack = [new UpdateSchemaLocation]; foreach (self::AVAILABLE_MIGRATIONS as $version => $migrations) { diff --git a/src/TextUI/Configuration/Xml/Migration/Migrator.php b/src/TextUI/Configuration/Xml/Migration/Migrator.php index 2755a4f597e..78adfae86d7 100644 --- a/src/TextUI/Configuration/Xml/Migration/Migrator.php +++ b/src/TextUI/Configuration/Xml/Migration/Migrator.php @@ -9,7 +9,7 @@ */ namespace PHPUnit\TextUI\XmlConfiguration; -use function sprintf; +use PHPUnit\Runner\Version; use PHPUnit\Util\Xml\Loader as XmlLoader; use PHPUnit\Util\Xml\XmlException; @@ -29,12 +29,11 @@ public function migrate(string $filename): string $origin = (new SchemaDetector)->detect($filename); if (!$origin->detected()) { - throw new Exception( - sprintf( - '"%s" is not a valid PHPUnit XML configuration file that can be migrated', - $filename, - ), - ); + throw new Exception('The file does not validate against any know schema'); + } + + if ($origin->version() === Version::series()) { + throw new Exception('The file does not need to be migrated'); } $configurationDocument = (new XmlLoader)->loadFile($filename); diff --git a/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetectionResult.php b/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetectionResult.php index e92426a1dd5..091826125c4 100644 --- a/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetectionResult.php +++ b/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetectionResult.php @@ -18,6 +18,9 @@ */ abstract class SchemaDetectionResult { + /** + * @psalm-assert-if-true SuccessfulSchemaDetectionResult $this + */ public function detected(): bool { return false; diff --git a/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetector.php b/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetector.php index 8d39f860477..ca2ee8f2f40 100644 --- a/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetector.php +++ b/src/TextUI/Configuration/Xml/SchemaDetector/SchemaDetector.php @@ -24,7 +24,9 @@ public function detect(string $filename): SchemaDetectionResult { $document = (new Loader)->loadFile($filename); - foreach (['10.0', '9.5', '9.2', '8.5'] as $candidate) { + $schemaFinder = new SchemaFinder; + + foreach ($schemaFinder->available() as $candidate) { $schema = (new SchemaFinder)->find($candidate); if (!(new Validator)->validate($document, $schema)->hasValidationErrors()) { diff --git a/src/TextUI/Configuration/Xml/SchemaDetector/SuccessfulSchemaDetectionResult.php b/src/TextUI/Configuration/Xml/SchemaDetector/SuccessfulSchemaDetectionResult.php index 07b0b03aff0..002dfe87c89 100644 --- a/src/TextUI/Configuration/Xml/SchemaDetector/SuccessfulSchemaDetectionResult.php +++ b/src/TextUI/Configuration/Xml/SchemaDetector/SuccessfulSchemaDetectionResult.php @@ -16,18 +16,30 @@ */ final class SuccessfulSchemaDetectionResult extends SchemaDetectionResult { + /** + * @psalm-var non-empty-string + */ private readonly string $version; + /** + * @psalm-param non-empty-string $version + */ public function __construct(string $version) { $this->version = $version; } + /** + * @psalm-assert-if-true SuccessfulSchemaDetectionResult $this + */ public function detected(): bool { return true; } + /** + * @psalm-return non-empty-string + */ public function version(): string { return $this->version; diff --git a/src/TextUI/Configuration/Xml/SchemaFinder.php b/src/TextUI/Configuration/Xml/SchemaFinder.php index 8e46a489ba1..b6b620d9860 100644 --- a/src/TextUI/Configuration/Xml/SchemaFinder.php +++ b/src/TextUI/Configuration/Xml/SchemaFinder.php @@ -9,9 +9,12 @@ */ namespace PHPUnit\TextUI\XmlConfiguration; +use function assert; use function defined; use function is_file; +use function rsort; use function sprintf; +use DirectoryIterator; use PHPUnit\Runner\Version; /** @@ -19,6 +22,30 @@ */ final class SchemaFinder { + /** + * @psalm-return non-empty-list + */ + public function available(): array + { + $result = [Version::series()]; + + foreach ((new DirectoryIterator($this->path() . 'schema')) as $file) { + if ($file->isDot()) { + continue; + } + + $version = $file->getBasename('.xsd'); + + assert(!empty($version)); + + $result[] = $version; + } + + rsort($result); + + return $result; + } + /** * @throws CannotFindSchemaException */ diff --git a/src/TextUI/Help.php b/src/TextUI/Help.php index 5ae9c10402c..e09c172b81c 100644 --- a/src/TextUI/Help.php +++ b/src/TextUI/Help.php @@ -124,8 +124,11 @@ final class Help ['arg' => '--reverse-list', 'desc' => 'Print defects in reverse order'], ['spacer' => ''], - ['arg' => '--teamcity', 'desc' => 'Replace default progress and result output with TeamCity format'], - ['arg' => '--testdox', 'desc' => 'Replace default result output with TestDox format'], + ['arg' => '--teamcity', 'desc' => 'Replace default progress and result output with TeamCity format'], + ['arg' => '--testdox', 'desc' => 'Replace default result output with TestDox format'], + ['spacer' => ''], + + ['arg' => '--debug', 'desc' => 'Replace default progress and result output with debugging information'], ], 'Logging' => [ diff --git a/src/TextUI/Output/Facade.php b/src/TextUI/Output/Facade.php index 23f15236822..4a7f09976a5 100644 --- a/src/TextUI/Output/Facade.php +++ b/src/TextUI/Output/Facade.php @@ -47,6 +47,10 @@ public static function init(Configuration $configuration, bool $extensionReplace assert(self::$printer !== null); + if ($configuration->debug()) { + return self::$printer; + } + self::createUnexpectedOutputPrinter(); if (!$extensionReplacesProgressOutput) { @@ -117,6 +121,10 @@ private static function createPrinter(Configuration $configuration): void { $printerNeeded = false; + if ($configuration->debug()) { + $printerNeeded = true; + } + if ($configuration->outputIsTeamCity()) { $printerNeeded = true; } @@ -196,14 +204,14 @@ private static function createResultPrinter(Configuration $configuration): void true, false, false, + true, false, false, - false, - false, - false, - false, - false, - false, + $configuration->displayDetailsOnTestsThatTriggerDeprecations(), + $configuration->displayDetailsOnTestsThatTriggerErrors(), + $configuration->displayDetailsOnTestsThatTriggerNotices(), + $configuration->displayDetailsOnTestsThatTriggerWarnings(), + $configuration->reverseDefectList(), ); } diff --git a/src/TextUI/Output/TestDox/ResultPrinter.php b/src/TextUI/Output/TestDox/ResultPrinter.php index 320ce69ff56..8959a4f8c41 100644 --- a/src/TextUI/Output/TestDox/ResultPrinter.php +++ b/src/TextUI/Output/TestDox/ResultPrinter.php @@ -310,7 +310,7 @@ private function colorFor(TestStatus $status): string return 'fg-cyan'; } - if ($status->isRisky() || $status->isIncomplete() || $status->isWarning()) { + if ($status->isIncomplete() || $status->isDeprecation() || $status->isNotice() || $status->isRisky() || $status->isWarning()) { return 'fg-yellow'; } @@ -335,7 +335,7 @@ private function messageColorFor(TestStatus $status): string return 'fg-cyan'; } - if ($status->isRisky() || $status->isIncomplete() || $status->isWarning()) { + if ($status->isIncomplete() || $status->isDeprecation() || $status->isNotice() || $status->isRisky() || $status->isWarning()) { return 'fg-yellow'; } @@ -356,18 +356,14 @@ private function symbolFor(TestStatus $status): string return '↩'; } - if ($status->isRisky()) { - return '☢'; + if ($status->isDeprecation() || $status->isNotice() || $status->isRisky() || $status->isWarning()) { + return '⚠'; } if ($status->isIncomplete()) { return '∅'; } - if ($status->isWarning()) { - return '⚠'; - } - return '?'; } } diff --git a/src/Util/Filesystem.php b/src/Util/Filesystem.php index 9789fe29a74..818e6bff0b6 100644 --- a/src/Util/Filesystem.php +++ b/src/Util/Filesystem.php @@ -10,7 +10,10 @@ namespace PHPUnit\Util; use function is_dir; +use function is_string; use function mkdir; +use function realpath; +use function str_starts_with; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit @@ -21,4 +24,24 @@ public static function createDirectory(string $directory): bool { return !(!is_dir($directory) && !@mkdir($directory, 0o777, true) && !is_dir($directory)); } + + /** + * @psalm-param non-empty-string $path + * + * @return false|non-empty-string + */ + public static function resolvePathOrStream(string $path): false|string + { + if (str_starts_with($path, 'php://') || str_starts_with($path, 'socket://')) { + return $path; + } + + $path = realpath($path); + + if (is_string($path) && !empty($path)) { + return $path; + } + + return false; + } } diff --git a/src/Util/Filter.php b/src/Util/Filter.php index 512d22623c2..46bf082bead 100644 --- a/src/Util/Filter.php +++ b/src/Util/Filter.php @@ -28,7 +28,7 @@ final class Filter /** * @throws Exception */ - public static function getFilteredStacktrace(Throwable $t): string + public static function getFilteredStacktrace(Throwable $t, bool $unwrap = true): string { $filteredStacktrace = ''; @@ -41,7 +41,7 @@ public static function getFilteredStacktrace(Throwable $t): string $eFile = $t->getFile(); $eLine = $t->getLine(); } else { - if ($t->getPrevious()) { + if ($unwrap && $t->getPrevious()) { $t = $t->getPrevious(); } diff --git a/tests/_files/DataProviderDependencyResultTest.php b/tests/_files/DataProviderDependencyResultTest.php new file mode 100644 index 00000000000..24b97d29a23 --- /dev/null +++ b/tests/_files/DataProviderDependencyResultTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture; + +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Depends; +use PHPUnit\Framework\TestCase; + +final class DataProviderDependencyResultTest extends TestCase +{ + public static function providerMethod(): array + { + return [ + [0, 2], + [1, 1], + ]; + } + + #[DataProvider('providerMethod')] + #[Depends('testDependency')] + public function testAdd($a, $b, $c): void + { + $this->assertSame(2, $c); + $this->assertSame($c, $a + $b); + } + + public function testDependency(): int + { + $a = 2; + $this->assertSame(2, $a); + + return $a; + } +} diff --git a/tests/_files/ExceptionInMockDestructor.php b/tests/_files/ExceptionInMockDestructor.php new file mode 100644 index 00000000000..6be9ff15e1a --- /dev/null +++ b/tests/_files/ExceptionInMockDestructor.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture; + +use Exception; + +class ExceptionInMockDestructor +{ + public function __destruct() + { + throw new Exception('Some exception.'); + } +} diff --git a/tests/_files/ExceptionInMockDestructorTest.php b/tests/_files/ExceptionInMockDestructorTest.php new file mode 100644 index 00000000000..d12cc12b2cf --- /dev/null +++ b/tests/_files/ExceptionInMockDestructorTest.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture; + +use PHPUnit\Framework\TestCase; + +class ExceptionInMockDestructorTest extends TestCase +{ + public function testOne(): void + { + $mock = $this->createMock(ExceptionInMockDestructor::class); + + $this->assertInstanceOf(ExceptionInMockDestructor::class, $mock); + } +} diff --git a/tests/_files/bar.txt b/tests/_files/bar.txt new file mode 100644 index 00000000000..351f9261cd1 --- /dev/null +++ b/tests/_files/bar.txt @@ -0,0 +1 @@ +Voulez-vous un café? diff --git a/tests/_files/foo.txt b/tests/_files/foo.txt new file mode 100644 index 00000000000..f4fe32c14f6 --- /dev/null +++ b/tests/_files/foo.txt @@ -0,0 +1 @@ +Voulez-vous un café? diff --git a/tests/_files/mock-object/MethodWIthVariadicVariables.php b/tests/_files/mock-object/MethodWIthVariadicVariables.php new file mode 100644 index 00000000000..f264a12cd96 --- /dev/null +++ b/tests/_files/mock-object/MethodWIthVariadicVariables.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\MockObject; + +class MethodWIthVariadicVariables +{ + public function testVariadic(string $foo, mixed ...$arguments): array + { + + return [$foo, ...$arguments]; + } +} diff --git a/tests/end-to-end/_files/log-events-text/Test.php b/tests/end-to-end/_files/log-events-text/Test.php index 5142b9cd92c..8c21fd3a13f 100644 --- a/tests/end-to-end/_files/log-events-text/Test.php +++ b/tests/end-to-end/_files/log-events-text/Test.php @@ -9,18 +9,45 @@ */ namespace PHPUnit\TestFixture\LogEventsText; +use function fopen; use PHPUnit\Framework\TestCase; use stdClass; final class Test extends TestCase { + public function testExportNull(): void + { + $this->assertNull(null); + } + + public function testExportBool(): void + { + $this->assertTrue(true); + } + + public function testExportInt(): void + { + $this->assertSame(1, 1); + } + + public function testExportStr(): void + { + $this->assertSame('hello, world!', 'hello, world!'); + } + + public function testExportArray(): void + { + $arr = [1, 'foo' => 2]; + $this->assertSame($arr, $arr); + } + public function testExportObject(): void { $this->assertSame(new stdClass, new stdClass); } - public function testExportNull(): void + public function testExportResource(): void { - $this->assertNull(null); + $this->assertSame(fopen('php://memory', 'rw+'), fopen('php://memory', 'rw+')); } } diff --git a/tests/end-to-end/_files/output-cli-help-color.txt b/tests/end-to-end/_files/output-cli-help-color.txt index a757c83be09..a4c8f92974e 100644 --- a/tests/end-to-end/_files/output-cli-help-color.txt +++ b/tests/end-to-end/_files/output-cli-help-color.txt @@ -118,6 +118,9 @@ --testdox  Replace default result output with TestDox format + --debug  Replace default progress and result output + with debugging information + Logging: --log-junit   Write test results in JUnit XML format to diff --git a/tests/end-to-end/_files/output-cli-usage.txt b/tests/end-to-end/_files/output-cli-usage.txt index f9305887d95..32cd37c5749 100644 --- a/tests/end-to-end/_files/output-cli-usage.txt +++ b/tests/end-to-end/_files/output-cli-usage.txt @@ -91,6 +91,8 @@ Reporting: --teamcity Replace default progress and result output with TeamCity format --testdox Replace default result output with TestDox format + --debug Replace default progress and result output with debugging information + Logging: --log-junit Write test results in JUnit XML format to file diff --git a/tests/end-to-end/cli/log-events-text-invalid-argument.phpt b/tests/end-to-end/cli/log-events-text-invalid-argument.phpt new file mode 100644 index 00000000000..f3c3c5bd28b --- /dev/null +++ b/tests/end-to-end/cli/log-events-text-invalid-argument.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test fails with invalid path +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +The path "%s" specified for the --log-events-text option could not be resolved diff --git a/tests/end-to-end/cli/log-events-text.phpt b/tests/end-to-end/cli/log-events-text.phpt index 53c6ef05897..4b8b1bfa26c 100644 --- a/tests/end-to-end/cli/log-events-text.phpt +++ b/tests/end-to-end/cli/log-events-text.phpt @@ -21,26 +21,58 @@ unlink($traceFile); --EXPECTF-- PHPUnit Started (PHPUnit %s using %s) Test Runner Configured -Test Suite Loaded (2 tests) +Test Suite Loaded (7 tests) Event Facade Sealed Test Runner Started Test Suite Sorted -Test Runner Execution Started (2 tests) -Test Suite Started (CLI Arguments, 2 tests) -Test Suite Started (PHPUnit\TestFixture\LogEventsText\Test, 2 tests) +Test Runner Execution Started (7 tests) +Test Suite Started (CLI Arguments, 7 tests) +Test Suite Started (PHPUnit\TestFixture\LogEventsText\Test, 7 tests) +Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +Assertion Succeeded (Constraint: is null, Value: null) +Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +Assertion Succeeded (Constraint: is true, Value: true) +Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +Assertion Succeeded (Constraint: is identical to 1, Value: 1) +Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +Assertion Succeeded (Constraint: is identical to 'hello, world!', Value: 'hello, world!') +Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) +Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) +Assertion Succeeded (Constraint: is identical to Array &0 [ + 0 => 1, + 'foo' => 2, +], Value: Array &0 [ + 0 => 1, + 'foo' => 2, +]) +Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) +Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) Assertion Failed (Constraint: is identical to an object of class "stdClass", Value: {enable export of objects to see this value}) Test Failed (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) Failed asserting that two variables reference the same object. Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) -Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -Assertion Succeeded (Constraint: is null, Value: null) -Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -Test Suite Finished (PHPUnit\TestFixture\LogEventsText\Test, 2 tests) -Test Suite Finished (CLI Arguments, 2 tests) +Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +Assertion Failed (Constraint: is identical to {enable export of objects to see this value}, Value: {enable export of objects to see this value}) +Test Failed (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +Failed asserting that two variables reference the same resource. +Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +Test Suite Finished (PHPUnit\TestFixture\LogEventsText\Test, 7 tests) +Test Suite Finished (CLI Arguments, 7 tests) Test Runner Execution Finished Test Runner Finished PHPUnit Finished (Shell Exit Code: 1) diff --git a/tests/end-to-end/cli/log-events-verbose-text-invalid-argument.phpt b/tests/end-to-end/cli/log-events-verbose-text-invalid-argument.phpt new file mode 100644 index 00000000000..1e22d7c6a09 --- /dev/null +++ b/tests/end-to-end/cli/log-events-verbose-text-invalid-argument.phpt @@ -0,0 +1,19 @@ +--TEST-- +Test fails with invalid path +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +The path "%s" specified for the --log-events-verbose-text option could not be resolved diff --git a/tests/end-to-end/cli/log-events-verbose-text.phpt b/tests/end-to-end/cli/log-events-verbose-text.phpt index cda80823e0f..acd51ee6a61 100644 --- a/tests/end-to-end/cli/log-events-verbose-text.phpt +++ b/tests/end-to-end/cli/log-events-verbose-text.phpt @@ -21,26 +21,58 @@ unlink($traceFile); --EXPECTF-- [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] PHPUnit Started (%s) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Runner Configured -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Loaded (2 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Loaded (7 tests) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Event Facade Sealed [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Runner Started [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Sorted -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Runner Execution Started (2 tests) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Started (CLI Arguments, 2 tests) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Started (PHPUnit\TestFixture\LogEventsText\Test, 2 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Runner Execution Started (7 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Started (CLI Arguments, 7 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Started (PHPUnit\TestFixture\LogEventsText\Test, 7 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Succeeded (Constraint: is null, Value: null) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Succeeded (Constraint: is true, Value: true) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportBool) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Succeeded (Constraint: is identical to 1, Value: 1) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportInt) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Succeeded (Constraint: is identical to 'hello, world!', Value: 'hello, world!') +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportStr) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Succeeded (Constraint: is identical to Array &0 [ + 0 => 1, + 'foo' => 2, + ], Value: Array &0 [ + 0 => 1, + 'foo' => 2, + ]) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportArray) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Failed (Constraint: is identical to an object of class "stdClass", Value: stdClass Object #%d ()) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Failed (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) Failed asserting that two variables reference the same object. [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportObject) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Succeeded (Constraint: is null, Value: null) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Passed (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportNull) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Finished (PHPUnit\TestFixture\LogEventsText\Test, 2 tests) -[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Finished (CLI Arguments, 2 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Preparation Started (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Prepared (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Assertion Failed (Constraint: is identical to resource(%d) of type (stream), Value: resource(%d) of type (stream)) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Failed (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) + Failed asserting that two variables reference the same resource. +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Finished (PHPUnit\TestFixture\LogEventsText\Test::testExportResource) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Finished (PHPUnit\TestFixture\LogEventsText\Test, 7 tests) +[%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Suite Finished (CLI Arguments, 7 tests) [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Runner Execution Finished [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] Test Runner Finished [%s:%s:%s.%s / %s:%s:%s.%s] [%s bytes] PHPUnit Finished (Shell Exit Code: 1) diff --git a/tests/end-to-end/event/test-method-builder-cannot-find-testcase-object.phpt b/tests/end-to-end/event/test-method-builder-cannot-find-testcase-object.phpt index 6d5ec7962f2..b7468caca4b 100644 --- a/tests/end-to-end/event/test-method-builder-cannot-find-testcase-object.phpt +++ b/tests/end-to-end/event/test-method-builder-cannot-find-testcase-object.phpt @@ -1,5 +1,9 @@ --TEST-- The right exception is raised when TestMethodBuilder::fromCallStack() cannot find a TestCase object +--SKIPIF-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +... 3 / 3 (100%) + +Time: %s, Memory: %s + +OK (3 tests, 5 assertions) diff --git a/tests/end-to-end/generic/exception-in-mock-destructor.phpt b/tests/end-to-end/generic/exception-in-mock-destructor.phpt new file mode 100644 index 00000000000..3a2e2e4f86f --- /dev/null +++ b/tests/end-to-end/generic/exception-in-mock-destructor.phpt @@ -0,0 +1,28 @@ +--TEST-- +phpunit ../../_files/ExceptionInMockDestructorTest.php +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +E 1 / 1 (100%) + +Time: %s, Memory: %s + +There was 1 error: + +1) PHPUnit\TestFixture\ExceptionInMockDestructorTest::testOne +Exception: Some exception. + +%sExceptionInMockDestructor.php:%d + +ERRORS! +Tests: 1, Assertions: 1, Errors: 1. diff --git a/tests/end-to-end/generic/unexpected-output-with-progress-printing.phpt b/tests/end-to-end/generic/unexpected-output-with-progress-printing.phpt index a6e5260718b..b18c34a5ae1 100644 --- a/tests/end-to-end/generic/unexpected-output-with-progress-printing.phpt +++ b/tests/end-to-end/generic/unexpected-output-with-progress-printing.phpt @@ -1,5 +1,9 @@ --TEST-- phpunit ../../_files/UnexpectedOutputTest.php +--SKIPIF-- +run($_SERVER['argv']); --EXPECTF-- Risky (PHPUnit\TestFixture\TestRunnerStopping\Risky) - [ ] One + [x] One [x] Two diff --git a/tests/end-to-end/migration/_files/unsupported-schema/phpunit.xml b/tests/end-to-end/migration/_files/unsupported-schema/phpunit.xml new file mode 100644 index 00000000000..b24baa02e01 --- /dev/null +++ b/tests/end-to-end/migration/_files/unsupported-schema/phpunit.xml @@ -0,0 +1,6 @@ + + + bar + diff --git a/tests/end-to-end/migration/unsupported-schema.phpt b/tests/end-to-end/migration/unsupported-schema.phpt new file mode 100644 index 00000000000..0640d3c0932 --- /dev/null +++ b/tests/end-to-end/migration/unsupported-schema.phpt @@ -0,0 +1,22 @@ +--TEST-- +Configuration migration is not possible when the configuration file does not validate against any known schema +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Migration of %s failed: +The file does not validate against any know schema +--CLEAN-- + $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -75,6 +88,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'speak', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt b/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt index 4c128181f9b..7feda6cbb6c 100644 --- a/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt +++ b/tests/end-to-end/mock-objects/generator/3154_namespaced_constant_resolving.phpt @@ -49,6 +49,19 @@ class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework public function a(int $i = %d, int $j = 17, string $v = '%s', string $z = '#'): string { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$i, $j, $v, $z]; $__phpunit_count = func_num_args(); @@ -60,6 +73,8 @@ class Issue3154Mock extends Is\Namespaced\Issue3154 implements PHPUnit\Framework } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Is\Namespaced\Issue3154', 'a', $__phpunit_arguments, 'string', $this, true diff --git a/tests/end-to-end/mock-objects/generator/3967.phpt b/tests/end-to-end/mock-objects/generator/3967.phpt index 6985c72bb04..c037c6af695 100644 --- a/tests/end-to-end/mock-objects/generator/3967.phpt +++ b/tests/end-to-end/mock-objects/generator/3967.phpt @@ -37,6 +37,19 @@ class MockBaz extends Exception implements Baz, PHPUnit\Framework\MockObject\Moc public function foo(): string { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -48,6 +61,8 @@ class MockBaz extends Exception implements Baz, PHPUnit\Framework\MockObject\Moc } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Bar', 'foo', $__phpunit_arguments, 'string', $this, true diff --git a/tests/end-to-end/mock-objects/generator/397.phpt b/tests/end-to-end/mock-objects/generator/397.phpt index 30612907459..df096d4d4fa 100644 --- a/tests/end-to-end/mock-objects/generator/397.phpt +++ b/tests/end-to-end/mock-objects/generator/397.phpt @@ -35,6 +35,19 @@ class MockC extends C implements PHPUnit\Framework\MockObject\MockObjectInternal public function m(?C $other): C { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$other]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockC extends C implements PHPUnit\Framework\MockObject\MockObjectInternal } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'C', 'm', $__phpunit_arguments, 'C', $this, true diff --git a/tests/end-to-end/mock-objects/generator/4139.phpt b/tests/end-to-end/mock-objects/generator/4139.phpt index 5ec17288ef9..535c0f9e27f 100644 --- a/tests/end-to-end/mock-objects/generator/4139.phpt +++ b/tests/end-to-end/mock-objects/generator/4139.phpt @@ -25,6 +25,19 @@ class %s implements PHPUnit\Framework\MockObject\MockObjectInternal, InterfaceWi public function __construct() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -36,6 +49,8 @@ class %s implements PHPUnit\Framework\MockObject\MockObjectInternal, InterfaceWi } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'InterfaceWithConstructor', '__construct', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/abstract_class.phpt b/tests/end-to-end/mock-objects/generator/abstract_class.phpt index 0c1d92afa8d..15261323796 100644 --- a/tests/end-to-end/mock-objects/generator/abstract_class.phpt +++ b/tests/end-to-end/mock-objects/generator/abstract_class.phpt @@ -39,6 +39,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function one() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -50,6 +63,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'one', $__phpunit_arguments, '', $this, true @@ -61,6 +76,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function two() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -72,6 +100,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'two', $__phpunit_arguments, '', $this, true @@ -83,6 +113,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte protected function three() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -94,6 +137,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'three', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class.phpt b/tests/end-to-end/mock-objects/generator/class.phpt index d5a4b202728..69c70e064bb 100644 --- a/tests/end-to-end/mock-objects/generator/class.phpt +++ b/tests/end-to-end/mock-objects/generator/class.phpt @@ -39,6 +39,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -50,6 +63,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true @@ -61,6 +76,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function baz(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -72,6 +100,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'baz', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt b/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt index 6cabb3511a9..055a815be0a 100644 --- a/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_nonexistent_method.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_partial.phpt b/tests/end-to-end/mock-objects/generator/class_partial.phpt index 28eb63acb98..2eb741eb475 100644 --- a/tests/end-to-end/mock-objects/generator/class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/class_partial.phpt @@ -39,6 +39,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -50,6 +63,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt index d8de82d8048..95fdd2fe646 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_deprecated_method.phpt @@ -41,6 +41,19 @@ class MockFoo extends ClassWithDeprecatedMethod implements PHPUnit\Framework\Moc { @trigger_error('The ClassWithDeprecatedMethod::deprecatedMethod method is deprecated (this method is deprecated).', E_USER_DEPRECATED); + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -52,6 +65,8 @@ class MockFoo extends ClassWithDeprecatedMethod implements PHPUnit\Framework\Moc } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithDeprecatedMethod', 'deprecatedMethod', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt index f24b703cfee..1a0a23ce333 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_named_method.phpt @@ -34,6 +34,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function method() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -45,6 +58,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'method', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt index 7df35463332..ce64bb2b7cc 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_nullable_typehinted_variadic_arguments.phpt @@ -35,6 +35,19 @@ class MockFoo extends ClassWithMethodWithNullableTypehintedVariadicArguments imp public function methodWithNullableTypehintedVariadicArguments($a, ?string ...$parameters) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$a]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends ClassWithMethodWithNullableTypehintedVariadicArguments imp } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithMethodWithNullableTypehintedVariadicArguments', 'methodWithNullableTypehintedVariadicArguments', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt index 03fc0d50ed7..b7100796a9e 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_typehinted_variadic_arguments.phpt @@ -35,6 +35,19 @@ class MockFoo extends ClassWithMethodWithTypehintedVariadicArguments implements public function methodWithTypehintedVariadicArguments($a, string ...$parameters) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$a]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends ClassWithMethodWithTypehintedVariadicArguments implements } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithMethodWithTypehintedVariadicArguments', 'methodWithTypehintedVariadicArguments', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt b/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt index e9d54ea5383..ea1e2ec59c6 100644 --- a/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt +++ b/tests/end-to-end/mock-objects/generator/class_with_method_with_variadic_arguments.phpt @@ -35,6 +35,19 @@ class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit\Fr public function methodWithVariadicArguments($a, ...$parameters) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$a]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends ClassWithMethodWithVariadicArguments implements PHPUnit\Fr } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithMethodWithVariadicArguments', 'methodWithVariadicArguments', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt b/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt index 1b4f00f8d2f..9c855906818 100644 --- a/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt +++ b/tests/end-to-end/mock-objects/generator/constant_as_parameter_default_value.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(int $baz = %d) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/interface.phpt b/tests/end-to-end/mock-objects/generator/interface.phpt index 05210cf5d3d..2258c32cbb4 100644 --- a/tests/end-to-end/mock-objects/generator/interface.phpt +++ b/tests/end-to-end/mock-objects/generator/interface.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt b/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt index 831856d8e37..8592925d272 100644 --- a/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt +++ b/tests/end-to-end/mock-objects/generator/invocation_object_clone_object.phpt @@ -40,6 +40,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -51,6 +64,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true @@ -62,6 +77,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function baz(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -73,6 +101,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'baz', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class.phpt index fa804a67dc4..d6822a08dab 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class.phpt @@ -41,6 +41,19 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI public function bar(NS\Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -52,6 +65,8 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'NS\Foo', 'bar', $__phpunit_arguments, '', $this, true @@ -63,6 +78,19 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI public function baz(NS\Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -74,6 +102,8 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'NS\Foo', 'baz', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt b/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt index a7320588aad..5b111eacd43 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_class_partial.phpt @@ -41,6 +41,19 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI public function bar(NS\Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -52,6 +65,8 @@ class MockFoo extends NS\Foo implements PHPUnit\Framework\MockObject\MockObjectI } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'NS\Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt b/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt index d9a907c368f..36ae50392ff 100644 --- a/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt +++ b/tests/end-to-end/mock-objects/generator/namespaced_interface.phpt @@ -35,6 +35,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, NS\Foo public function bar(NS\Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, NS\Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'NS\Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/nullable_types.phpt b/tests/end-to-end/mock-objects/generator/nullable_types.phpt index a635288b493..337d98cd0bb 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_types.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_types.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(?int $x) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$x]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt b/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt index 2443c181f01..215e4872ea2 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_union_type_parameter.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(bool|int $baz, Foo|null|stdClass $other) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz, $other]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt b/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt index 92b3316d278..b8951419f06 100644 --- a/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt +++ b/tests/end-to-end/mock-objects/generator/nullable_union_type_return.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(): bool|int|null { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'bool|int|null', $this, true diff --git a/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt b/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt index 261b70b58aa..ff461b3b6d9 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_dnf.phpt @@ -48,6 +48,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar((A&B)|int|null $baz) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -59,6 +72,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/parameter_false.phpt b/tests/end-to-end/mock-objects/generator/parameter_false.phpt index 3235a3e6ce4..8918a0e0bc3 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_false.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_false.phpt @@ -38,6 +38,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(false $baz): void { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -49,6 +62,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'void', $this, true diff --git a/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt b/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt index fc839ad9af5..fd71afe49b0 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_intersection.phpt @@ -43,6 +43,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(AnInterface&AnotherInterface $baz) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -54,6 +67,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/parameter_null.phpt b/tests/end-to-end/mock-objects/generator/parameter_null.phpt index 8acaa1a27bb..2798d272833 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_null.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_null.phpt @@ -38,6 +38,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(null $baz): void { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -49,6 +62,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'void', $this, true diff --git a/tests/end-to-end/mock-objects/generator/parameter_true.phpt b/tests/end-to-end/mock-objects/generator/parameter_true.phpt index 5856d2e77af..9f887d660b8 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_true.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_true.phpt @@ -38,6 +38,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(true $baz): void { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -49,6 +62,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'void', $this, true diff --git a/tests/end-to-end/mock-objects/generator/parameter_union.phpt b/tests/end-to-end/mock-objects/generator/parameter_union.phpt index cdca80927b2..44528fca51e 100644 --- a/tests/end-to-end/mock-objects/generator/parameter_union.phpt +++ b/tests/end-to-end/mock-objects/generator/parameter_union.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(bool|int $baz, Foo|stdClass $other) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz, $other]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/generator/proxy.phpt b/tests/end-to-end/mock-objects/generator/proxy.phpt index 956c1087047..8e6453fc46b 100644 --- a/tests/end-to-end/mock-objects/generator/proxy.phpt +++ b/tests/end-to-end/mock-objects/generator/proxy.phpt @@ -34,6 +34,19 @@ class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInt public function bar(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -45,6 +58,8 @@ class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInt } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true, true @@ -58,6 +73,19 @@ class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInt public function baz(Foo $foo) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -69,6 +97,8 @@ class ProxyFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInt } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'baz', $__phpunit_arguments, '', $this, true, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt index 4137fccd46d..8c563f8a0a0 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_closure.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(): Closure { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'Closure', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt index da1ccc6ea2f..8f7b39600bf 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_dnf.phpt @@ -48,6 +48,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(): (A&B)|int|null { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -59,6 +72,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '(A&B)|int|null', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt index bc6084f3e77..1cff137cb95 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_false.phpt @@ -38,6 +38,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(): false { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -49,6 +62,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'false', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt index f8bc3f9a69f..a44f218db5c 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_final.phpt @@ -40,6 +40,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(): FinalClass { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -51,6 +64,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'FinalClass', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt index 1ec09428c44..bba83cc3e66 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(): Generator { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'Generator', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator_empty_by_default.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator_empty_by_default.phpt index 9196dbf1382..d2d35267a31 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_generator_empty_by_default.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_generator_empty_by_default.phpt @@ -1,5 +1,9 @@ --TEST-- Iterable return types should return empty array by default +--SKIPIF-- + $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -54,6 +67,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'AnInterface&AnotherInterface', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt index 69457fe3a6e..00fadb261c2 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_never.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(string $baz): never { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'never', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt index 5de62db8663..e5bf4557ae6 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_null.phpt @@ -38,6 +38,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(): null { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -49,6 +62,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'null', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt index 37ea58b586e..50e7729e74d 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_nullable.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(string $baz): ?string { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '?string', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt index c05df39d0f8..0624a88db1c 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_object_method.phpt @@ -36,6 +36,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(string $baz): Bar { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -47,6 +60,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'Bar', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt index d10e86e8ff9..f781369dae9 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_parent.phpt @@ -40,6 +40,19 @@ class MockBar extends Bar implements PHPUnit\Framework\MockObject\MockObjectInte public function baz(): Foo { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -51,6 +64,8 @@ class MockBar extends Bar implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Bar', 'baz', $__phpunit_arguments, 'Foo', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt index 213adfe7ff5..dada8dcb80a 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_self.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(string $baz): Foo { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'Foo', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt index 106e098b0ee..0aa1b619133 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_static.phpt @@ -43,6 +43,19 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen public function returnsStatic(): static { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -54,6 +67,8 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithStaticReturnTypes', 'returnsStatic', $__phpunit_arguments, 'static', $this, true @@ -65,6 +80,19 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen public function returnsStaticOrNull(): ?static { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -76,6 +104,8 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithStaticReturnTypes', 'returnsStaticOrNull', $__phpunit_arguments, '?static', $this, true @@ -87,6 +117,19 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen public function returnsUnionWithStatic(): static|stdClass { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -98,6 +141,8 @@ class MockClassWithStaticReturnTypes extends ClassWithStaticReturnTypes implemen } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'ClassWithStaticReturnTypes', 'returnsUnionWithStatic', $__phpunit_arguments, 'static|stdClass', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt index ee7d054aa44..acb48690c9a 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_true.phpt @@ -38,6 +38,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(): true { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -49,6 +62,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'true', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt index 50fb050b68d..8432acf3916 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_union.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(): bool|int { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'bool|int', $this, true diff --git a/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt b/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt index 1b334f49f34..c73556df98e 100644 --- a/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt +++ b/tests/end-to-end/mock-objects/generator/return_type_declarations_void.phpt @@ -33,6 +33,19 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo public function bar(string $baz): void { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -44,6 +57,8 @@ class MockFoo implements PHPUnit\Framework\MockObject\MockObjectInternal, Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'void', $this, true diff --git a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt b/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt index 6c1d2e7ebf0..b20b468594e 100644 --- a/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt +++ b/tests/end-to-end/mock-objects/generator/scalar_type_declarations.phpt @@ -35,6 +35,19 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte public function bar(string $baz) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$baz]; $__phpunit_count = func_num_args(); @@ -46,6 +59,8 @@ class MockFoo extends Foo implements PHPUnit\Framework\MockObject\MockObjectInte } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/mock-method/call_original.phpt b/tests/end-to-end/mock-objects/mock-method/call_original.phpt index e0509b89a5e..4beb2faabfb 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original.phpt @@ -23,6 +23,19 @@ print $code; public function bar() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ print $code; } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false, true diff --git a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt index 1cfb0430b66..8dfab7f39ae 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument.phpt @@ -23,6 +23,19 @@ print $code; private function bar($arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar($arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false, true diff --git a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt index d22d321820c..bf99664c952 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original_with_argument_variadic.phpt @@ -23,6 +23,19 @@ print $code; private function bar(...$args) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(...$args) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false, true diff --git a/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt b/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt index 0dda3cce175..f92156737e6 100644 --- a/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt +++ b/tests/end-to-end/mock-objects/mock-method/call_original_with_return_type_void.phpt @@ -23,6 +23,19 @@ print $code; public function bar(): void { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ print $code; } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'void', $this, false, true diff --git a/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt b/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt index 5aef17c57dd..50ab1870d1e 100644 --- a/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt +++ b/tests/end-to-end/mock-objects/mock-method/clone_method_arguments.phpt @@ -23,6 +23,19 @@ print $code; public function bar() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ print $code; } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, true diff --git a/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt b/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt index c5b5211c07c..6ccdc32901b 100644 --- a/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt +++ b/tests/end-to-end/mock-objects/mock-method/deprecated_with_description.phpt @@ -28,6 +28,19 @@ public function bar() { @trigger_error('The Foo::bar method is deprecated (some explanation).', E_USER_DEPRECATED); + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -39,6 +52,8 @@ public function bar() } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt b/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt index e8fc33ec6e1..e2a387ecfe0 100644 --- a/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt +++ b/tests/end-to-end/mock-objects/mock-method/deprecated_without_description.phpt @@ -28,6 +28,19 @@ public function bar() { @trigger_error('The Foo::bar method is deprecated ().', E_USER_DEPRECATED); + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -39,6 +52,8 @@ public function bar() } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/private_method.phpt b/tests/end-to-end/mock-objects/mock-method/private_method.phpt index ca62fee8c73..f844e12da35 100644 --- a/tests/end-to-end/mock-objects/mock-method/private_method.phpt +++ b/tests/end-to-end/mock-objects/mock-method/private_method.phpt @@ -23,6 +23,19 @@ print $code; private function bar() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar() } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/protected_method.phpt b/tests/end-to-end/mock-objects/mock-method/protected_method.phpt index eee3bf255a6..f8f6d82999e 100644 --- a/tests/end-to-end/mock-objects/mock-method/protected_method.phpt +++ b/tests/end-to-end/mock-objects/mock-method/protected_method.phpt @@ -23,6 +23,19 @@ print $code; protected function bar() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ protected function bar() } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt b/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt index 5ee4280e40f..51156da0c97 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_by_reference.phpt @@ -23,6 +23,19 @@ print $code; public function &bar() { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ public function &bar() } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt b/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt index 3413cd8288c..3baa0687d02 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_by_reference_with_return_type.phpt @@ -23,6 +23,19 @@ print $code; public function &bar(): string { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ public function &bar(): string } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'string', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/return_type.phpt b/tests/end-to-end/mock-objects/mock-method/return_type.phpt index 948406e32bf..9d44056ae7b 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_type.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_type.phpt @@ -23,6 +23,19 @@ print $code; public function bar(): string { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ public function bar(): string } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'string', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt b/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt index d4e058b68a2..7fd0b2734a6 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_type_parent.phpt @@ -27,6 +27,19 @@ print $code; public function bar(): Baz { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -38,6 +51,8 @@ public function bar(): Baz } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'Baz', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt b/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt index 0d0a8237f3e..7ccd57a45ac 100644 --- a/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt +++ b/tests/end-to-end/mock-objects/mock-method/return_type_self.phpt @@ -23,6 +23,19 @@ print $code; public function bar(): Foo { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ public function bar(): Foo } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, 'Foo', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument.phpt index 981ac9640c0..76b527ea4e4 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument.phpt @@ -23,6 +23,19 @@ print $code; private function bar($arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar($arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt index 2659db33e47..aaac640b99c 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default.phpt @@ -23,6 +23,19 @@ print $code; private function bar($arg = false) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar($arg = false) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt index c23a7870076..e7d79d5330d 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default_constant.phpt @@ -28,6 +28,19 @@ print $code; private function bar($a = 1, $b = 2, $c = 3, $d = 4) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$a, $b, $c, $d]; $__phpunit_count = func_num_args(); @@ -39,6 +52,8 @@ private function bar($a = 1, $b = 2, $c = 3, $d = 4) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt index 9d68fc2b08d..94ef6dcfd99 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default_new_expression.phpt @@ -30,6 +30,19 @@ print $code; public function method(Foo $foo = new \Foo(1, 2, 3)) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$foo]; $__phpunit_count = func_num_args(); @@ -41,6 +54,8 @@ public function method(Foo $foo = new \Foo(1, 2, 3)) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Bar', 'method', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt index 40119c3e2fd..07fe364b31a 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_default_null.phpt @@ -23,6 +23,19 @@ print $code; private function bar($arg = NULL) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar($arg = NULL) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt index 87e70a312fc..6a7b2d35a7e 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_nullable.phpt @@ -23,6 +23,19 @@ print $code; private function bar(?string $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(?string $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt index 859187f9cb7..149dc6adfea 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_reference.phpt @@ -23,6 +23,19 @@ print $code; private function bar(&$arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [&$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(&$arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt index 8fe5b89b44b..08f5391e64c 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_array.phpt @@ -23,6 +23,19 @@ print $code; private function bar(array $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(array $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt index c8e39a1468d..d94e276f681 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_callable.phpt @@ -23,6 +23,19 @@ print $code; private function bar(callable $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(callable $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt index 56fcbcbf3a1..54375f6806b 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_class.phpt @@ -23,6 +23,19 @@ print $code; private function bar(Exception $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(Exception $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt index 43c97200e93..a59f3871d18 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_scalar.phpt @@ -23,6 +23,19 @@ print $code; private function bar(string $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(string $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt index 23fbd8cf57d..4d7d5293807 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_self.phpt @@ -23,6 +23,19 @@ print $code; private function bar(Foo $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(Foo $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt index e8e781fda8f..a0549f5ef08 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_unkown_class.phpt @@ -23,6 +23,19 @@ print $code; private function bar(UnknownClass $arg) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(UnknownClass $arg) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt index 17fc225ef9d..3c2a792c356 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_typed_variadic.phpt @@ -23,6 +23,19 @@ print $code; private function bar(string ...$args) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(string ...$args) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt b/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt index 9bedd96e2a3..e4ce178d801 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_argument_variadic.phpt @@ -23,6 +23,19 @@ print $code; private function bar(...$args) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = []; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar(...$args) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt b/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt index a3f143e6730..7cdbfa7adb7 100644 --- a/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt +++ b/tests/end-to-end/mock-objects/mock-method/with_arguments.phpt @@ -23,6 +23,19 @@ print $code; private function bar($arg1, $arg2) { + $__phpunit_definedVariables = get_defined_vars(); + $__phpunit_namedVariadicParameters = []; + + foreach ($__phpunit_definedVariables as $__phpunit_definedVariableName => $__phpunit_definedVariableValue) { + if ((new ReflectionParameter([__CLASS__, __FUNCTION__], $__phpunit_definedVariableName))->isVariadic()) { + foreach ($__phpunit_definedVariableValue as $__phpunit_key => $__phpunit_namedValue) { + if (is_string($__phpunit_key)) { + $__phpunit_namedVariadicParameters[$__phpunit_key] = $__phpunit_namedValue; + } + } + } + } + $__phpunit_arguments = [$arg1, $arg2]; $__phpunit_count = func_num_args(); @@ -34,6 +47,8 @@ private function bar($arg1, $arg2) } } + $__phpunit_arguments = array_merge($__phpunit_arguments, $__phpunit_namedVariadicParameters); + $__phpunit_result = $this->__phpunit_getInvocationHandler()->invoke( new \PHPUnit\Framework\MockObject\Invocation( 'Foo', 'bar', $__phpunit_arguments, '', $this, false diff --git a/tests/end-to-end/phpt/expect-location-hint.phpt b/tests/end-to-end/phpt/expect-location-hint.phpt index d2494d76465..a7dee4ce2c9 100644 --- a/tests/end-to-end/phpt/expect-location-hint.phpt +++ b/tests/end-to-end/phpt/expect-location-hint.phpt @@ -1,5 +1,9 @@ --TEST-- PHPT EXPECT comparison returns correct code location hint +--SKIPIF-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +E 1 / 1 (100%) + +Time: %s, Memory: %s MB + +There was 1 error: + +1) PHPUnit\TestFixture\Issue5574\Issue5574Test::testThrownWrappedThrowablesOutputsCorrectStackTraceForEach +Exception: My exception + +%sIssue5574Test.php:22 + +Caused by +Error: Inner Exception + +%sIssue5574Test.php:21 + +ERRORS! +Tests: 1, Assertions: 0, Errors: 1. diff --git a/tests/end-to-end/regression/5574/Issue5574Test.php b/tests/end-to-end/regression/5574/Issue5574Test.php new file mode 100644 index 00000000000..4fde4db842e --- /dev/null +++ b/tests/end-to-end/regression/5574/Issue5574Test.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\Issue5574; + +use Error; +use Exception; +use PHPUnit\Framework\TestCase; + +final class Issue5574Test extends TestCase +{ + public function testThrownWrappedThrowablesOutputsCorrectStackTraceForEach(): void + { + $innerException = new Error('Inner Exception'); + $outerException = new Exception('My exception', 0, $innerException); + + throw $outerException; + } +} diff --git a/tests/end-to-end/regression/765.phpt b/tests/end-to-end/regression/765.phpt index 2cf908286b5..0aac3d9e8d1 100644 --- a/tests/end-to-end/regression/765.phpt +++ b/tests/end-to-end/regression/765.phpt @@ -1,5 +1,9 @@ --TEST-- GH-765: Fatal error triggered in PHPUnit when exception is thrown in data provider of a test with a dependency +--SKIPIF-- + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class DeprecationTest extends TestCase +{ + public function testDeprecation(): void + { + trigger_error('deprecation', E_USER_DEPRECATED); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/testdox/_files/NoticeTest.php b/tests/end-to-end/testdox/_files/NoticeTest.php new file mode 100644 index 00000000000..217e8857fdc --- /dev/null +++ b/tests/end-to-end/testdox/_files/NoticeTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class NoticeTest extends TestCase +{ + public function testNotice(): void + { + trigger_error('notice', E_USER_NOTICE); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/testdox/_files/WarningTest.php b/tests/end-to-end/testdox/_files/WarningTest.php new file mode 100644 index 00000000000..48925d3cc79 --- /dev/null +++ b/tests/end-to-end/testdox/_files/WarningTest.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\TestDox; + +use function trigger_error; +use PHPUnit\Framework\TestCase; + +final class WarningTest extends TestCase +{ + public function testWarning(): void + { + trigger_error('warning', E_USER_WARNING); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/testdox/risky-test-colorized.phpt b/tests/end-to-end/testdox/risky-test-colorized.phpt index b3e30403ae0..6b36a558ff2 100644 --- a/tests/end-to-end/testdox/risky-test-colorized.phpt +++ b/tests/end-to-end/testdox/risky-test-colorized.phpt @@ -20,7 +20,14 @@ Runtime: %s Time: %s, Memory: %s Risky (PHPUnit\TestFixture\TestDox\Risky) - ☢ This is a useless test that does not test anything + ⚠ This is a useless test that does not test anything + +There was 1 risky test: + +1) PHPUnit\TestFixture\TestDox\RiskyTest::test_this_is_a_useless_test_that_does_not_test_anything +This test did not perform any assertions + +%s:16 OK, but there were issues! Tests: 1, Assertions: 0, Risky: 1. diff --git a/tests/end-to-end/testdox/risky-test.phpt b/tests/end-to-end/testdox/risky-test.phpt index 2b7586b1efc..4cf3ec43df4 100644 --- a/tests/end-to-end/testdox/risky-test.phpt +++ b/tests/end-to-end/testdox/risky-test.phpt @@ -20,7 +20,14 @@ Runtime: %s Time: %s, Memory: %s Risky (PHPUnit\TestFixture\TestDox\Risky) - ☢ This is a useless test that does not test anything + ⚠ This is a useless test that does not test anything + +There was 1 risky test: + +1) PHPUnit\TestFixture\TestDox\RiskyTest::test_this_is_a_useless_test_that_does_not_test_anything +This test did not perform any assertions + +%s:16 OK, but there were issues! Tests: 1, Assertions: 0, Risky: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt b/tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt new file mode 100644 index 00000000000..e1a02cdf59e --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-deprecation-default.phpt @@ -0,0 +1,26 @@ +--TEST-- +TestDox: Test triggers deprecation and --display-deprecations is not used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Deprecation (PHPUnit\TestFixture\TestDox\Deprecation) + ⚠ Deprecation + +OK, but there were issues! +Tests: 1, Assertions: 1, Deprecations: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt b/tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt new file mode 100644 index 00000000000..8638fde2956 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-deprecation-details.phpt @@ -0,0 +1,37 @@ +--TEST-- +TestDox: Test triggers deprecation and --display-deprecations is used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Deprecation (PHPUnit\TestFixture\TestDox\Deprecation) + ⚠ Deprecation + +1 test triggered 1 deprecation: + +1) %sDeprecationTest.php:19 +deprecation + +Triggered by: + +* PHPUnit\TestFixture\TestDox\DeprecationTest::testDeprecation + %sDeprecationTest.php:17 + +OK, but there were issues! +Tests: 1, Assertions: 1, Deprecations: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-notice-default.phpt b/tests/end-to-end/testdox/test-that-triggers-notice-default.phpt new file mode 100644 index 00000000000..eda8af96993 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-notice-default.phpt @@ -0,0 +1,26 @@ +--TEST-- +TestDox: Test triggers notice and --display-notices is not used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Notice (PHPUnit\TestFixture\TestDox\Notice) + ⚠ Notice + +OK, but there were issues! +Tests: 1, Assertions: 1, Notices: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-notice-details.phpt b/tests/end-to-end/testdox/test-that-triggers-notice-details.phpt new file mode 100644 index 00000000000..918c473170d --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-notice-details.phpt @@ -0,0 +1,37 @@ +--TEST-- +TestDox: Test triggers notice and --display-notices is used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Notice (PHPUnit\TestFixture\TestDox\Notice) + ⚠ Notice + +1 test triggered 1 notice: + +1) %sNoticeTest.php:19 +notice + +Triggered by: + +* PHPUnit\TestFixture\TestDox\NoticeTest::testNotice + %sNoticeTest.php:17 + +OK, but there were issues! +Tests: 1, Assertions: 1, Notices: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-warning-default.phpt b/tests/end-to-end/testdox/test-that-triggers-warning-default.phpt new file mode 100644 index 00000000000..34123752399 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-warning-default.phpt @@ -0,0 +1,26 @@ +--TEST-- +TestDox: Test triggers warning and --display-warning is not used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Warning (PHPUnit\TestFixture\TestDox\Warning) + ⚠ Warning + +OK, but there were issues! +Tests: 1, Assertions: 1, Warnings: 1. diff --git a/tests/end-to-end/testdox/test-that-triggers-warning-details.phpt b/tests/end-to-end/testdox/test-that-triggers-warning-details.phpt new file mode 100644 index 00000000000..1578ed3f719 --- /dev/null +++ b/tests/end-to-end/testdox/test-that-triggers-warning-details.phpt @@ -0,0 +1,37 @@ +--TEST-- +TestDox: Test triggers warning and --display-warning is used +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +Time: %s, Memory: %s + +Warning (PHPUnit\TestFixture\TestDox\Warning) + ⚠ Warning + +1 test triggered 1 warning: + +1) %sWarningTest.php:19 +warning + +Triggered by: + +* PHPUnit\TestFixture\TestDox\WarningTest::testWarning + %sWarningTest.php:17 + +OK, but there were issues! +Tests: 1, Assertions: 1, Warnings: 1. diff --git a/tests/unit/Event/FacadeTest.php b/tests/unit/Event/FacadeTest.php new file mode 100644 index 00000000000..42d4df6dcb0 --- /dev/null +++ b/tests/unit/Event/FacadeTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Event; + +use PHPUnit\Event\Tracer\Tracer; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\TestCase; + +#[CoversClass(Facade::class)] +#[Small] +final class FacadeTest extends TestCase +{ + public function testSubscriberRegistrationDoesNotWorkWhenEventFacadeIsSealed(): void + { + $this->expectException(EventFacadeIsSealedException::class); + + Facade::instance()->registerSubscriber( + new class implements Subscriber + {}, + ); + } + + public function testTracerRegistrationDoesNotWorkWhenEventFacadeIsSealed(): void + { + $this->expectException(EventFacadeIsSealedException::class); + + Facade::instance()->registerTracer( + new class implements Tracer + { + public function trace(Event $event): void + { + } + }, + ); + } +} diff --git a/tests/unit/Event/Value/Telemetry/GarbageCollectorStatusTest.php b/tests/unit/Event/Value/Telemetry/GarbageCollectorStatusTest.php index d962c717d65..436f24ff7c8 100644 --- a/tests/unit/Event/Value/Telemetry/GarbageCollectorStatusTest.php +++ b/tests/unit/Event/Value/Telemetry/GarbageCollectorStatusTest.php @@ -88,6 +88,34 @@ public function testMayNotHaveExtendedInformation(): void $this->assertFalse($this->withoutDetails()->hasExtendedInformation()); } + public function testMayNotHaveApplicationTime(): void + { + $this->expectException(RuntimeException::class); + + $this->withoutDetails()->applicationTime(); + } + + public function testMayNotHaveCollectorTime(): void + { + $this->expectException(RuntimeException::class); + + $this->withoutDetails()->collectorTime(); + } + + public function testMayNotHaveDestructorTime(): void + { + $this->expectException(RuntimeException::class); + + $this->withoutDetails()->destructorTime(); + } + + public function testMayNotHaveFreeTime(): void + { + $this->expectException(RuntimeException::class); + + $this->withoutDetails()->freeTime(); + } + public function testMayNotHaveRunning(): void { $this->expectException(RuntimeException::class); diff --git a/tests/unit/Event/Value/Telemetry/SystemTest.php b/tests/unit/Event/Value/Telemetry/SystemTest.php index 87047b64850..40d5c0579fe 100644 --- a/tests/unit/Event/Value/Telemetry/SystemTest.php +++ b/tests/unit/Event/Value/Telemetry/SystemTest.php @@ -24,7 +24,7 @@ public function testSnapshotReturnsSnapshot(): void $clock = new class($time) implements StopWatch { - private readonly \PHPUnit\Event\Telemetry\HRTime $time; + private readonly HRTime $time; public function __construct(HRTime $time) { diff --git a/tests/unit/Event/Value/Test/TestData/TestDataCollectionTest.php b/tests/unit/Event/Value/Test/TestData/TestDataCollectionTest.php new file mode 100644 index 00000000000..c5b081d7ef8 --- /dev/null +++ b/tests/unit/Event/Value/Test/TestData/TestDataCollectionTest.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Event\TestData; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\Attributes\UsesClass; +use PHPUnit\Framework\TestCase; + +#[CoversClass(TestDataCollection::class)] +#[CoversClass(TestDataCollectionIterator::class)] +#[UsesClass(TestData::class)] +#[UsesClass(DataFromDataProvider::class)] +#[UsesClass(DataFromTestDependency::class)] +#[Small] +final class TestDataCollectionTest extends TestCase +{ + public function testMayBeEmpty(): void + { + $collection = TestDataCollection::fromArray([]); + + $this->assertCount(0, $collection); + $this->assertFalse($collection->hasDataFromDataProvider()); + } + + public function testMayContainDataFromDataProvider(): void + { + $data = $this->dataFromDataProvider(); + $collection = TestDataCollection::fromArray([$data]); + + $this->assertTrue($collection->hasDataFromDataProvider()); + $this->assertSame([$data], $collection->asArray()); + $this->assertSame($data, $collection->dataFromDataProvider()); + } + + public function testMayContainDataFromDependedUponTest(): void + { + $data = $this->dataFromDependedUponTest(); + $collection = TestDataCollection::fromArray([$data]); + + $this->assertFalse($collection->hasDataFromDataProvider()); + $this->assertSame([$data], $collection->asArray()); + } + + public function testMayNotContainMoreThanOneDataSetFromDataProvider(): void + { + $this->expectException(MoreThanOneDataSetFromDataProviderException::class); + + TestDataCollection::fromArray([$this->dataFromDataProvider(), $this->dataFromDataProvider()]); + } + + public function testExceptionIsRaisedWhenDataFromDataProviderIsAccessedButDoesNotExist(): void + { + $collection = TestDataCollection::fromArray([]); + + $this->expectException(NoDataSetFromDataProviderException::class); + + $collection->dataFromDataProvider(); + } + + public function testIsIterable(): void + { + $data = $this->dataFromDataProvider(); + $collection = TestDataCollection::fromArray([$data]); + + foreach ($collection as $index => $element) { + $this->assertSame(0, $index); + $this->assertSame($data, $element); + } + } + + private function dataFromDataProvider(): DataFromDataProvider + { + return DataFromDataProvider::from( + 'data-set-name', + 'data-as-string', + 'data-as-string-for-output', + ); + } + + private function dataFromDependedUponTest(): DataFromTestDependency + { + return DataFromTestDependency::from('data-as-string'); + } +} diff --git a/tests/unit/Event/Value/Test/TestData/TestDataTest.php b/tests/unit/Event/Value/Test/TestData/TestDataTest.php new file mode 100644 index 00000000000..6d8f613428e --- /dev/null +++ b/tests/unit/Event/Value/Test/TestData/TestDataTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Event\TestData; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\TestCase; + +#[CoversClass(TestData::class)] +#[CoversClass(DataFromDataProvider::class)] +#[CoversClass(DataFromTestDependency::class)] +#[Small] +final class TestDataTest extends TestCase +{ + public function testDataCanBeFromDataProvider(): void + { + $name = 'data-set-name'; + $dataAsString = 'data-as-string'; + $dataAsStringForOutput = 'data-as-string-for-output'; + + $data = DataFromDataProvider::from( + $name, + $dataAsString, + $dataAsStringForOutput, + ); + + $this->assertTrue($data->isFromDataProvider()); + $this->assertFalse($data->isFromTestDependency()); + $this->assertSame($name, $data->dataSetName()); + $this->assertSame($dataAsString, $data->data()); + $this->assertSame($dataAsStringForOutput, $data->dataAsStringForResultOutput()); + } + + public function testDataCanBeFromDependedUponTest(): void + { + $dataAsString = 'data-as-string'; + + $data = DataFromTestDependency::from($dataAsString); + + $this->assertTrue($data->isFromTestDependency()); + $this->assertFalse($data->isFromDataProvider()); + $this->assertSame($dataAsString, $data->data()); + } +} diff --git a/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php b/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php index de36fdf7d90..4afd01428f9 100644 --- a/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php +++ b/tests/unit/Event/Value/TestSuite/TestSuiteBuilderTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestSuite as FrameworkTestSuite; +use PHPUnit\Runner\Filter\Factory; use PHPUnit\TextUI\CliArguments\Builder as CliArgumentsBuilder; use PHPUnit\TextUI\Configuration\Merger as ConfigurationMerger; use PHPUnit\TextUI\XmlConfiguration\Loader as XmlConfigurationLoader; @@ -29,9 +30,23 @@ public function test_Builds_TestSuite_value_object_for_test_suite_loaded_from_XM $this->assertTrue($testSuite->isWithName()); $this->assertStringEndsWith('phpunit.xml', $testSuite->name()); $this->assertSame(3, $testSuite->count()); + $this->assertSame(3, $testSuite->tests()->count()); $this->assertCount(3, $testSuite->tests()); } + public function testBuildCountWithFilter(): void + { + $testSuite = $this->testSuiteFromXmlConfiguration(); + $filterFactory = new Factory; + $filterFactory->addNameFilter('one'); + $testSuite->injectFilter($filterFactory); + $testSuite = TestSuiteBuilder::from($testSuite); + + $this->assertSame(1, $testSuite->count()); + $this->assertSame(1, $testSuite->tests()->count()); + $this->assertCount(1, $testSuite->tests()); + } + public function test_Builds_TestSuite_value_object_for_test_case_class(): void { $testSuite = TestSuiteBuilder::from($this->testSuiteFromXmlConfiguration()->tests()[0]->tests()[0]); diff --git a/tests/unit/Event/Value/TestSuite/TestSuiteTest.php b/tests/unit/Event/Value/TestSuite/TestSuiteTest.php new file mode 100644 index 00000000000..78a0fca3312 --- /dev/null +++ b/tests/unit/Event/Value/TestSuite/TestSuiteTest.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Event\TestSuite; + +use PHPUnit\Event\Code\TestCollection; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\TestCase; + +#[CoversClass(TestSuite::class)] +#[CoversClass(TestSuiteForTestClass::class)] +#[CoversClass(TestSuiteForTestMethodWithDataProvider::class)] +#[CoversClass(TestSuiteWithName::class)] +#[Small] +final class TestSuiteTest extends TestCase +{ + public function testCanBeTestSuiteForTestClass(): void + { + $className = 'ExampleTest'; + $size = 0; + $tests = TestCollection::fromArray([]); + $file = 'ExampleTest.php'; + $line = 1; + + $testSuite = new TestSuiteForTestClass($className, $size, $tests, $file, $line); + + $this->assertTrue($testSuite->isForTestClass()); + $this->assertFalse($testSuite->isForTestMethodWithDataProvider()); + $this->assertFalse($testSuite->isWithName()); + + $this->assertSame($className, $testSuite->className()); + $this->assertSame($className, $testSuite->name()); + $this->assertSame($size, $testSuite->count()); + $this->assertSame($tests, $testSuite->tests()); + $this->assertSame($file, $testSuite->file()); + $this->assertSame($line, $testSuite->line()); + } + + public function testCanBeTestSuiteForTestMethodWithDataProvider(): void + { + $name = 'ExampleTest::testOne'; + $className = 'ExampleTest'; + $methodName = 'testOne'; + $size = 0; + $tests = TestCollection::fromArray([]); + $file = 'ExampleTest.php'; + $line = 1; + + $testSuite = new TestSuiteForTestMethodWithDataProvider($name, $size, $tests, $className, $methodName, $file, $line); + + $this->assertFalse($testSuite->isForTestClass()); + $this->assertTrue($testSuite->isForTestMethodWithDataProvider()); + $this->assertFalse($testSuite->isWithName()); + + $this->assertSame($name, $testSuite->name()); + $this->assertSame($className, $testSuite->className()); + $this->assertSame($methodName, $testSuite->methodName()); + $this->assertSame($size, $testSuite->count()); + $this->assertSame($tests, $testSuite->tests()); + $this->assertSame($file, $testSuite->file()); + $this->assertSame($line, $testSuite->line()); + } + + public function testCanBeTestSuiteWithName(): void + { + $name = 'the-name'; + $size = 0; + $tests = TestCollection::fromArray([]); + + $testSuite = new TestSuiteWithName($name, $size, $tests); + + $this->assertFalse($testSuite->isForTestClass()); + $this->assertFalse($testSuite->isForTestMethodWithDataProvider()); + $this->assertTrue($testSuite->isWithName()); + + $this->assertSame($name, $testSuite->name()); + $this->assertSame($size, $testSuite->count()); + $this->assertSame($tests, $testSuite->tests()); + } +} diff --git a/tests/unit/Event/Value/ThrowableTest.php b/tests/unit/Event/Value/ThrowableTest.php index 1cf89266d30..c67d25dd88b 100644 --- a/tests/unit/Event/Value/ThrowableTest.php +++ b/tests/unit/Event/Value/ThrowableTest.php @@ -46,7 +46,7 @@ public function testCanBeCreatedForThrowableWithPrevious(): void $this->assertSame(Exception::class, $t->className()); $this->assertSame('second message', $t->message()); $this->assertSame("Exception: second message\n", $t->description()); - $this->assertSame(Filter::getFilteredStacktrace($second), $t->stackTrace()); + $this->assertSame(Filter::getFilteredStacktrace($second, false), $t->stackTrace()); $this->assertTrue($t->hasPrevious()); $previous = $t->previous(); @@ -54,7 +54,7 @@ public function testCanBeCreatedForThrowableWithPrevious(): void $this->assertSame(Exception::class, $previous->className()); $this->assertSame('first message', $previous->message()); $this->assertSame("Exception: first message\n", $previous->description()); - $this->assertSame(Filter::getFilteredStacktrace($first), $t->stackTrace()); + $this->assertSame(Filter::getFilteredStacktrace($first), $previous->stackTrace()); $this->assertStringMatchesFormat( <<<'EOD' diff --git a/tests/unit/Framework/AssertTest.php b/tests/unit/Framework/AssertTest.php index e44984edbd4..75a4ce220a4 100644 --- a/tests/unit/Framework/AssertTest.php +++ b/tests/unit/Framework/AssertTest.php @@ -1570,6 +1570,29 @@ public function testAssertStringNotMatchesFormatFile(): void $this->assertStringNotMatchesFormatFile(TEST_FILES_PATH . 'expectedFileFormat.txt', "FOO\n"); } + public function testAssertFileEqualsCanonicalizing(): void + { + $this->assertFileNotEquals(TEST_FILES_PATH . 'foo.txt', TEST_FILES_PATH . 'bar.txt'); + $this->assertFileEqualsCanonicalizing(TEST_FILES_PATH . 'foo.txt', TEST_FILES_PATH . 'foo.txt'); + + $this->expectException(AssertionFailedError::class); + + $this->assertFileEqualsCanonicalizing(TEST_FILES_PATH . 'foo.txt', TEST_FILES_PATH . 'foo.xml'); + } + + public function testAssertStringNotEqualsFileCanonicalizing(): void + { + $contents = file_get_contents(TEST_FILES_PATH . 'foo.xml'); + + $this->assertStringNotEqualsFileCanonicalizing(TEST_FILES_PATH . 'foo.xml', $contents . ' BAR'); + + $this->assertStringNotEqualsFileCanonicalizing(TEST_FILES_PATH . 'foo.xml', 'BAR'); + + $this->expectException(AssertionFailedError::class); + + $this->assertStringNotEqualsFileCanonicalizing(TEST_FILES_PATH . 'foo.xml', $contents); + } + public function testStringsCanBeComparedForEqualityIgnoringCase(): void { $this->assertEqualsIgnoringCase('a', 'A'); diff --git a/tests/unit/Framework/Constraint/Operator/LogicalNotTest.php b/tests/unit/Framework/Constraint/Operator/LogicalNotTest.php index fee82e4d4b3..882f81ed799 100644 --- a/tests/unit/Framework/Constraint/Operator/LogicalNotTest.php +++ b/tests/unit/Framework/Constraint/Operator/LogicalNotTest.php @@ -9,9 +9,12 @@ */ namespace PHPUnit\Framework\Constraint; +use PHPUnit\Framework\Assert; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\Ticket; use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; @@ -127,4 +130,16 @@ public function testIsCountable(): void $this->assertCount(2, $constraint); } + + #[TestDox('LogicalNot(IsEqual(\'test contains something\')) is handled correctly')] + #[Ticket('https://github.com/sebastianbergmann/phpunit/issues/5516')] + public function testForNotEqualsWithStringThatContainsContains(): void + { + $constraint = new LogicalNot(new IsEqual('test contains something')); + + $this->expectException(ExpectationFailedException::class); + $this->expectExceptionMessage("Failed asserting that 'test contains something' is not equal to 'test contains something'."); + + Assert::assertThat('test contains something', $constraint); + } } diff --git a/tests/unit/Framework/MockObject/MockObjectTest.php b/tests/unit/Framework/MockObject/MockObjectTest.php index 60001a73992..8031e993fe0 100644 --- a/tests/unit/Framework/MockObject/MockObjectTest.php +++ b/tests/unit/Framework/MockObject/MockObjectTest.php @@ -19,6 +19,7 @@ use PHPUnit\TestFixture\MockObject\AnInterface; use PHPUnit\TestFixture\MockObject\InterfaceWithImplicitProtocol; use PHPUnit\TestFixture\MockObject\InterfaceWithReturnTypeDeclaration; +use PHPUnit\TestFixture\MockObject\MethodWIthVariadicVariables; use ReflectionProperty; #[Group('test-doubles')] @@ -418,6 +419,36 @@ public function testExpectationsCannotHaveDuplicateIds(): void $this->fail(); } + public function testWillReturnCallbackWithVariadicVariables(): void + { + $mock = $this->createMock(MethodWIthVariadicVariables::class); + $mock->expects($this->once())->method('testVariadic') + ->withAnyParameters() + ->willReturnCallback(static fn ($string, ...$arguments) => [$string, ...$arguments]); + + $testData = ['foo', 'bar', 'biz' => 'kuz']; + $actual = $mock->testVariadic(...$testData); + + $this->assertSame($testData, $actual); + } + + public function testExpectationsAreClonedWhenTestDoubleIsCloned(): void + { + $double = $this->createMock(InterfaceWithReturnTypeDeclaration::class); + + $double->expects($this->exactly(2))->method('doSomething'); + + $clone = clone $double; + + $double->expects($this->once())->method('doSomethingElse')->willReturn(1); + $clone->expects($this->once())->method('doSomethingElse')->willReturn(2); + + $this->assertFalse($double->doSomething()); + $this->assertFalse($clone->doSomething()); + $this->assertSame(1, $double->doSomethingElse(0)); + $this->assertSame(2, $clone->doSomethingElse(0)); + } + /** * @psalm-param class-string $type */ diff --git a/tests/unit/TextUI/Configuration/Xml/SchemaFinderTest.php b/tests/unit/TextUI/Configuration/Xml/SchemaFinderTest.php index 576aad41e2e..6b4f703a19f 100644 --- a/tests/unit/TextUI/Configuration/Xml/SchemaFinderTest.php +++ b/tests/unit/TextUI/Configuration/Xml/SchemaFinderTest.php @@ -9,6 +9,7 @@ */ namespace PHPUnit\TextUI\XmlConfiguration; +use function count; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Small; use PHPUnit\Framework\TestCase; @@ -18,12 +19,20 @@ #[Small] final class SchemaFinderTest extends TestCase { - public function testFindsExistingSchemaForComposerInstallation(): void + public function testListsAvailableSchemas(): void + { + $schemas = (new SchemaFinder)->available(); + + $this->assertSame((new Version)->series(), $schemas[0]); + $this->assertSame('8.5', $schemas[count($schemas) - 1]); + } + + public function testFindsExistingSchema(): void { $this->assertFileExists((new SchemaFinder)->find((new Version)->series())); } - public function testDoesNotFindNonExistentSchemaForComposerInstallation(): void + public function testDoesNotFindNonExistentSchema(): void { $this->expectException(CannotFindSchemaException::class); diff --git a/tests/unit/Util/FilesystemTest.php b/tests/unit/Util/FilesystemTest.php new file mode 100644 index 00000000000..273e2abc571 --- /dev/null +++ b/tests/unit/Util/FilesystemTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Util; + +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\TestCase; + +#[CoversClass(Filesystem::class)] +#[Small] +final class FilesystemTest extends TestCase +{ + public function testCanResolvePathOrStream(): void + { + $this->assertSame('php://stdout', Filesystem::resolvePathOrStream('php://stdout')); + $this->assertSame('socket://hostname:port', Filesystem::resolvePathOrStream('socket://hostname:port')); + $this->assertSame(__FILE__, Filesystem::resolvePathOrStream(__FILE__)); + $this->assertFalse(Filesystem::resolvePathOrStream(__DIR__ . '/does-not-exist')); + } +} diff --git a/tests/unit/Util/FilterTest.php b/tests/unit/Util/FilterTest.php new file mode 100644 index 00000000000..7976a06bfd5 --- /dev/null +++ b/tests/unit/Util/FilterTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\Util; + +use Exception; +use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\Small; +use PHPUnit\Framework\TestCase; + +#[CoversClass(Test::class)] +#[Small] +final class FilterTest extends TestCase +{ + public function testUnwrapThrowableUsesPreviousValues(): void + { + $first = new Exception('first', 123, null); + $second = new Exception('second', 345, $first); + + $this->assertSame(Filter::getFilteredStacktrace($second), Filter::getFilteredStacktrace($first)); + } +} diff --git a/tools/php-cs-fixer b/tools/php-cs-fixer index 9ad35530677..68a11611783 100755 Binary files a/tools/php-cs-fixer and b/tools/php-cs-fixer differ diff --git a/tools/psalm b/tools/psalm index 5df97c1e258..3edea88e0cb 100755 Binary files a/tools/psalm and b/tools/psalm differ