diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000000..ad14f6c48d6 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,47 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 60 + +# Number of days of inactivity before a stale Issue or Pull Request is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: 7 + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - blocked + - enhancement + - backward-compatibility-break + - feature-removal + - php-support-removal + - process + - rfc + - refactoring + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Label to use when marking as stale +staleLabel: stale + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had activity within the last 60 days. It will be closed after 7 days if no further activity occurs. Thank you for your contributions. + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Comment to post when closing a stale Issue or Pull Request. +closeComment: > + This issue has been automatically closed because it has not had activity since it was marked as stale. Thank you for your contributions. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Limit to only `issues` or `pulls` +only: issues + diff --git a/.php_cs.dist b/.php_cs.dist index e23e1e35851..3b3c086a060 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -164,8 +164,6 @@ return PhpCsFixer\Config::create() ->files() ->in(__DIR__ . '/build') ->in(__DIR__ . '/src') - ->in(__DIR__ . '/tests/Framework') - ->in(__DIR__ . '/tests/Runner') - ->in(__DIR__ . '/tests/Util') - ->name('*.php') + ->in(__DIR__ . '/tests') + ->notName('*.phpt') ); diff --git a/ChangeLog-5.7.md b/ChangeLog-5.7.md deleted file mode 100644 index c8c778748d3..00000000000 --- a/ChangeLog-5.7.md +++ /dev/null @@ -1,242 +0,0 @@ -# Changes in PHPUnit 5.7 - -All notable changes of the PHPUnit 5.7 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. - -## [5.7.27] - 2018-02-01 - -### Fixed - -* Fixed [#2236](https://github.com/sebastianbergmann/phpunit/issues/2236): Exceptions in `tearDown()` do not affect `getStatus()` -* Fixed [#2950](https://github.com/sebastianbergmann/phpunit/issues/2950): Class extending `PHPUnit\Framework\TestSuite` does not extend `PHPUnit\FrameworkTestCase` -* Fixed [#2972](https://github.com/sebastianbergmann/phpunit/issues/2972): PHPUnit crashes when test suite contains both `.phpt` files and unconventionally named tests - -## [5.7.26] - 2017-12-17 - -### Fixed - -* Fixed [#2472](https://github.com/sebastianbergmann/phpunit/issues/2472): `PHPUnit\Util\Getopt` uses deprecated `each()` function -* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered -* Fixed [#2922](https://github.com/sebastianbergmann/phpunit/issues/2922): Test class is not discovered when there is a test class with `@group` and provider throwing exception in it, tests are run with `--exclude-group` for that group, there is another class called later (after the class from above), and the name of that another class does not match its filename - -## [5.7.25] - 2017-11-14 - -### Fixed - -* Fixed [#2859](https://github.com/sebastianbergmann/phpunit/issues/2859): Regression caused by fix for [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833) - -## [5.7.24] - 2017-11-14 - -### Fixed - -* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered - -## [5.7.23] - 2017-10-15 - -### Fixed - -* Fixed [#2731](https://github.com/sebastianbergmann/phpunit/issues/2731): Empty exception message cannot be expected - -## [5.7.22] - 2017-09-24 - -### Fixed - -* Fixed [#2769](https://github.com/sebastianbergmann/phpunit/issues/2769): Usage of `setUseErrorHandler()` produces `Undefined variable` error - -## [5.7.21] - 2017-06-21 - -### Added - -* Added `PHPUnit\Framework\AssertionFailedError`, `PHPUnit\Framework\Test`, and `PHPUnit\Framework\TestSuite` to the forward compatibility layer for PHPUnit 6 - -### Fixed - -* Fixed [#2705](https://github.com/sebastianbergmann/phpunit/issues/2705): `stderr` parameter in `phpunit.xml` always considered `true` - -## [5.7.20] - 2017-05-22 - -### Fixed - -* Fixed [#2563](https://github.com/sebastianbergmann/phpunit/pull/2563): `phpunit --version` does not display version when running unsupported PHP - -## [5.7.19] - 2017-04-03 - -### Fixed - -* Fixed [#2638](https://github.com/sebastianbergmann/phpunit/pull/2638): Regression in `PHPUnit\Framework\TestCase:registerMockObjectsFromTestArguments()` - -## [5.7.18] - 2017-04-02 - -### Fixed - -* Fixed [#2145](https://github.com/sebastianbergmann/phpunit/issues/2145): `--stop-on-failure` fails to stop on PHP 7 -* Fixed [#2572](https://github.com/sebastianbergmann/phpunit/issues/2572): `PHPUnit\Framework\TestCase:registerMockObjectsFromTestArguments()` does not correctly handle arrays that reference themselves - -## [5.7.17] - 2017-03-19 - -### Fixed - -* Fixed [#2016](https://github.com/sebastianbergmann/phpunit/issues/2016): `prophesize()` does not work when static attributes are backed up -* Fixed [#2568](https://github.com/sebastianbergmann/phpunit/issues/2568): `ArraySubsetConstraint` uses invalid cast to array -* Fixed [#2573](https://github.com/sebastianbergmann/phpunit/issues/2573): `getMockFromWsdl()` does not handle URLs with query parameters -* `PHPUnit\Util\Test::getDataFromTestWithAnnotation()` raises notice when docblock contains Windows line endings - -## [5.7.16] - 2017-03-15 - -### Fixed - -* Fixed [#2547](https://github.com/sebastianbergmann/phpunit/issues/2547): Code Coverage data is collected for test annotated with `@coversNothing` -* Fixed [#2558](https://github.com/sebastianbergmann/phpunit/issues/2558): `countOf()` function is missing - -## [5.7.15] - 2017-03-02 - -### Fixed - -* Fixed [#1999](https://github.com/sebastianbergmann/phpunit/issues/1999): Handler is inherited from previous custom option with handler -* Fixed [#2149](https://github.com/sebastianbergmann/phpunit/issues/2149): `assertCount()` does not handle generators properly -* Fixed [#2478](https://github.com/sebastianbergmann/phpunit/issues/2478): Tests that take too long are not reported as risky test - -## [5.7.14] - 2017-02-19 - -### Fixed - -* Fixed [#2489](https://github.com/sebastianbergmann/phpunit/issues/2489): `processUncoveredFilesFromWhitelist` is not handled correctly -* Fixed default values for `addUncoveredFilesFromWhitelist` and `processUncoveredFilesFromWhitelist` in `phpunit.xsd` - -## [5.7.13] - 2017-02-10 - -### Fixed - -* Fixed [#2493](https://github.com/sebastianbergmann/phpunit/issues/2493): Fix for [#2475](https://github.com/sebastianbergmann/phpunit/pull/2475) does not apply to PHPUnit 5.7 - -## [5.7.12] - 2017-02-08 - -### Fixed - -* Fixed [#2475](https://github.com/sebastianbergmann/phpunit/pull/2475): Defining a test suite with only one file does not work - -## [5.7.11] - 2017-02-05 - -### Fixed - -* Deprecation errors when used with PHP 7.2 - -## [5.7.10] - 2017-02-04 - -### Fixed - -* Fixed [#2462](https://github.com/sebastianbergmann/phpunit/issues/2462): Code Coverage whitelist is filled even if no code coverage data is to be collected - -## [5.7.9] - 2017-01-28 - -### Fixed - -* Fixed [#2447](https://github.com/sebastianbergmann/phpunit/issues/2447): Reverted backwards incompatible change to handling of boolean environment variable values specified in XML - -## [5.7.8] - 2017-01-26 - -### Fixed - -* Fixed [#2446](https://github.com/sebastianbergmann/phpunit/issues/2446): Reverted backwards incompatible change to exit code in case of warnings - -## [5.7.7] - 2017-01-25 - -### Fixed - -* Fixed [#1896](https://github.com/sebastianbergmann/phpunit/issues/1896): Wrong test location when `@depends` and `@dataProvider` are combined -* Fixed [#1983](https://github.com/sebastianbergmann/phpunit/pull/1983): Tests with `@expectedException` annotation cannot be skipped -* Fixed [#2137](https://github.com/sebastianbergmann/phpunit/issues/2137): Warnings for invalid data providers are suppressed when test execution is filtered -* Fixed [#2275](https://github.com/sebastianbergmann/phpunit/pull/2275): Invalid UTF-8 characters can lead to missing output -* Fixed [#2299](https://github.com/sebastianbergmann/phpunit/issues/2299): `expectExceptionMessage()` and `expectExceptionCode()` do not work without `expectException()` -* Fixed [#2328](https://github.com/sebastianbergmann/phpunit/issues/2328): `TestListener` callbacks `startTest()` and `endTest()` are not called when test is skipped due to `@depends` -* Fixed [#2331](https://github.com/sebastianbergmann/phpunit/issues/2331): Boolean environment variable values specified in XML get mangled -* Fixed [#2333](https://github.com/sebastianbergmann/phpunit/issues/2333): `assertContains()` and `assertNotContains()` do not handle UTF-8 strings correctly -* Fixed [#2340](https://github.com/sebastianbergmann/phpunit/pull/2340): Data providers that use `yield` or implement `Iterator` cannot be combined -* Fixed [#2349](https://github.com/sebastianbergmann/phpunit/pull/2349): `PHPUnit_TextUI_Command` does not `exit()` when it should -* Fixed [#2392](https://github.com/sebastianbergmann/phpunit/issues/2392): Empty (but valid) data provider should skip the test -* Fixed [#2431](https://github.com/sebastianbergmann/phpunit/issues/2431): `assertArraySubset()` does not support `ArrayAccess` -* Fixed [#2435](https://github.com/sebastianbergmann/phpunit/issues/2435): Empty `@group` annotation causes error on PHP 7.2+ - -## [5.7.6] - 2017-01-22 - -### Fixed - -* Fixed [#2424](https://github.com/sebastianbergmann/phpunit/issues/2424): `TestCase::getStatus()` returns `STATUS_PASSED` instead of `STATUS_RISKY` for risky test -* Fixed [#2427](https://github.com/sebastianbergmann/phpunit/issues/2427): TestDox group configuration is not handled -* Fixed [#2428](https://github.com/sebastianbergmann/phpunit/pull/2428): Nested arrays specificied in XML configuration file are not handled correctly - -## [5.7.5] - 2016-12-28 - -### Fixed - -* Fixed [#2404](https://github.com/sebastianbergmann/phpunit/pull/2404): `assertDirectoryNotIsWriteable()` calls itself - -## [5.7.4] - 2016-12-13 - -### Fixed - -* Fixed [#2394](https://github.com/sebastianbergmann/phpunit/issues/2394): Do not treat `AssertionError` as assertion failure on PHP 5 - -## [5.7.3] - 2016-12-09 - -### Fixed - -* Fixed [#2384](https://github.com/sebastianbergmann/phpunit/pull/2384): Handle `PHPUnit_Framework_Exception` correctly when expecting exceptions - -## [5.7.2] - 2016-12-03 - -### Fixed - -* Fixed [#2382](https://github.com/sebastianbergmann/phpunit/issues/2382): Uncloneable test doubles passed via data provider do not work - -## [5.7.1] - 2016-12-02 - -### Fixed - -* Fixed [#2380](https://github.com/sebastianbergmann/phpunit/issues/2380): Data Providers cannot be generators anymore - -## [5.7.0] - 2016-12-02 - -### Added - -* Merged [#2223](https://github.com/sebastianbergmann/phpunit/pull/2223): Add support for multiple data providers -* Added `extensionsDirectory` configuration directive to configure a directory from which all `.phar` files are loaded as PHPUnit extensions -* Added `--no-extensions` commandline option to suppress loading of extensions (from configured extension directory) -* Added `PHPUnit\Framework\Assert` as an alias for `PHPUnit_Framework_Assert` for forward compatibility -* Added `PHPUnit\Framework\BaseTestListener` as an alias for `PHPUnit_Framework_BaseTestListener` for forward compatibility -* Added `PHPUnit\Framework\TestListener` as an alias for `PHPUnit_Framework_TestListener` for forward compatibility - -### Changed - -* The `--log-json` commandline option has been deprecated -* The `--tap` and `--log-tap` commandline options have been deprecated -* The `--self-update` and `--self-upgrade` commandline options have been deprecated (PHAR binary only) - -[5.7.27]: https://github.com/sebastianbergmann/phpunit/compare/5.7.26...5.7.27 -[5.7.26]: https://github.com/sebastianbergmann/phpunit/compare/5.7.25...5.7.26 -[5.7.25]: https://github.com/sebastianbergmann/phpunit/compare/5.7.24...5.7.25 -[5.7.24]: https://github.com/sebastianbergmann/phpunit/compare/5.7.23...5.7.24 -[5.7.23]: https://github.com/sebastianbergmann/phpunit/compare/5.7.22...5.7.23 -[5.7.22]: https://github.com/sebastianbergmann/phpunit/compare/5.7.21...5.7.22 -[5.7.21]: https://github.com/sebastianbergmann/phpunit/compare/5.7.20...5.7.21 -[5.7.20]: https://github.com/sebastianbergmann/phpunit/compare/5.7.19...5.7.20 -[5.7.19]: https://github.com/sebastianbergmann/phpunit/compare/5.7.18...5.7.19 -[5.7.18]: https://github.com/sebastianbergmann/phpunit/compare/5.7.17...5.7.18 -[5.7.17]: https://github.com/sebastianbergmann/phpunit/compare/5.7.16...5.7.17 -[5.7.16]: https://github.com/sebastianbergmann/phpunit/compare/5.7.15...5.7.16 -[5.7.15]: https://github.com/sebastianbergmann/phpunit/compare/5.7.14...5.7.15 -[5.7.14]: https://github.com/sebastianbergmann/phpunit/compare/5.7.13...5.7.14 -[5.7.13]: https://github.com/sebastianbergmann/phpunit/compare/5.7.12...5.7.13 -[5.7.12]: https://github.com/sebastianbergmann/phpunit/compare/5.7.11...5.7.12 -[5.7.11]: https://github.com/sebastianbergmann/phpunit/compare/5.7.10...5.7.11 -[5.7.10]: https://github.com/sebastianbergmann/phpunit/compare/5.7.9...5.7.10 -[5.7.9]: https://github.com/sebastianbergmann/phpunit/compare/5.7.8...5.7.9 -[5.7.8]: https://github.com/sebastianbergmann/phpunit/compare/5.7.7...5.7.8 -[5.7.7]: https://github.com/sebastianbergmann/phpunit/compare/5.7.6...5.7.7 -[5.7.6]: https://github.com/sebastianbergmann/phpunit/compare/5.7.5...5.7.6 -[5.7.5]: https://github.com/sebastianbergmann/phpunit/compare/5.7.4...5.7.5 -[5.7.4]: https://github.com/sebastianbergmann/phpunit/compare/5.7.3...5.7.4 -[5.7.3]: https://github.com/sebastianbergmann/phpunit/compare/5.7.2...5.7.3 -[5.7.2]: https://github.com/sebastianbergmann/phpunit/compare/5.7.1...5.7.2 -[5.7.1]: https://github.com/sebastianbergmann/phpunit/compare/5.7.0...5.7.1 -[5.7.0]: https://github.com/sebastianbergmann/phpunit/compare/5.6...5.7.0 - diff --git a/ChangeLog-6.5.md b/ChangeLog-6.5.md index e89aa24b8c9..8a703bc03d4 100644 --- a/ChangeLog-6.5.md +++ b/ChangeLog-6.5.md @@ -2,7 +2,7 @@ All notable changes of the PHPUnit 6.5 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. -## [6.5.8] - 2018-MM-DD +## [6.5.8] - 2018-04-10 ### Fixed diff --git a/ChangeLog-7.1.md b/ChangeLog-7.1.md index c56fa6688cb..2ce48de87de 100644 --- a/ChangeLog-7.1.md +++ b/ChangeLog-7.1.md @@ -2,13 +2,25 @@ All notable changes of the PHPUnit 7.1 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. -## [7.1.2] - 2018-MM-DD +## [7.1.4] - 2018-04-18 + +### Fixed + +* Fixed [#3034](https://github.com/sebastianbergmann/phpunit/pull/3034): `$this->getStatus()` returns `STATUS_PASSED` in `tearDown()` after unexpected exception + +## [7.1.3] - 2018-04-13 + +### Fixed + +* Fixed [#3094](https://github.com/sebastianbergmann/phpunit/issues/3094): Faulty dependency constraint affecting `getObjectForTrait()` (failure using `--prefer-lowest`) + +## [7.1.2] - 2018-04-10 ### Fixed * Fixed [#2830](https://github.com/sebastianbergmann/phpunit/issues/2830): `@runClassInSeparateProcess` does not work for tests that use `@dataProvider` * Fixed [#3059](https://github.com/sebastianbergmann/phpunit/pull/3059): `StringMatchesFormatDescription` constraint fails when matching multiline with `\r\n` -* Fixed [#3083](https://github.com/sebastianbergmann/phpunit/pull/3083): `@runClassInSeparateProcess` and `@dataProvider` cannot be used together +* Fixed [#3087](https://github.com/sebastianbergmann/phpunit/pull/3087): `TestCase::getTestResultObject()` can return `null` ## [7.1.1] - 2018-04-06 @@ -28,6 +40,8 @@ All notable changes of the PHPUnit 7.1 release series are documented in this fil * `PHPUnit\Framework\Assert` is no longer searched for test methods * `ReflectionMethod::invokeArgs()` is no longer used to invoke test methods +[7.1.4]: https://github.com/sebastianbergmann/phpunit/compare/7.1.3...7.1.4 +[7.1.3]: https://github.com/sebastianbergmann/phpunit/compare/7.1.2...7.1.3 [7.1.2]: https://github.com/sebastianbergmann/phpunit/compare/7.1.1...7.1.2 [7.1.1]: https://github.com/sebastianbergmann/phpunit/compare/7.1.0...7.1.1 [7.1.0]: https://github.com/sebastianbergmann/phpunit/compare/7.0...7.1.0 diff --git a/ChangeLog-7.2.md b/ChangeLog-7.2.md index 5dfe9b1c4b9..b1b8d282fb6 100644 --- a/ChangeLog-7.2.md +++ b/ChangeLog-7.2.md @@ -6,6 +6,7 @@ All notable changes of the PHPUnit 7.2 release series are documented in this fil ### Added +* Implemented [#3042](https://github.com/sebastianbergmann/phpunit/pull/3042): Add `TestCase::expectNotToPerformAssertions()` method as alternative to `@doesNotPerformAssertions` annotation * Implemented [#3064](https://github.com/sebastianbergmann/phpunit/issues/3064): Mark tests as risky when they claim not to perform assertions but do * Implemented [#3066](https://github.com/sebastianbergmann/phpunit/issues/3066): Validate XML configuration against XSD * Implemented [#3076](https://github.com/sebastianbergmann/phpunit/issues/3076): Extensions can be configured via PHPUnit's XML configuration diff --git a/build.xml b/build.xml index 6123b76f373..c442ea7be53 100644 --- a/build.xml +++ b/build.xml @@ -125,6 +125,8 @@ + + diff --git a/build/tools/composer b/build/tools/composer index 041775a1274..499114bb3cf 100755 Binary files a/build/tools/composer and b/build/tools/composer differ diff --git a/composer.json b/composer.json index f1775fcfb80..b1b998cc048 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,8 @@ "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.0", - "phpunit/phpunit-mock-objects": "^6.1", - "sebastian/comparator": "^2.1", + "phpunit/phpunit-mock-objects": "^6.1.1", + "sebastian/comparator": "^2.1 || ^3.0", "sebastian/diff": "^3.0", "sebastian/environment": "^3.1", "sebastian/exporter": "^3.1", diff --git a/phpunit.xsd b/phpunit.xsd index ac8b3774980..8b932429555 100644 --- a/phpunit.xsd +++ b/phpunit.xsd @@ -2,7 +2,7 @@ - This Schema file defines the rules by which the XML configuration file of PHPUnit 7.0 may be structured. + This Schema file defines the rules by which the XML configuration file of PHPUnit 7.2 may be structured. diff --git a/src/Framework/ExceptionWrapper.php b/src/Framework/ExceptionWrapper.php index 3ae217f9712..30a6a4e6d97 100644 --- a/src/Framework/ExceptionWrapper.php +++ b/src/Framework/ExceptionWrapper.php @@ -75,12 +75,12 @@ public function getPreviousWrapped(): ?self /** * @param string $className */ - public function setClassName(string $className) + public function setClassName(string $className): void { $this->className = $className; } - public function setOriginalException(\Throwable $t) + public function setOriginalException(\Throwable $t): void { $this->originalException($t); diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 1a34636e065..839d514ff2d 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -619,6 +619,11 @@ public function expectExceptionObject(\Exception $exception): void $this->expectExceptionCode($exception->getCode()); } + public function expectNotToPerformAssertions() + { + $this->doesNotPerformAssertions = true; + } + public function setRegisterMockObjectsFromTestArgumentsRecursively(bool $flag): void { $this->registerMockObjectsFromTestArgumentsRecursively = $flag; @@ -868,7 +873,9 @@ public function runBare(): void $this->status = BaseTestRunner::STATUS_FAILURE; $this->statusMessage = $e->getMessage(); } catch (Throwable $_e) { - $e = $_e; + $e = $_e; + $this->status = BaseTestRunner::STATUS_ERROR; + $this->statusMessage = $_e->getMessage(); } $this->mockObjects = []; @@ -1033,7 +1040,7 @@ public function setOutputCallback(callable $callback): void $this->outputCallback = $callback; } - public function getTestResultObject(): TestResult + public function getTestResultObject(): ?TestResult { return $this->result; } diff --git a/src/Util/Configuration.php b/src/Util/Configuration.php index ba75e1dce25..abbcbc53f25 100644 --- a/src/Util/Configuration.php +++ b/src/Util/Configuration.php @@ -948,7 +948,7 @@ public function getTestSuiteNames(): array return $names; } - private function validateConfigurationAgainstSchema() + private function validateConfigurationAgainstSchema(): void { $original = \libxml_use_internal_errors(true); $xsdFilename = __DIR__ . '/../../phpunit.xsd'; diff --git a/tests/Framework/TestCaseTest.php b/tests/Framework/TestCaseTest.php index c1036c30c61..c360fe0eb85 100644 --- a/tests/Framework/TestCaseTest.php +++ b/tests/Framework/TestCaseTest.php @@ -177,6 +177,14 @@ public function testExceptionInTearDown(): void $this->assertEquals(BaseTestRunner::STATUS_ERROR, $test->getStatus()); } + public function testExceptionInTestIsDetectedInTeardown(): void + { + $test = new \ExceptionInTestDetectedInTeardown('testSomething'); + $test->run(); + + $this->assertTrue($test->exceptionDetected); + } + public function testNoArgTestCasePasses(): void { $result = new TestResult; @@ -322,6 +330,17 @@ public function testWrongException(): void $this->assertCount(1, $result); } + public function testDoesNotPerformAssertions(): void + { + $test = new \DoNoAssertionTestCase('testNothing'); + $test->expectNotToPerformAssertions(); + + $result = $test->run(); + + $this->assertEquals(0, $result->riskyCount()); + $this->assertCount(1, $result); + } + /** * @backupGlobals enabled */ @@ -721,6 +740,12 @@ public function testProvidingArrayThatMixesObjectsAndScalars(): void $this->assertSame($data, $test->myTestData); } + public function testGettingNullTestResultObject(): void + { + $test = new \Success(); + $this->assertNull($test->getTestResultObject()); + } + /** * @return array */ diff --git a/tests/Regression/GitHub/1149/Issue1149Test.php b/tests/Regression/GitHub/1149/Issue1149Test.php index 99e80cb7318..025124d43d8 100644 --- a/tests/Regression/GitHub/1149/Issue1149Test.php +++ b/tests/Regression/GitHub/1149/Issue1149Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1149Test extends TestCase { - public function testOne() + public function testOne(): void { $this->assertTrue(true); print '1'; @@ -12,7 +20,7 @@ public function testOne() /** * @runInSeparateProcess */ - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); print '2'; diff --git a/tests/Regression/GitHub/1216/Issue1216Test.php b/tests/Regression/GitHub/1216/Issue1216Test.php index 37ddb154ef8..61296351b18 100644 --- a/tests/Regression/GitHub/1216/Issue1216Test.php +++ b/tests/Regression/GitHub/1216/Issue1216Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1216Test extends TestCase { - public function testConfigAvailableInBootstrap() + public function testConfigAvailableInBootstrap(): void { $this->assertTrue($_ENV['configAvailableInBootstrap']); } diff --git a/tests/Regression/GitHub/1216/bootstrap1216.php b/tests/Regression/GitHub/1216/bootstrap1216.php index cec2724aa6f..9d0eb300579 100644 --- a/tests/Regression/GitHub/1216/bootstrap1216.php +++ b/tests/Regression/GitHub/1216/bootstrap1216.php @@ -1,2 +1,10 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ $_ENV['configAvailableInBootstrap'] = isset($_ENV['loadedFromConfig']); diff --git a/tests/Regression/GitHub/1265/Issue1265Test.php b/tests/Regression/GitHub/1265/Issue1265Test.php index f6c3f092212..dcb43e8c8ab 100644 --- a/tests/Regression/GitHub/1265/Issue1265Test.php +++ b/tests/Regression/GitHub/1265/Issue1265Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1265Test extends TestCase { - public function testTrue() + public function testTrue(): void { $this->assertTrue(true); } diff --git a/tests/Regression/GitHub/1330/Issue1330Test.php b/tests/Regression/GitHub/1330/Issue1330Test.php index 6e0213a20df..789238e6538 100644 --- a/tests/Regression/GitHub/1330/Issue1330Test.php +++ b/tests/Regression/GitHub/1330/Issue1330Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1330Test extends TestCase { - public function testTrue() + public function testTrue(): void { $this->assertTrue(PHPUNIT_1330); } diff --git a/tests/Regression/GitHub/1335/Issue1335Test.php b/tests/Regression/GitHub/1335/Issue1335Test.php index 352e53448bf..deba6f7a28b 100644 --- a/tests/Regression/GitHub/1335/Issue1335Test.php +++ b/tests/Regression/GitHub/1335/Issue1335Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -7,62 +15,62 @@ */ class Issue1335Test extends TestCase { - public function testGlobalString() + public function testGlobalString(): void { $this->assertEquals('Hello', $GLOBALS['globalString']); } - public function testGlobalIntTruthy() + public function testGlobalIntTruthy(): void { $this->assertEquals(1, $GLOBALS['globalIntTruthy']); } - public function testGlobalIntFalsey() + public function testGlobalIntFalsey(): void { $this->assertEquals(0, $GLOBALS['globalIntFalsey']); } - public function testGlobalFloat() + public function testGlobalFloat(): void { $this->assertEquals(1.123, $GLOBALS['globalFloat']); } - public function testGlobalBoolTrue() + public function testGlobalBoolTrue(): void { $this->assertTrue($GLOBALS['globalBoolTrue']); } - public function testGlobalBoolFalse() + public function testGlobalBoolFalse(): void { $this->assertFalse($GLOBALS['globalBoolFalse']); } - public function testGlobalNull() + public function testGlobalNull(): void { $this->assertEquals(null, $GLOBALS['globalNull']); } - public function testGlobalArray() + public function testGlobalArray(): void { $this->assertEquals(['foo'], $GLOBALS['globalArray']); } - public function testGlobalNestedArray() + public function testGlobalNestedArray(): void { $this->assertEquals([['foo']], $GLOBALS['globalNestedArray']); } - public function testGlobalObject() + public function testGlobalObject(): void { $this->assertEquals((object) ['foo'=> 'bar'], $GLOBALS['globalObject']); } - public function testGlobalObjectWithBackSlashString() + public function testGlobalObjectWithBackSlashString(): void { $this->assertEquals((object) ['foo'=> 'back\\slash'], $GLOBALS['globalObjectWithBackSlashString']); } - public function testGlobalObjectWithDoubleBackSlashString() + public function testGlobalObjectWithDoubleBackSlashString(): void { $this->assertEquals((object) ['foo'=> 'back\\\\slash'], $GLOBALS['globalObjectWithDoubleBackSlashString']); } diff --git a/tests/Regression/GitHub/1335/bootstrap1335.php b/tests/Regression/GitHub/1335/bootstrap1335.php index 7165bb2b19f..51dad554b4f 100644 --- a/tests/Regression/GitHub/1335/bootstrap1335.php +++ b/tests/Regression/GitHub/1335/bootstrap1335.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ $globalString = 'Hello'; $globalIntTruthy = 1; $globalIntFalsey = 0; diff --git a/tests/Regression/GitHub/1337/Issue1337Test.php b/tests/Regression/GitHub/1337/Issue1337Test.php index fb2ceaa1b54..0678dbbaf75 100644 --- a/tests/Regression/GitHub/1337/Issue1337Test.php +++ b/tests/Regression/GitHub/1337/Issue1337Test.php @@ -1,12 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1337Test extends TestCase { /** * @dataProvider dataProvider + * + * @param mixed $a */ - public function testProvider($a) + public function testProvider($a): void { $this->assertTrue($a); } diff --git a/tests/Regression/GitHub/1348/Issue1348Test.php b/tests/Regression/GitHub/1348/Issue1348Test.php index a8dfc7cd668..0ab9a14ce9d 100644 --- a/tests/Regression/GitHub/1348/Issue1348Test.php +++ b/tests/Regression/GitHub/1348/Issue1348Test.php @@ -1,16 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1348Test extends TestCase { - public function testSTDOUT() + public function testSTDOUT(): void { - fwrite(STDOUT, "\nSTDOUT does not break test result\n"); + \fwrite(STDOUT, "\nSTDOUT does not break test result\n"); $this->assertTrue(true); } - public function testSTDERR() + public function testSTDERR(): void { - fwrite(STDERR, 'STDERR works as usual.'); + \fwrite(STDERR, 'STDERR works as usual.'); } } diff --git a/tests/Regression/GitHub/1351/ChildProcessClass1351.php b/tests/Regression/GitHub/1351/ChildProcessClass1351.php index 24c05376667..2bac282f92f 100644 --- a/tests/Regression/GitHub/1351/ChildProcessClass1351.php +++ b/tests/Regression/GitHub/1351/ChildProcessClass1351.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class ChildProcessClass1351 { } diff --git a/tests/Regression/GitHub/1351/Issue1351Test.php b/tests/Regression/GitHub/1351/Issue1351Test.php index 47ebcbfcfd3..6784fb9fd81 100644 --- a/tests/Regression/GitHub/1351/Issue1351Test.php +++ b/tests/Regression/GitHub/1351/Issue1351Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1351Test extends TestCase @@ -8,24 +16,25 @@ class Issue1351Test extends TestCase /** * @runInSeparateProcess */ - public function testFailurePre() + public function testFailurePre(): void { $this->instance = new ChildProcessClass1351(); $this->assertFalse(true, 'Expected failure.'); } - public function testFailurePost() + public function testFailurePost(): void { $this->assertNull($this->instance); - $this->assertFalse(class_exists(ChildProcessClass1351::class, false), 'ChildProcessClass1351 is not loaded.'); + $this->assertFalse(\class_exists(ChildProcessClass1351::class, false), 'ChildProcessClass1351 is not loaded.'); } /** * @runInSeparateProcess */ - public function testExceptionPre() + public function testExceptionPre(): void { $this->instance = new ChildProcessClass1351(); + try { throw new LogicException('Expected exception.'); } catch (LogicException $e) { @@ -33,13 +42,13 @@ public function testExceptionPre() } } - public function testExceptionPost() + public function testExceptionPost(): void { $this->assertNull($this->instance); - $this->assertFalse(class_exists(ChildProcessClass1351::class, false), 'ChildProcessClass1351 is not loaded.'); + $this->assertFalse(\class_exists(ChildProcessClass1351::class, false), 'ChildProcessClass1351 is not loaded.'); } - public function testPhpCoreLanguageException() + public function testPhpCoreLanguageException(): void { // User-space code cannot instantiate a PDOException with a string code, // so trigger a real one. diff --git a/tests/Regression/GitHub/1374/Issue1374Test.php b/tests/Regression/GitHub/1374/Issue1374Test.php index d9a97c5bf7f..fd339ca43e4 100644 --- a/tests/Regression/GitHub/1374/Issue1374Test.php +++ b/tests/Regression/GitHub/1374/Issue1374Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -11,13 +19,13 @@ protected function setUp(): void print __FUNCTION__; } - public function testSomething() + protected function tearDown(): void { - $this->fail('This should not be reached'); + print __FUNCTION__; } - protected function tearDown(): void + public function testSomething(): void { - print __FUNCTION__; + $this->fail('This should not be reached'); } } diff --git a/tests/Regression/GitHub/1437/Issue1437Test.php b/tests/Regression/GitHub/1437/Issue1437Test.php index 08b799b7242..4ac4df9f46b 100644 --- a/tests/Regression/GitHub/1437/Issue1437Test.php +++ b/tests/Regression/GitHub/1437/Issue1437Test.php @@ -1,11 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1437Test extends TestCase { - public function testFailure() + public function testFailure(): void { - ob_start(); + \ob_start(); $this->assertTrue(false); } } diff --git a/tests/Regression/GitHub/1468/Issue1468Test.php b/tests/Regression/GitHub/1468/Issue1468Test.php index 94efc97635a..202dd3c2c15 100644 --- a/tests/Regression/GitHub/1468/Issue1468Test.php +++ b/tests/Regression/GitHub/1468/Issue1468Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1468Test extends TestCase @@ -6,7 +14,7 @@ class Issue1468Test extends TestCase /** * @todo Implement this test */ - public function testFailure() + public function testFailure(): void { $this->markTestIncomplete(); } diff --git a/tests/Regression/GitHub/1471/Issue1471Test.php b/tests/Regression/GitHub/1471/Issue1471Test.php index 013ccdb2302..3a359516131 100644 --- a/tests/Regression/GitHub/1471/Issue1471Test.php +++ b/tests/Regression/GitHub/1471/Issue1471Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1471Test extends TestCase { - public function testFailure() + public function testFailure(): void { $this->expectOutputString('*'); diff --git a/tests/Regression/GitHub/1472/Issue1472Test.php b/tests/Regression/GitHub/1472/Issue1472Test.php index 8f517c187a4..3633fd3f310 100644 --- a/tests/Regression/GitHub/1472/Issue1472Test.php +++ b/tests/Regression/GitHub/1472/Issue1472Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1472Test extends TestCase { - public function testAssertEqualXMLStructure() + public function testAssertEqualXMLStructure(): void { $doc = new DOMDocument; $doc->loadXML(''); diff --git a/tests/Regression/GitHub/1570/Issue1570Test.php b/tests/Regression/GitHub/1570/Issue1570Test.php index dec80acf485..6fda1111b4f 100644 --- a/tests/Regression/GitHub/1570/Issue1570Test.php +++ b/tests/Regression/GitHub/1570/Issue1570Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1570Test extends TestCase { - public function testOne() + public function testOne(): void { print '*'; } diff --git a/tests/Regression/GitHub/2137/Issue2137Test.php b/tests/Regression/GitHub/2137/Issue2137Test.php index a83a06a9a2b..0e3aa5a0e6b 100644 --- a/tests/Regression/GitHub/2137/Issue2137Test.php +++ b/tests/Regression/GitHub/2137/Issue2137Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Issue2137Test extends PHPUnit\Framework\TestCase { /** @@ -11,12 +19,11 @@ class Issue2137Test extends PHPUnit\Framework\TestCase * @throws \PHPUnit\Framework\ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ - public function testBrandService($provided, $expected) + public function testBrandService($provided, $expected): void { $this->assertSame($provided, $expected); } - public function provideBrandService() { return [ @@ -25,7 +32,6 @@ public function provideBrandService() ]; } - /** * @dataProvider provideBrandService * @@ -36,7 +42,7 @@ public function provideBrandService() * @throws \PHPUnit\Framework\ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ - public function testSomethingElseInvalid($provided, $expected) + public function testSomethingElseInvalid($provided, $expected): void { $this->assertSame($provided, $expected); } diff --git a/tests/Regression/GitHub/2145/Issue2145Test.php b/tests/Regression/GitHub/2145/Issue2145Test.php index 4076f5ce005..99c9dd7c1bd 100644 --- a/tests/Regression/GitHub/2145/Issue2145Test.php +++ b/tests/Regression/GitHub/2145/Issue2145Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Issue2145Test extends PHPUnit\Framework\TestCase { public static function setUpBeforeClass(): void @@ -6,11 +14,11 @@ public static function setUpBeforeClass(): void throw new Exception; } - public function testOne() + public function testOne(): void { } - public function testTwo() + public function testTwo(): void { } } diff --git a/tests/Regression/GitHub/2158/Issue2158Test.php b/tests/Regression/GitHub/2158/Issue2158Test.php index 2f6e01b91a1..5e70ba332af 100644 --- a/tests/Regression/GitHub/2158/Issue2158Test.php +++ b/tests/Regression/GitHub/2158/Issue2158Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue2158Test extends TestCase @@ -6,7 +14,7 @@ class Issue2158Test extends TestCase /** * Set constant in main process */ - public function testSomething() + public function testSomething(): void { include __DIR__ . '/constant.inc'; $this->assertTrue(true); @@ -18,8 +26,8 @@ public function testSomething() * * @runInSeparateProcess */ - public function testSomethingElse() + public function testSomethingElse(): void { - $this->assertTrue(defined('TEST_CONSTANT')); + $this->assertTrue(\defined('TEST_CONSTANT')); } } diff --git a/tests/Regression/GitHub/2366/Issue2366Test.php b/tests/Regression/GitHub/2366/Issue2366Test.php index 17be78289fd..b7790c64d35 100644 --- a/tests/Regression/GitHub/2366/Issue2366Test.php +++ b/tests/Regression/GitHub/2366/Issue2366Test.php @@ -1,10 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue2366 { - public function foo() + public function foo(): bool { + return false; } } @@ -12,8 +21,10 @@ class Issue2366Test extends TestCase { /** * @dataProvider provider + * + * @param mixed $o */ - public function testOne($o) + public function testOne($o): void { $this->assertEquals(1, $o->foo()); } diff --git a/tests/Regression/GitHub/2380/Issue2380Test.php b/tests/Regression/GitHub/2380/Issue2380Test.php index 55c2b80a0fc..abc36be101e 100644 --- a/tests/Regression/GitHub/2380/Issue2380Test.php +++ b/tests/Regression/GitHub/2380/Issue2380Test.php @@ -1,12 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue2380Test extends TestCase { /** * @dataProvider generatorData + * + * @param mixed $data */ - public function testGeneratorProvider($data) + public function testGeneratorProvider($data): void { $this->assertNotEmpty($data); } diff --git a/tests/Regression/GitHub/2382/Issue2382Test.php b/tests/Regression/GitHub/2382/Issue2382Test.php index 9fd49cb0f97..b12349b9777 100644 --- a/tests/Regression/GitHub/2382/Issue2382Test.php +++ b/tests/Regression/GitHub/2382/Issue2382Test.php @@ -1,12 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue2382Test extends TestCase { /** * @dataProvider dataProvider + * + * @param mixed $test */ - public function testOne($test) + public function testOne($test): void { $this->assertInstanceOf(\Exception::class, $test); } diff --git a/tests/Regression/GitHub/2435/Issue2435Test.php b/tests/Regression/GitHub/2435/Issue2435Test.php index fdfd196b403..f77833ddf6c 100644 --- a/tests/Regression/GitHub/2435/Issue2435Test.php +++ b/tests/Regression/GitHub/2435/Issue2435Test.php @@ -1,10 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ class Issue2435Test extends PHPUnit\Framework\TestCase { - public function testOne() + public function testOne(): void { $this->assertTrue(true); } diff --git a/tests/Regression/GitHub/244/Issue244Test.php b/tests/Regression/GitHub/244/Issue244Test.php index efa98f46e28..dc544b2cf72 100644 --- a/tests/Regression/GitHub/244/Issue244Test.php +++ b/tests/Regression/GitHub/244/Issue244Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue244Test extends TestCase @@ -7,7 +15,7 @@ class Issue244Test extends TestCase * @expectedException Issue244Exception * @expectedExceptionCode 123StringCode */ - public function testWorks() + public function testWorks(): void { throw new Issue244Exception; } @@ -16,7 +24,7 @@ public function testWorks() * @expectedException Issue244Exception * @expectedExceptionCode OtherString */ - public function testFails() + public function testFails(): void { throw new Issue244Exception; } @@ -25,7 +33,7 @@ public function testFails() * @expectedException Issue244Exception * @expectedExceptionCode 123 */ - public function testFailsTooIfExpectationIsANumber() + public function testFailsTooIfExpectationIsANumber(): void { throw new Issue244Exception; } @@ -34,7 +42,7 @@ public function testFailsTooIfExpectationIsANumber() * @expectedException Issue244ExceptionIntCode * @expectedExceptionCode 123String */ - public function testFailsTooIfExceptionCodeIsANumber() + public function testFailsTooIfExceptionCodeIsANumber(): void { throw new Issue244ExceptionIntCode; } diff --git a/tests/Regression/GitHub/2448-existing-test.phpt b/tests/Regression/GitHub/2448-existing-test.phpt index 5b27253dd39..6b968ce4d04 100644 --- a/tests/Regression/GitHub/2448-existing-test.phpt +++ b/tests/Regression/GitHub/2448-existing-test.phpt @@ -5,7 +5,7 @@ $_SERVER['argv'][1] = '--no-configuration'; $_SERVER['argv'][2] = 'Test'; -chdir(__DIR__.'/2448'); +\chdir(__DIR__ . '/2448'); require __DIR__ . '/../../bootstrap.php'; PHPUnit\TextUI\Command::main(); diff --git a/tests/Regression/GitHub/2448/Test.php b/tests/Regression/GitHub/2448/Test.php index 95a032c376a..308e66a488c 100644 --- a/tests/Regression/GitHub/2448/Test.php +++ b/tests/Regression/GitHub/2448/Test.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Test extends PHPUnit\Framework\TestCase { - public function testOne() + public function testOne(): void { $this->assertTrue(true); } diff --git a/tests/Regression/GitHub/2591/SeparateClassPreserveTest.php b/tests/Regression/GitHub/2591/SeparateClassPreserveTest.php index b6141d07e32..cee8492fc22 100644 --- a/tests/Regression/GitHub/2591/SeparateClassPreserveTest.php +++ b/tests/Regression/GitHub/2591/SeparateClassPreserveTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -7,12 +15,12 @@ */ class Issue2591_SeparateClassPreserveTest extends TestCase { - public function testOriginalGlobalString() + public function testOriginalGlobalString(): void { $this->assertEquals('Hello', $GLOBALS['globalString']); } - public function testChangedGlobalString() + public function testChangedGlobalString(): void { $value = 'Hello! I am changed from inside!'; @@ -20,9 +28,8 @@ public function testChangedGlobalString() $this->assertEquals($value, $GLOBALS['globalString']); } - public function testGlobalString() + public function testGlobalString(): void { $this->assertEquals('Hello', $GLOBALS['globalString']); } - } diff --git a/tests/Regression/GitHub/2591/SeparateFunctionNoPreserveTest.php b/tests/Regression/GitHub/2591/SeparateFunctionNoPreserveTest.php index 92c013ec796..273e1e803c1 100644 --- a/tests/Regression/GitHub/2591/SeparateFunctionNoPreserveTest.php +++ b/tests/Regression/GitHub/2591/SeparateFunctionNoPreserveTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -7,15 +15,14 @@ */ class Issue2591_SeparateFunctionNoPreserveTest extends TestCase { - public function testChangedGlobalString() + public function testChangedGlobalString(): void { $GLOBALS['globalString'] = 'Hello!'; $this->assertEquals('Hello!', $GLOBALS['globalString']); } - public function testGlobalString() + public function testGlobalString(): void { $this->assertEquals('Hello', $GLOBALS['globalString']); } - } diff --git a/tests/Regression/GitHub/2591/SeparateFunctionPreserveTest.php b/tests/Regression/GitHub/2591/SeparateFunctionPreserveTest.php index 61b2a78e237..34047bc7e42 100644 --- a/tests/Regression/GitHub/2591/SeparateFunctionPreserveTest.php +++ b/tests/Regression/GitHub/2591/SeparateFunctionPreserveTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -7,15 +15,14 @@ */ class Issue2591_SeparateFunctionPreserveTest extends TestCase { - public function testChangedGlobalString() + public function testChangedGlobalString(): void { $GLOBALS['globalString'] = 'Hello!'; $this->assertEquals('Hello!', $GLOBALS['globalString']); } - public function testGlobalString() + public function testGlobalString(): void { $this->assertEquals('Hello', $GLOBALS['globalString']); } - } diff --git a/tests/Regression/GitHub/2591/bootstrapNoBootstrap.php b/tests/Regression/GitHub/2591/bootstrapNoBootstrap.php index ba308f2a2ac..bc1e307ac00 100644 --- a/tests/Regression/GitHub/2591/bootstrapNoBootstrap.php +++ b/tests/Regression/GitHub/2591/bootstrapNoBootstrap.php @@ -1,6 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +\ini_set('display_errors', 0); +\ini_set('log_errors', 1); $globalString = 'Hello'; diff --git a/tests/Regression/GitHub/2591/bootstrapWithBootstrap.php b/tests/Regression/GitHub/2591/bootstrapWithBootstrap.php index 656f7dcbd9a..75426911b14 100644 --- a/tests/Regression/GitHub/2591/bootstrapWithBootstrap.php +++ b/tests/Regression/GitHub/2591/bootstrapWithBootstrap.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ $globalString = 'Hello'; -require __DIR__ . '/../../../bootstrap.php'; \ No newline at end of file +require __DIR__ . '/../../../bootstrap.php'; diff --git a/tests/Regression/GitHub/2591/bootstrapWithBootstrapNoGlobal.php b/tests/Regression/GitHub/2591/bootstrapWithBootstrapNoGlobal.php index 2907ee563c9..66c08c4314d 100644 --- a/tests/Regression/GitHub/2591/bootstrapWithBootstrapNoGlobal.php +++ b/tests/Regression/GitHub/2591/bootstrapWithBootstrapNoGlobal.php @@ -1,4 +1,11 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -require __DIR__ . '/../../../bootstrap.php'; \ No newline at end of file +require __DIR__ . '/../../../bootstrap.php'; diff --git a/tests/Regression/GitHub/2724-diff-pid-from-master-process.phpt b/tests/Regression/GitHub/2724-diff-pid-from-master-process.phpt index 859f730281c..e05078659dc 100644 --- a/tests/Regression/GitHub/2724-diff-pid-from-master-process.phpt +++ b/tests/Regression/GitHub/2724-diff-pid-from-master-process.phpt @@ -8,7 +8,7 @@ $_SERVER['argv'][3] = __DIR__ . '/2724/SeparateClassRunMethodInNewProcessTest.ph require __DIR__ . '/../../bootstrap.php'; -file_put_contents(__DIR__ . '/2724/parent_process_id.txt', getmypid()); +\file_put_contents(__DIR__ . '/2724/parent_process_id.txt', \getmypid()); PHPUnit\TextUI\Command::main(); ?> diff --git a/tests/Regression/GitHub/2724/SeparateClassRunMethodInNewProcessTest.php b/tests/Regression/GitHub/2724/SeparateClassRunMethodInNewProcessTest.php index 4d8cf4ba40b..1c73862d6ab 100644 --- a/tests/Regression/GitHub/2724/SeparateClassRunMethodInNewProcessTest.php +++ b/tests/Regression/GitHub/2724/SeparateClassRunMethodInNewProcessTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ /** * @runClassInSeparateProcess @@ -6,33 +14,33 @@ class SeparateClassRunMethodInNewProcessTest extends PHPUnit\Framework\TestCase { const PROCESS_ID_FILE_PATH = __DIR__ . '/parent_process_id.txt'; - const INITIAL_MASTER_PID = 0; - const INITIAL_PID1 = 1; + const INITIAL_MASTER_PID = 0; + const INITIAL_PID1 = 1; public static $masterPid = self::INITIAL_MASTER_PID; - public static $pid1 = self::INITIAL_PID1; + public static $pid1 = self::INITIAL_PID1; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); - if (file_exists(self::PROCESS_ID_FILE_PATH)) { - static::$masterPid = (int) file_get_contents(self::PROCESS_ID_FILE_PATH); + if (\file_exists(self::PROCESS_ID_FILE_PATH)) { + static::$masterPid = (int) \file_get_contents(self::PROCESS_ID_FILE_PATH); } } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); - if (file_exists(self::PROCESS_ID_FILE_PATH)) { - unlink(self::PROCESS_ID_FILE_PATH); + if (\file_exists(self::PROCESS_ID_FILE_PATH)) { + \unlink(self::PROCESS_ID_FILE_PATH); } } - public function testMethodShouldGetDifferentPidThanMaster() + public function testMethodShouldGetDifferentPidThanMaster(): void { - static::$pid1 = getmypid(); + static::$pid1 = \getmypid(); $this->assertNotEquals(self::INITIAL_PID1, static::$pid1); $this->assertNotEquals(self::INITIAL_MASTER_PID, static::$masterPid); diff --git a/tests/Regression/GitHub/2725/BeforeAfterClassPidTest.php b/tests/Regression/GitHub/2725/BeforeAfterClassPidTest.php index 2ea38a934a9..ac8804a6c8e 100644 --- a/tests/Regression/GitHub/2725/BeforeAfterClassPidTest.php +++ b/tests/Regression/GitHub/2725/BeforeAfterClassPidTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Issue2725; use PHPUnit\Framework\TestCase; @@ -14,30 +21,30 @@ class BeforeAfterClassPidTest extends TestCase /** * @beforeClass */ - public static function showPidBefore() - { - $GLOBALS[static::PID_VARIABLE] = getmypid(); - } - - public function testMethod1WithItsBeforeAndAfter() - { - $this->assertEquals($GLOBALS[static::PID_VARIABLE], getmypid()); - } - - public function testMethod2WithItsBeforeAndAfter() + public static function showPidBefore(): void { - $this->assertEquals($GLOBALS[static::PID_VARIABLE], getmypid()); + $GLOBALS[static::PID_VARIABLE] = \getmypid(); } /** * @afterClass */ - public static function showPidAfter() + public static function showPidAfter(): void { - if ($GLOBALS[static::PID_VARIABLE] - getmypid() !== 0) { - echo "\n@afterClass output - PID difference should be zero!"; + if ($GLOBALS[static::PID_VARIABLE] - \getmypid() !== 0) { + print "\n@afterClass output - PID difference should be zero!"; } unset($GLOBALS[static::PID_VARIABLE]); } + + public function testMethod1WithItsBeforeAndAfter(): void + { + $this->assertEquals($GLOBALS[static::PID_VARIABLE], \getmypid()); + } + + public function testMethod2WithItsBeforeAndAfter(): void + { + $this->assertEquals($GLOBALS[static::PID_VARIABLE], \getmypid()); + } } diff --git a/tests/Regression/GitHub/2731/Issue2731Test.php b/tests/Regression/GitHub/2731/Issue2731Test.php index 0d1e6d3cd18..b2530db410b 100644 --- a/tests/Regression/GitHub/2731/Issue2731Test.php +++ b/tests/Regression/GitHub/2731/Issue2731Test.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Issue2731Test extends PHPUnit\Framework\TestCase { - public function testOne() + public function testOne(): void { $this->expectException(Exception::class); $this->expectExceptionMessage(''); diff --git a/tests/Regression/GitHub/2811/Issue2811Test.php b/tests/Regression/GitHub/2811/Issue2811Test.php index 20bb57037f2..340c68812c7 100644 --- a/tests/Regression/GitHub/2811/Issue2811Test.php +++ b/tests/Regression/GitHub/2811/Issue2811Test.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Issue2811Test extends PHPUnit\Framework\TestCase { - public function testOne() + public function testOne(): void { $this->expectExceptionMessage('hello'); diff --git a/tests/Regression/GitHub/2830/Issue2830Test.php b/tests/Regression/GitHub/2830/Issue2830Test.php index 4a9497680e9..bcf7c6a0a0e 100644 --- a/tests/Regression/GitHub/2830/Issue2830Test.php +++ b/tests/Regression/GitHub/2830/Issue2830Test.php @@ -1,14 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ + class Issue2830Test extends PHPUnit\Framework\TestCase { /** * @dataProvider simpleDataProvider */ - public function testMethodUsesDataProvider() + public function testMethodUsesDataProvider(): void { $this->assertTrue(true); } @@ -19,4 +24,4 @@ public function simpleDataProvider() ['foo'], ]; } -} \ No newline at end of file +} diff --git a/tests/Regression/GitHub/2972/issue-2972-test.phpt b/tests/Regression/GitHub/2972/issue-2972-test.phpt index 4d09cf5a94e..2d7dd750d1f 100644 --- a/tests/Regression/GitHub/2972/issue-2972-test.phpt +++ b/tests/Regression/GitHub/2972/issue-2972-test.phpt @@ -2,7 +2,7 @@ Just a sample test for issue 2972, does not actually test anything --FILE-- ===DONE=== --EXPECT-- diff --git a/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php b/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php index 3fd57f018ec..e97849106b3 100644 --- a/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php +++ b/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php @@ -1,12 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Issue2972; use PHPUnit\Framework\TestCase; class Issue2972Test extends TestCase { - public function testHello() + public function testHello(): void { $this->assertNotEmpty('Hello world!'); } diff --git a/tests/Regression/GitHub/322/Issue322Test.php b/tests/Regression/GitHub/322/Issue322Test.php index 894a06f2cac..df698c7b3a9 100644 --- a/tests/Regression/GitHub/322/Issue322Test.php +++ b/tests/Regression/GitHub/322/Issue322Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue322Test extends TestCase @@ -6,7 +14,7 @@ class Issue322Test extends TestCase /** * @group one */ - public function testOne() + public function testOne(): void { $this->assertTrue(true); } @@ -14,7 +22,7 @@ public function testOne() /** * @group two */ - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); } diff --git a/tests/Regression/GitHub/433/Issue433Test.php b/tests/Regression/GitHub/433/Issue433Test.php index eb865767107..799b7a7673f 100644 --- a/tests/Regression/GitHub/433/Issue433Test.php +++ b/tests/Regression/GitHub/433/Issue433Test.php @@ -1,21 +1,29 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue433Test extends TestCase { - public function testOutputWithExpectationBefore() + public function testOutputWithExpectationBefore(): void { $this->expectOutputString('test'); print 'test'; } - public function testOutputWithExpectationAfter() + public function testOutputWithExpectationAfter(): void { print 'test'; $this->expectOutputString('test'); } - public function testNotMatchingOutput() + public function testNotMatchingOutput(): void { print 'bar'; $this->expectOutputString('foo'); diff --git a/tests/Regression/GitHub/445/Issue445Test.php b/tests/Regression/GitHub/445/Issue445Test.php index 560835eba6e..a506939e147 100644 --- a/tests/Regression/GitHub/445/Issue445Test.php +++ b/tests/Regression/GitHub/445/Issue445Test.php @@ -1,21 +1,29 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue445Test extends TestCase { - public function testOutputWithExpectationBefore() + public function testOutputWithExpectationBefore(): void { $this->expectOutputString('test'); print 'test'; } - public function testOutputWithExpectationAfter() + public function testOutputWithExpectationAfter(): void { print 'test'; $this->expectOutputString('test'); } - public function testNotMatchingOutput() + public function testNotMatchingOutput(): void { print 'bar'; $this->expectOutputString('foo'); diff --git a/tests/Regression/GitHub/498/Issue498Test.php b/tests/Regression/GitHub/498/Issue498Test.php index 993419f7a98..b049421f218 100644 --- a/tests/Regression/GitHub/498/Issue498Test.php +++ b/tests/Regression/GitHub/498/Issue498Test.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue498Test extends TestCase @@ -8,8 +15,10 @@ class Issue498Test extends TestCase * @test * @dataProvider shouldBeTrueDataProvider * @group falseOnly + * + * @param mixed $testData */ - public function shouldBeTrue($testData) + public function shouldBeTrue($testData): void { $this->assertTrue(true); } @@ -18,8 +27,10 @@ public function shouldBeTrue($testData) * @test * @dataProvider shouldBeFalseDataProvider * @group trueOnly + * + * @param mixed $testData */ - public function shouldBeFalse($testData) + public function shouldBeFalse($testData): void { $this->assertFalse(false); } diff --git a/tests/Regression/GitHub/503/Issue503Test.php b/tests/Regression/GitHub/503/Issue503Test.php index 2d1af390c48..0b26c32fa27 100644 --- a/tests/Regression/GitHub/503/Issue503Test.php +++ b/tests/Regression/GitHub/503/Issue503Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue503Test extends TestCase { - public function testCompareDifferentLineEndings() + public function testCompareDifferentLineEndings(): void { $this->assertSame( "foo\n", diff --git a/tests/Regression/GitHub/581/Issue581Test.php b/tests/Regression/GitHub/581/Issue581Test.php index 05e01076b5a..6de48670d10 100644 --- a/tests/Regression/GitHub/581/Issue581Test.php +++ b/tests/Regression/GitHub/581/Issue581Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue581Test extends TestCase { - public function testExportingObjectsDoesNotBreakWindowsLineFeeds() + public function testExportingObjectsDoesNotBreakWindowsLineFeeds(): void { $this->assertEquals( (object) [1, 2, "Test\r\n", 4, 5, 6, 7, 8], diff --git a/tests/Regression/GitHub/74/Issue74Test.php b/tests/Regression/GitHub/74/Issue74Test.php index 6e9faf3bcea..a20fddffebb 100644 --- a/tests/Regression/GitHub/74/Issue74Test.php +++ b/tests/Regression/GitHub/74/Issue74Test.php @@ -1,11 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue74Test extends TestCase { - public function testCreateAndThrowNewExceptionInProcessIsolation() + public function testCreateAndThrowNewExceptionInProcessIsolation(): void { require_once __DIR__ . '/NewException.php'; + throw new NewException('Testing GH-74'); } } diff --git a/tests/Regression/GitHub/74/NewException.php b/tests/Regression/GitHub/74/NewException.php index abe2f7119a9..61dd361aa05 100644 --- a/tests/Regression/GitHub/74/NewException.php +++ b/tests/Regression/GitHub/74/NewException.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class NewException extends Exception { } diff --git a/tests/Regression/GitHub/765/Issue765Test.php b/tests/Regression/GitHub/765/Issue765Test.php index f8d732d0eb0..577761959d0 100644 --- a/tests/Regression/GitHub/765/Issue765Test.php +++ b/tests/Regression/GitHub/765/Issue765Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue765Test extends TestCase { - public function testDependee() + public function testDependee(): void { $this->assertTrue(true); } @@ -11,13 +19,15 @@ public function testDependee() /** * @depends testDependee * @dataProvider dependentProvider + * + * @param mixed $a */ - public function testDependent($a) + public function testDependent($a): void { $this->assertTrue(true); } - public function dependentProvider() + public function dependentProvider(): void { throw new Exception; } diff --git a/tests/Regression/GitHub/797/Issue797Test.php b/tests/Regression/GitHub/797/Issue797Test.php index a10d3dd9d54..f1424962cda 100644 --- a/tests/Regression/GitHub/797/Issue797Test.php +++ b/tests/Regression/GitHub/797/Issue797Test.php @@ -1,11 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue797Test extends TestCase { protected $preserveGlobalState = false; - public function testBootstrapPhpIsExecutedInIsolation() + public function testBootstrapPhpIsExecutedInIsolation(): void { $this->assertEquals(GITHUB_ISSUE, 797); } diff --git a/tests/Regression/GitHub/797/bootstrap797.php b/tests/Regression/GitHub/797/bootstrap797.php index 03890a35a89..b51cb8e66bb 100644 --- a/tests/Regression/GitHub/797/bootstrap797.php +++ b/tests/Regression/GitHub/797/bootstrap797.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ // PHPUnit_Framework_TestCase itself does not exist. :-) require __DIR__ . '/../../../bootstrap.php'; diff --git a/tests/Regression/GitHub/863.phpt b/tests/Regression/GitHub/863.phpt index ef04db1b164..df1c62719bc 100644 --- a/tests/Regression/GitHub/863.phpt +++ b/tests/Regression/GitHub/863.phpt @@ -7,7 +7,7 @@ $_SERVER['argv'][1] = '--no-configuration'; $_SERVER['argv'][2] = '--repeat'; $_SERVER['argv'][3] = '50'; $_SERVER['argv'][4] = 'BankAccountTest'; -$_SERVER['argv'][5] = dirname(dirname(__DIR__)) . '/_files/BankAccountTest.php'; +$_SERVER['argv'][5] = \dirname(\dirname(__DIR__)) . '/_files/BankAccountTest.php'; require __DIR__ . '/../../bootstrap.php'; PHPUnit\TextUI\Command::main(); diff --git a/tests/Regression/GitHub/873/Issue873Test.php b/tests/Regression/GitHub/873/Issue873Test.php index 70fd9046403..5a611380145 100644 --- a/tests/Regression/GitHub/873/Issue873Test.php +++ b/tests/Regression/GitHub/873/Issue873Test.php @@ -1,7 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +if (\extension_loaded('xdebug')) { + \xdebug_disable(); } throw new Exception( diff --git a/tests/Regression/Trac/1021/Issue1021Test.php b/tests/Regression/Trac/1021/Issue1021Test.php index f4b4c34510f..13877f7afb2 100644 --- a/tests/Regression/Trac/1021/Issue1021Test.php +++ b/tests/Regression/Trac/1021/Issue1021Test.php @@ -1,12 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue1021Test extends TestCase { /** * @dataProvider provider + * + * @param mixed $data */ - public function testSomething($data) + public function testSomething($data): void { $this->assertTrue($data); } @@ -14,7 +24,7 @@ public function testSomething($data) /** * @depends testSomething */ - public function testSomethingElse() + public function testSomethingElse(): void { $this->assertTrue(true); } diff --git a/tests/Regression/Trac/523/Issue523Test.php b/tests/Regression/Trac/523/Issue523Test.php index 1a10414a663..a274f6a4e04 100644 --- a/tests/Regression/Trac/523/Issue523Test.php +++ b/tests/Regression/Trac/523/Issue523Test.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue523Test extends TestCase { - public function testAttributeEquals() + public function testAttributeEquals(): void { $this->assertAttributeEquals('foo', 'field', new Issue523()); } diff --git a/tests/Regression/Trac/578/Issue578Test.php b/tests/Regression/Trac/578/Issue578Test.php index 24b8248828b..2a0b239162a 100644 --- a/tests/Regression/Trac/578/Issue578Test.php +++ b/tests/Regression/Trac/578/Issue578Test.php @@ -1,21 +1,29 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Issue578Test extends TestCase { - public function testNoticesDoublePrintStackTrace() + public function testNoticesDoublePrintStackTrace(): void { $this->iniSet('error_reporting', E_ALL | E_NOTICE); - trigger_error('Stack Trace Test Notice', E_NOTICE); + \trigger_error('Stack Trace Test Notice', E_NOTICE); } - public function testWarningsDoublePrintStackTrace() + public function testWarningsDoublePrintStackTrace(): void { $this->iniSet('error_reporting', E_ALL | E_NOTICE); - trigger_error('Stack Trace Test Notice', E_WARNING); + \trigger_error('Stack Trace Test Notice', E_WARNING); } - public function testUnexpectedExceptionsPrintsCorrectly() + public function testUnexpectedExceptionsPrintsCorrectly(): void { throw new Exception('Double printed exception'); } diff --git a/tests/Regression/Trac/684/Issue684Test.php b/tests/Regression/Trac/684/Issue684Test.php index 3a300b0e099..4e14dbb30bc 100644 --- a/tests/Regression/Trac/684/Issue684Test.php +++ b/tests/Regression/Trac/684/Issue684Test.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Foo_Bar_Issue684Test extends TestCase diff --git a/tests/Regression/Trac/783/ChildSuite.php b/tests/Regression/Trac/783/ChildSuite.php index 0825462b23b..6b64bda230d 100644 --- a/tests/Regression/Trac/783/ChildSuite.php +++ b/tests/Regression/Trac/783/ChildSuite.php @@ -1,7 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestSuite; require_once 'OneTest.php'; + require_once 'TwoTest.php'; class ChildSuite diff --git a/tests/Regression/Trac/783/OneTest.php b/tests/Regression/Trac/783/OneTest.php index 269ade905bf..7e49161d6c6 100644 --- a/tests/Regression/Trac/783/OneTest.php +++ b/tests/Regression/Trac/783/OneTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -6,7 +14,7 @@ */ class OneTest extends TestCase { - public function testSomething() + public function testSomething(): void { $this->assertTrue(true); } diff --git a/tests/Regression/Trac/783/ParentSuite.php b/tests/Regression/Trac/783/ParentSuite.php index 87d37672957..9803380a966 100644 --- a/tests/Regression/Trac/783/ParentSuite.php +++ b/tests/Regression/Trac/783/ParentSuite.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestSuite; require_once 'ChildSuite.php'; diff --git a/tests/Regression/Trac/783/TwoTest.php b/tests/Regression/Trac/783/TwoTest.php index c6a422e33b0..dada5bbca32 100644 --- a/tests/Regression/Trac/783/TwoTest.php +++ b/tests/Regression/Trac/783/TwoTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -6,7 +14,7 @@ */ class TwoTest extends TestCase { - public function testSomething() + public function testSomething(): void { $this->assertTrue(true); } diff --git a/tests/TextUI/_files/Extension.php b/tests/TextUI/_files/Extension.php index e0242539a1a..3936f0d4822 100644 --- a/tests/TextUI/_files/Extension.php +++ b/tests/TextUI/_files/Extension.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace PHPUnit\Test; use PHPUnit\Runner\AfterIncompleteTestHook; @@ -9,8 +17,8 @@ use PHPUnit\Runner\AfterTestErrorHook; use PHPUnit\Runner\AfterTestFailureHook; use PHPUnit\Runner\AfterTestWarningHook; -use PHPUnit\Runner\BeforeTestHook; use PHPUnit\Runner\BeforeFirstTestHook; +use PHPUnit\Runner\BeforeTestHook; final class Extension implements BeforeFirstTestHook, BeforeTestHook, AfterSuccessfulTestHook, AfterSkippedTestHook, AfterRiskyTestHook, AfterIncompleteTestHook, AfterTestErrorHook, AfterTestWarningHook, AfterTestFailureHook, AfterLastTestHook { @@ -18,7 +26,7 @@ final class Extension implements BeforeFirstTestHook, BeforeTestHook, AfterSucce public function __construct() { - $this->amountOfInjectedArguments = count(func_get_args()); + $this->amountOfInjectedArguments = \count(\func_get_args()); } public function tellAmountOfInjectedArguments(): void diff --git a/tests/TextUI/_files/HookTest.php b/tests/TextUI/_files/HookTest.php index 19fe80ff606..63280452072 100644 --- a/tests/TextUI/_files/HookTest.php +++ b/tests/TextUI/_files/HookTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace PHPUnit\Test; use PHPUnit\Framework\RiskyTestError; diff --git a/tests/TextUI/_files/NullPrinter.php b/tests/TextUI/_files/NullPrinter.php index 3d298ff83fc..f41ceb7f926 100644 --- a/tests/TextUI/_files/NullPrinter.php +++ b/tests/TextUI/_files/NullPrinter.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace PHPUnit\Test; -use PHPUnit\Util\Printer; use PHPUnit\Framework\TestListener; use PHPUnit\Framework\TestListenerDefaultImplementation; +use PHPUnit\Util\Printer; final class NullPrinter extends Printer implements TestListener { diff --git a/tests/TextUI/mycommand.phpt b/tests/TextUI/mycommand.phpt index ca8c8c7a7aa..fc63788a3f7 100644 --- a/tests/TextUI/mycommand.phpt +++ b/tests/TextUI/mycommand.phpt @@ -9,6 +9,7 @@ $_SERVER['argv'][4] = 'BankAccountTest'; $_SERVER['argv'][5] = __DIR__ . '/../_files/BankAccountTest.php'; require __DIR__ . '/../bootstrap.php'; + require __DIR__ . '/../_files/MyCommand.php'; MyCommand::main(); ?> diff --git a/tests/TextUI/teamcity-inner-exceptions.phpt b/tests/TextUI/teamcity-inner-exceptions.phpt index 55cd5907d0f..85436afd746 100644 --- a/tests/TextUI/teamcity-inner-exceptions.phpt +++ b/tests/TextUI/teamcity-inner-exceptions.phpt @@ -19,13 +19,13 @@ PHPUnit %s by Sebastian Bergmann and contributors. ##teamcity[testStarted name='testPrintingChildException' locationHint='php_qn://%s%etests%e_files%eExceptionStackTest.php::\ExceptionStackTest::testPrintingChildException' flowId='%d'] -##teamcity[testFailed name='testPrintingChildException' message='Child exception|nmessage|nFailed asserting that two arrays are equal.|n--- Expected|n+++ Actual|n@@ @@|n Array (|n- 0 => 1|n+ 0 => 2|n )|n' details=' %s_files%eExceptionStackTest.php:14|n |n Caused by|n message|n Failed asserting that two arrays are equal.|n --- Expected|n +++ Actual|n @@ @@|n Array (|n - 0 => 1|n + 0 => 2|n )|n |n %s_files%eExceptionStackTest.php:10|n ' flowId='%d'] +##teamcity[testFailed name='testPrintingChildException' message='Child exception|nmessage|nFailed asserting that two arrays are equal.|n--- Expected|n+++ Actual|n@@ @@|n Array (|n- 0 => 1|n+ 0 => 2|n )|n' details=' %s_files%eExceptionStackTest.php:%d|n |n Caused by|n message|n Failed asserting that two arrays are equal.|n --- Expected|n +++ Actual|n @@ @@|n Array (|n - 0 => 1|n + 0 => 2|n )|n |n %s_files%eExceptionStackTest.php:%d|n ' flowId='%d'] ##teamcity[testFinished name='testPrintingChildException' duration='%d' flowId='%d'] ##teamcity[testStarted name='testNestedExceptions' locationHint='php_qn://%s%etests%e_files%eExceptionStackTest.php::\ExceptionStackTest::testNestedExceptions' flowId='%d'] -##teamcity[testFailed name='testNestedExceptions' message='Exception : One' details=' %s%etests%e_files%eExceptionStackTest.php:22|n |n Caused by|n InvalidArgumentException: Two|n |n %s%etests%e_files%eExceptionStackTest.php:21|n |n Caused by|n Exception: Three|n |n %s%etests%e_files%eExceptionStackTest.php:20|n ' flowId='%d'] +##teamcity[testFailed name='testNestedExceptions' message='Exception : One' details=' %s%etests%e_files%eExceptionStackTest.php:%d|n |n Caused by|n InvalidArgumentException: Two|n |n %s%etests%e_files%eExceptionStackTest.php:%d|n |n Caused by|n Exception: Three|n |n %s%etests%e_files%eExceptionStackTest.php:%d|n ' flowId='%d'] ##teamcity[testFinished name='testNestedExceptions' duration='%d' flowId='%d'] diff --git a/tests/TextUI/testdox-xml.phpt b/tests/TextUI/testdox-xml.phpt index cde0e4ad930..eb1c450b54a 100644 --- a/tests/TextUI/testdox-xml.phpt +++ b/tests/TextUI/testdox-xml.phpt @@ -16,7 +16,7 @@ PHPUnit %s by Sebastian Bergmann and contributors. .FEISRW 7 / 7 (100%) - + diff --git a/tests/Util/TestTest.php b/tests/Util/TestTest.php index e656cac46af..0b6ad396c13 100644 --- a/tests/Util/TestTest.php +++ b/tests/Util/TestTest.php @@ -872,7 +872,7 @@ public function testTwoCoversDefaultClassAnnotationsAreNotAllowed(): void public function testFunctionParenthesesAreAllowed(): void { $this->assertSame( - [TEST_FILES_PATH . 'CoveredFunction.php' => \range(2, 4)], + [TEST_FILES_PATH . 'CoveredFunction.php' => \range(10, 12)], Test::getLinesToBeCovered( 'CoverageFunctionParenthesesTest', 'testSomething' @@ -883,7 +883,7 @@ public function testFunctionParenthesesAreAllowed(): void public function testFunctionParenthesesAreAllowedWithWhitespace(): void { $this->assertSame( - [TEST_FILES_PATH . 'CoveredFunction.php' => \range(2, 4)], + [TEST_FILES_PATH . 'CoveredFunction.php' => \range(10, 12)], Test::getLinesToBeCovered( 'CoverageFunctionParenthesesWhitespaceTest', 'testSomething' @@ -894,7 +894,7 @@ public function testFunctionParenthesesAreAllowedWithWhitespace(): void public function testMethodParenthesesAreAllowed(): void { $this->assertSame( - [TEST_FILES_PATH . 'CoveredClass.php' => \range(31, 35)], + [TEST_FILES_PATH . 'CoveredClass.php' => \range(29, 33)], Test::getLinesToBeCovered( 'CoverageMethodParenthesesTest', 'testSomething' @@ -905,7 +905,7 @@ public function testMethodParenthesesAreAllowed(): void public function testMethodParenthesesAreAllowedWithWhitespace(): void { $this->assertSame( - [TEST_FILES_PATH . 'CoveredClass.php' => \range(31, 35)], + [TEST_FILES_PATH . 'CoveredClass.php' => \range(29, 33)], Test::getLinesToBeCovered( 'CoverageMethodParenthesesWhitespaceTest', 'testSomething' @@ -917,7 +917,7 @@ public function testNamespacedFunctionCanBeCoveredOrUsed(): void { $this->assertEquals( [ - TEST_FILES_PATH . 'NamespaceCoveredFunction.php' => \range(4, 7) + TEST_FILES_PATH . 'NamespaceCoveredFunction.php' => \range(12, 15) ], Test::getLinesToBeCovered( \CoverageNamespacedFunctionTest::class, @@ -935,91 +935,91 @@ public function getLinesToBeCoveredProvider() ], [ 'CoverageClassExtendedTest', - \array_merge(\range(19, 36), \range(2, 17)) + \array_merge(\range(27, 44), \range(10, 25)) ], [ 'CoverageClassTest', - \range(19, 36) + \range(27, 44) ], [ 'CoverageMethodTest', - \range(31, 35) + \range(29, 33) ], [ 'CoverageMethodOneLineAnnotationTest', - \range(31, 35) + \range(29, 33) ], [ 'CoverageNotPrivateTest', - \array_merge(\range(25, 29), \range(31, 35)) + \array_merge(\range(29, 33), \range(35, 39)) ], [ 'CoverageNotProtectedTest', - \array_merge(\range(21, 23), \range(31, 35)) + \array_merge(\range(29, 33), \range(41, 43)) ], [ 'CoverageNotPublicTest', - \array_merge(\range(21, 23), \range(25, 29)) + \array_merge(\range(35, 39), \range(41, 43)) ], [ 'CoveragePrivateTest', - \range(21, 23) + \range(41, 43) ], [ 'CoverageProtectedTest', - \range(25, 29) + \range(35, 39) ], [ 'CoveragePublicTest', - \range(31, 35) + \range(29, 33) ], [ 'CoverageFunctionTest', - \range(2, 4) + \range(10, 12) ], [ 'NamespaceCoverageClassExtendedTest', - \array_merge(\range(21, 38), \range(4, 19)) + \array_merge(\range(29, 46), \range(12, 27)) ], [ 'NamespaceCoverageClassTest', - \range(21, 38) + \range(29, 46) ], [ 'NamespaceCoverageMethodTest', - \range(33, 37) + \range(31, 35) ], [ 'NamespaceCoverageNotPrivateTest', - \array_merge(\range(27, 31), \range(33, 37)) + \array_merge(\range(31, 35), \range(37, 41)) ], [ 'NamespaceCoverageNotProtectedTest', - \array_merge(\range(23, 25), \range(33, 37)) + \array_merge(\range(31, 35), \range(43, 45)) ], [ 'NamespaceCoverageNotPublicTest', - \array_merge(\range(23, 25), \range(27, 31)) + \array_merge(\range(37, 41), \range(43, 45)) ], [ 'NamespaceCoveragePrivateTest', - \range(23, 25) + \range(43, 45) ], [ 'NamespaceCoverageProtectedTest', - \range(27, 31) + \range(37, 41) ], [ 'NamespaceCoveragePublicTest', - \range(33, 37) + \range(31, 35) ], [ 'NamespaceCoverageCoversClassTest', - \array_merge(\range(23, 25), \range(27, 31), \range(33, 37), \range(6, 8), \range(10, 13), \range(15, 18)) + \array_merge(\range(43, 45), \range(37, 41), \range(31, 35), \range(24, 26), \range(19, 22), \range(14, 17)) ], [ 'NamespaceCoverageCoversClassPublicTest', - \range(33, 37) + \range(31, 35) ], [ 'CoverageNothingTest', diff --git a/tests/_files/AbstractTest.php b/tests/_files/AbstractTest.php index 49f88b8e334..a519e37bcf2 100644 --- a/tests/_files/AbstractTest.php +++ b/tests/_files/AbstractTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; abstract class AbstractTest extends TestCase { - public function testOne() + public function testOne(): void { $this->assertTrue(true); } diff --git a/tests/_files/ArrayAccessible.php b/tests/_files/ArrayAccessible.php index 4eb2fd13d20..171eebe7b2e 100644 --- a/tests/_files/ArrayAccessible.php +++ b/tests/_files/ArrayAccessible.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class ArrayAccessible implements ArrayAccess, IteratorAggregate { private $array; @@ -11,7 +18,7 @@ public function __construct(array $array = []) public function offsetExists($offset) { - return array_key_exists($offset, $this->array); + return \array_key_exists($offset, $this->array); } public function offsetGet($offset) @@ -19,7 +26,7 @@ public function offsetGet($offset) return $this->array[$offset]; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value): void { if (null === $offset) { $this->array[] = $value; @@ -28,7 +35,7 @@ public function offsetSet($offset, $value) } } - public function offsetUnset($offset) + public function offsetUnset($offset): void { unset($this->array[$offset]); } diff --git a/tests/_files/AssertionExample.php b/tests/_files/AssertionExample.php index d830f155286..30d659d6246 100644 --- a/tests/_files/AssertionExample.php +++ b/tests/_files/AssertionExample.php @@ -1,8 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class AssertionExample { - public function doSomething() + public function doSomething(): void { - assert(false); + \assert(false); } } diff --git a/tests/_files/AssertionExampleTest.php b/tests/_files/AssertionExampleTest.php index f78879c7838..26a6569f23c 100644 --- a/tests/_files/AssertionExampleTest.php +++ b/tests/_files/AssertionExampleTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class AssertionExampleTest extends TestCase { - public function testOne() + public function testOne(): void { $e = new AssertionExample; diff --git a/tests/_files/BankAccount.php b/tests/_files/BankAccount.php index 67b92329a5d..b7d51d00448 100644 --- a/tests/_files/BankAccount.php +++ b/tests/_files/BankAccount.php @@ -35,46 +35,46 @@ public function getBalance() } /** - * Sets the bank account's balance. + * Deposits an amount of money to the bank account. * * @param float $balance * * @throws BankAccountException */ - protected function setBalance($balance) + public function depositMoney($balance) { - if ($balance >= 0) { - $this->balance = $balance; - } else { - throw new BankAccountException; - } + $this->setBalance($this->getBalance() + $balance); + + return $this->getBalance(); } /** - * Deposits an amount of money to the bank account. + * Withdraws an amount of money from the bank account. * * @param float $balance * * @throws BankAccountException */ - public function depositMoney($balance) + public function withdrawMoney($balance) { - $this->setBalance($this->getBalance() + $balance); + $this->setBalance($this->getBalance() - $balance); return $this->getBalance(); } /** - * Withdraws an amount of money from the bank account. + * Sets the bank account's balance. * * @param float $balance * * @throws BankAccountException */ - public function withdrawMoney($balance) + protected function setBalance($balance): void { - $this->setBalance($this->getBalance() - $balance); - - return $this->getBalance(); + if ($balance >= 0) { + $this->balance = $balance; + } else { + throw new BankAccountException; + } } } diff --git a/tests/_files/BankAccountTest.php b/tests/_files/BankAccountTest.php index 5e83ea02d3f..b68dfc4c0c2 100644 --- a/tests/_files/BankAccountTest.php +++ b/tests/_files/BankAccountTest.php @@ -26,7 +26,7 @@ protected function setUp(): void * @group balanceIsInitiallyZero * @group specification */ - public function testBalanceIsInitiallyZero() + public function testBalanceIsInitiallyZero(): void { /* @Given a fresh bank account */ $ba = new BankAccount; @@ -43,7 +43,7 @@ public function testBalanceIsInitiallyZero() * @group balanceCannotBecomeNegative * @group specification */ - public function testBalanceCannotBecomeNegative() + public function testBalanceCannotBecomeNegative(): void { try { $this->ba->withdrawMoney(1); @@ -61,7 +61,7 @@ public function testBalanceCannotBecomeNegative() * @group balanceCannotBecomeNegative * @group specification */ - public function testBalanceCannotBecomeNegative2() + public function testBalanceCannotBecomeNegative2(): void { try { $this->ba->depositMoney(-1); diff --git a/tests/_files/BankAccountTest.test.php b/tests/_files/BankAccountTest.test.php index 9c427f2e619..ab2d60b7bfc 100644 --- a/tests/_files/BankAccountTest.test.php +++ b/tests/_files/BankAccountTest.test.php @@ -26,7 +26,7 @@ protected function setUp(): void * @group balanceIsInitiallyZero * @group specification */ - public function testBalanceIsInitiallyZero() + public function testBalanceIsInitiallyZero(): void { $this->assertEquals(0, $this->ba->getBalance()); } @@ -36,7 +36,7 @@ public function testBalanceIsInitiallyZero() * @group balanceCannotBecomeNegative * @group specification */ - public function testBalanceCannotBecomeNegative() + public function testBalanceCannotBecomeNegative(): void { try { $this->ba->withdrawMoney(1); @@ -54,7 +54,7 @@ public function testBalanceCannotBecomeNegative() * @group balanceCannotBecomeNegative * @group specification */ - public function testBalanceCannotBecomeNegative2() + public function testBalanceCannotBecomeNegative2(): void { try { $this->ba->depositMoney(-1); diff --git a/tests/_files/BankAccountTest2.php b/tests/_files/BankAccountTest2.php index b39d35dbc54..6e2aef7698f 100644 --- a/tests/_files/BankAccountTest2.php +++ b/tests/_files/BankAccountTest2.php @@ -19,7 +19,7 @@ protected function setUp(): void $this->ba = new BankAccount; } - public function testBalanceIsInitiallyZero() + public function testBalanceIsInitiallyZero(): void { $ba = new BankAccount; @@ -28,7 +28,7 @@ public function testBalanceIsInitiallyZero() $this->assertEquals(0, $balance); } - public function testBalanceCannotBecomeNegative() + public function testBalanceCannotBecomeNegative(): void { try { $this->ba->withdrawMoney(1); @@ -41,7 +41,7 @@ public function testBalanceCannotBecomeNegative() $this->fail(); } - public function testBalanceCannotBecomeNegative2() + public function testBalanceCannotBecomeNegative2(): void { try { $this->ba->depositMoney(-1); diff --git a/tests/_files/BeforeAndAfterTest.php b/tests/_files/BeforeAndAfterTest.php index 7c748109605..bfa53f5ac91 100644 --- a/tests/_files/BeforeAndAfterTest.php +++ b/tests/_files/BeforeAndAfterTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class BeforeAndAfterTest extends TestCase @@ -6,7 +14,7 @@ class BeforeAndAfterTest extends TestCase public static $beforeWasRun; public static $afterWasRun; - public static function resetProperties() + public static function resetProperties(): void { self::$beforeWasRun = 0; self::$afterWasRun = 0; @@ -15,7 +23,7 @@ public static function resetProperties() /** * @before */ - public function initialSetup() + public function initialSetup(): void { self::$beforeWasRun++; } @@ -23,15 +31,16 @@ public function initialSetup() /** * @after */ - public function finalTeardown() + public function finalTeardown(): void { self::$afterWasRun++; } - public function test1() + public function test1(): void { } - public function test2() + + public function test2(): void { } } diff --git a/tests/_files/BeforeClassAndAfterClassTest.php b/tests/_files/BeforeClassAndAfterClassTest.php index 4897f301654..e74e9dfe454 100644 --- a/tests/_files/BeforeClassAndAfterClassTest.php +++ b/tests/_files/BeforeClassAndAfterClassTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class BeforeClassAndAfterClassTest extends TestCase @@ -6,7 +14,7 @@ class BeforeClassAndAfterClassTest extends TestCase public static $beforeClassWasRun = 0; public static $afterClassWasRun = 0; - public static function resetProperties() + public static function resetProperties(): void { self::$beforeClassWasRun = 0; self::$afterClassWasRun = 0; @@ -15,7 +23,7 @@ public static function resetProperties() /** * @beforeClass */ - public static function initialClassSetup() + public static function initialClassSetup(): void { self::$beforeClassWasRun++; } @@ -23,15 +31,16 @@ public static function initialClassSetup() /** * @afterClass */ - public static function finalClassTeardown() + public static function finalClassTeardown(): void { self::$afterClassWasRun++; } - public function test1() + public function test1(): void { } - public function test2() + + public function test2(): void { } } diff --git a/tests/_files/BeforeClassWithOnlyDataProviderTest.php b/tests/_files/BeforeClassWithOnlyDataProviderTest.php index 37dad98e77b..c5217fd5392 100644 --- a/tests/_files/BeforeClassWithOnlyDataProviderTest.php +++ b/tests/_files/BeforeClassWithOnlyDataProviderTest.php @@ -1,28 +1,36 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class BeforeClassWithOnlyDataProviderTest extends \PHPUnit\Framework\TestCase { public static $setUpBeforeClassWasCalled; public static $beforeClassWasCalled; - public static function resetProperties() + public static function resetProperties(): void { self::$setUpBeforeClassWasCalled = false; self::$beforeClassWasCalled = false; } - public static function setUpBeforeClass(): void - { - self::$setUpBeforeClassWasCalled = true; - } - /** * @beforeClass */ - public static function someAnnotatedSetupMethod() + public static function someAnnotatedSetupMethod(): void { self::$beforeClassWasCalled = true; } + public static function setUpBeforeClass(): void + { + self::$setUpBeforeClassWasCalled = true; + } + public function dummyProvider() { return [[1]]; @@ -32,7 +40,7 @@ public function dummyProvider() * @dataProvider dummyProvider * delete annotation to fail test case */ - public function testDummy() + public function testDummy(): void { $this->assertFalse(false); } diff --git a/tests/_files/Book.php b/tests/_files/Book.php index 1f49ef0a8a6..2e0f88b1a8b 100644 --- a/tests/_files/Book.php +++ b/tests/_files/Book.php @@ -14,5 +14,5 @@ class Book { // the order of properties is important for testing the cycle! - public $author = null; + public $author; } diff --git a/tests/_files/Calculator.php b/tests/_files/Calculator.php index e269bd6ca0b..b8040418d41 100644 --- a/tests/_files/Calculator.php +++ b/tests/_files/Calculator.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Calculator { /** @@ -6,6 +14,9 @@ class Calculator * @assert (0, 1) == 1 * @assert (1, 0) == 1 * @assert (1, 1) == 2 + * + * @param mixed $a + * @param mixed $b */ public function add($a, $b) { diff --git a/tests/_files/ChangeCurrentWorkingDirectoryTest.php b/tests/_files/ChangeCurrentWorkingDirectoryTest.php index 2e8f0ac48e5..c0cc608ddb4 100644 --- a/tests/_files/ChangeCurrentWorkingDirectoryTest.php +++ b/tests/_files/ChangeCurrentWorkingDirectoryTest.php @@ -1,11 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ChangeCurrentWorkingDirectoryTest extends TestCase { - public function testSomethingThatChangesTheCwd() + public function testSomethingThatChangesTheCwd(): void { - chdir('../'); + \chdir('../'); $this->assertTrue(true); } } diff --git a/tests/_files/ClassWithNonPublicAttributes.php b/tests/_files/ClassWithNonPublicAttributes.php index ec285b81fb2..bec350e8d2b 100644 --- a/tests/_files/ClassWithNonPublicAttributes.php +++ b/tests/_files/ClassWithNonPublicAttributes.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class ParentClassWithPrivateAttributes { private static $privateStaticParentAttribute = 'foo'; @@ -20,10 +28,10 @@ class ClassWithNonPublicAttributes extends ParentClassWithProtectedAttributes public $publicAttribute = 'foo'; public $foo = 1; public $bar = 2; + + public $publicArray = ['foo']; protected $protectedAttribute = 'bar'; protected $privateAttribute = 'baz'; - - public $publicArray = ['foo']; - protected $protectedArray = ['bar']; - protected $privateArray = ['baz']; + protected $protectedArray = ['bar']; + protected $privateArray = ['baz']; } diff --git a/tests/_files/ClassWithScalarTypeDeclarations.php b/tests/_files/ClassWithScalarTypeDeclarations.php index 8f20f32c801..0780e2489d5 100644 --- a/tests/_files/ClassWithScalarTypeDeclarations.php +++ b/tests/_files/ClassWithScalarTypeDeclarations.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class ClassWithScalarTypeDeclarations { - public function foo(string $string, int $int) + public function foo(string $string, int $int): void { } } diff --git a/tests/_files/ClonedDependencyTest.php b/tests/_files/ClonedDependencyTest.php index 165760c2049..50bb6547d87 100644 --- a/tests/_files/ClonedDependencyTest.php +++ b/tests/_files/ClonedDependencyTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ClonedDependencyTest extends TestCase @@ -19,40 +27,50 @@ public function testOne() /** * @depends testOne + * + * @param mixed $dependency */ - public function testTwo($dependency) + public function testTwo($dependency): void { $this->assertSame(self::$dependency, $dependency); } /** * @depends !clone testOne + * + * @param mixed $dependency */ - public function testThree($dependency) + public function testThree($dependency): void { $this->assertSame(self::$dependency, $dependency); } /** * @depends clone testOne + * + * @param mixed $dependency */ - public function testFour($dependency) + public function testFour($dependency): void { $this->assertNotSame(self::$dependency, $dependency); } /** * @depends !shallowClone testOne + * + * @param mixed $dependency */ - public function testFive($dependency) + public function testFive($dependency): void { $this->assertSame(self::$dependency, $dependency); } /** * @depends shallowClone testOne + * + * @param mixed $dependency */ - public function testSix($dependency) + public function testSix($dependency): void { $this->assertNotSame(self::$dependency, $dependency); } diff --git a/tests/_files/ConcreteTest.my.php b/tests/_files/ConcreteTest.my.php index c795db550ff..739cd0f4886 100644 --- a/tests/_files/ConcreteTest.my.php +++ b/tests/_files/ConcreteTest.my.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class ConcreteWithMyCustomExtensionTest extends AbstractTest { - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); } diff --git a/tests/_files/ConcreteTest.php b/tests/_files/ConcreteTest.php index cccfb6a627a..8e6d4968821 100644 --- a/tests/_files/ConcreteTest.php +++ b/tests/_files/ConcreteTest.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class ConcreteTest extends AbstractTest { - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); } diff --git a/tests/_files/CountConstraint.php b/tests/_files/CountConstraint.php index 84674a8802d..a0abea91100 100644 --- a/tests/_files/CountConstraint.php +++ b/tests/_files/CountConstraint.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\Constraint\Constraint; final class CountConstraint extends Constraint @@ -24,7 +32,7 @@ public function matches($other): bool public function toString(): string { - return sprintf( + return \sprintf( 'is accepted by %s', self::class ); diff --git a/tests/_files/CoverageClassExtendedTest.php b/tests/_files/CoverageClassExtendedTest.php index e6d496e4acc..cf1a85e6ec7 100644 --- a/tests/_files/CoverageClassExtendedTest.php +++ b/tests/_files/CoverageClassExtendedTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageClassExtendedTest extends TestCase @@ -6,7 +14,7 @@ class CoverageClassExtendedTest extends TestCase /** * @covers CoveredClass */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageClassTest.php b/tests/_files/CoverageClassTest.php index baa04d8c7d1..e9710a9d7d1 100644 --- a/tests/_files/CoverageClassTest.php +++ b/tests/_files/CoverageClassTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageClassTest extends TestCase @@ -6,7 +14,7 @@ class CoverageClassTest extends TestCase /** * @covers CoveredClass */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageFunctionParenthesesTest.php b/tests/_files/CoverageFunctionParenthesesTest.php index 560e3817582..6f118f44e9d 100644 --- a/tests/_files/CoverageFunctionParenthesesTest.php +++ b/tests/_files/CoverageFunctionParenthesesTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageFunctionParenthesesTest extends TestCase @@ -6,7 +14,7 @@ class CoverageFunctionParenthesesTest extends TestCase /** * @covers ::globalFunction() */ - public function testSomething() + public function testSomething(): void { globalFunction(); } diff --git a/tests/_files/CoverageFunctionParenthesesWhitespaceTest.php b/tests/_files/CoverageFunctionParenthesesWhitespaceTest.php index f51d298d481..ffea17c9678 100644 --- a/tests/_files/CoverageFunctionParenthesesWhitespaceTest.php +++ b/tests/_files/CoverageFunctionParenthesesWhitespaceTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageFunctionParenthesesWhitespaceTest extends TestCase @@ -6,7 +14,7 @@ class CoverageFunctionParenthesesWhitespaceTest extends TestCase /** * @covers ::globalFunction ( ) */ - public function testSomething() + public function testSomething(): void { globalFunction(); } diff --git a/tests/_files/CoverageFunctionTest.php b/tests/_files/CoverageFunctionTest.php index de963a27d3a..75479c7dc4f 100644 --- a/tests/_files/CoverageFunctionTest.php +++ b/tests/_files/CoverageFunctionTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageFunctionTest extends TestCase @@ -6,7 +14,7 @@ class CoverageFunctionTest extends TestCase /** * @covers ::globalFunction */ - public function testSomething() + public function testSomething(): void { globalFunction(); } diff --git a/tests/_files/CoverageMethodOneLineAnnotationTest.php b/tests/_files/CoverageMethodOneLineAnnotationTest.php index 92cdfaef9b4..198f576c14f 100644 --- a/tests/_files/CoverageMethodOneLineAnnotationTest.php +++ b/tests/_files/CoverageMethodOneLineAnnotationTest.php @@ -1,11 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageMethodOneLineAnnotationTest extends TestCase { /** @covers CoveredClass::publicMethod */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageMethodParenthesesTest.php b/tests/_files/CoverageMethodParenthesesTest.php index b624ed95a1a..341cbbea57e 100644 --- a/tests/_files/CoverageMethodParenthesesTest.php +++ b/tests/_files/CoverageMethodParenthesesTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageMethodParenthesesTest extends TestCase @@ -6,7 +14,7 @@ class CoverageMethodParenthesesTest extends TestCase /** * @covers CoveredClass::publicMethod() */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageMethodParenthesesWhitespaceTest.php b/tests/_files/CoverageMethodParenthesesWhitespaceTest.php index 20d2e751ac8..58bf8b5792c 100644 --- a/tests/_files/CoverageMethodParenthesesWhitespaceTest.php +++ b/tests/_files/CoverageMethodParenthesesWhitespaceTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageMethodParenthesesWhitespaceTest extends TestCase @@ -6,7 +14,7 @@ class CoverageMethodParenthesesWhitespaceTest extends TestCase /** * @covers CoveredClass::publicMethod ( ) */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageMethodTest.php b/tests/_files/CoverageMethodTest.php index fb7a88277dd..4013efc41dc 100644 --- a/tests/_files/CoverageMethodTest.php +++ b/tests/_files/CoverageMethodTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageMethodTest extends TestCase @@ -6,7 +14,7 @@ class CoverageMethodTest extends TestCase /** * @covers CoveredClass::publicMethod */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageNamespacedFunctionTest.php b/tests/_files/CoverageNamespacedFunctionTest.php index bc5fffb4f1b..97afd8779bf 100644 --- a/tests/_files/CoverageNamespacedFunctionTest.php +++ b/tests/_files/CoverageNamespacedFunctionTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageNamespacedFunctionTest extends TestCase @@ -6,7 +14,7 @@ class CoverageNamespacedFunctionTest extends TestCase /** * @covers foo\func() */ - public function testFunc() + public function testFunc(): void { foo\func(); } diff --git a/tests/_files/CoverageNoneTest.php b/tests/_files/CoverageNoneTest.php index d8d9cae672a..268de4c6c21 100644 --- a/tests/_files/CoverageNoneTest.php +++ b/tests/_files/CoverageNoneTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageNoneTest extends TestCase { - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageNotPrivateTest.php b/tests/_files/CoverageNotPrivateTest.php index e98efd85375..2e37c280427 100644 --- a/tests/_files/CoverageNotPrivateTest.php +++ b/tests/_files/CoverageNotPrivateTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageNotPrivateTest extends TestCase @@ -6,7 +14,7 @@ class CoverageNotPrivateTest extends TestCase /** * @covers CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageNotProtectedTest.php b/tests/_files/CoverageNotProtectedTest.php index 7c9c488cf21..310154f761f 100644 --- a/tests/_files/CoverageNotProtectedTest.php +++ b/tests/_files/CoverageNotProtectedTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageNotProtectedTest extends TestCase @@ -6,7 +14,7 @@ class CoverageNotProtectedTest extends TestCase /** * @covers CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageNotPublicTest.php b/tests/_files/CoverageNotPublicTest.php index 202724a05b3..9f6c41b5889 100644 --- a/tests/_files/CoverageNotPublicTest.php +++ b/tests/_files/CoverageNotPublicTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageNotPublicTest extends TestCase @@ -6,7 +14,7 @@ class CoverageNotPublicTest extends TestCase /** * @covers CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageNothingTest.php b/tests/_files/CoverageNothingTest.php index 4e1c0d0f562..e4c831fe35b 100644 --- a/tests/_files/CoverageNothingTest.php +++ b/tests/_files/CoverageNothingTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageNothingTest extends TestCase @@ -7,7 +15,7 @@ class CoverageNothingTest extends TestCase * @covers CoveredClass::publicMethod * @coversNothing */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoveragePrivateTest.php b/tests/_files/CoveragePrivateTest.php index 849c3480d41..741899ab88f 100644 --- a/tests/_files/CoveragePrivateTest.php +++ b/tests/_files/CoveragePrivateTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoveragePrivateTest extends TestCase @@ -6,7 +14,7 @@ class CoveragePrivateTest extends TestCase /** * @covers CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageProtectedTest.php b/tests/_files/CoverageProtectedTest.php index 6ae3544ca02..3fded37566d 100644 --- a/tests/_files/CoverageProtectedTest.php +++ b/tests/_files/CoverageProtectedTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoverageProtectedTest extends TestCase @@ -6,7 +14,7 @@ class CoverageProtectedTest extends TestCase /** * @covers CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoveragePublicTest.php b/tests/_files/CoveragePublicTest.php index d977090ccdb..e7f5f3e7ff3 100644 --- a/tests/_files/CoveragePublicTest.php +++ b/tests/_files/CoveragePublicTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class CoveragePublicTest extends TestCase @@ -6,7 +14,7 @@ class CoveragePublicTest extends TestCase /** * @covers CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoverageTwoDefaultClassAnnotations.php b/tests/_files/CoverageTwoDefaultClassAnnotations.php index 1011769f796..35a3e8bb911 100644 --- a/tests/_files/CoverageTwoDefaultClassAnnotations.php +++ b/tests/_files/CoverageTwoDefaultClassAnnotations.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ /** * @coversDefaultClass \NamespaceOne @@ -9,7 +17,7 @@ class CoverageTwoDefaultClassAnnotations /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/CoveredClass.php b/tests/_files/CoveredClass.php index f382ce99b5c..283b8498f34 100644 --- a/tests/_files/CoveredClass.php +++ b/tests/_files/CoveredClass.php @@ -1,36 +1,44 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class CoveredParentClass { - private function privateMethod() + public function publicMethod(): void { + $this->protectedMethod(); } - protected function protectedMethod() + protected function protectedMethod(): void { $this->privateMethod(); } - public function publicMethod() + private function privateMethod(): void { - $this->protectedMethod(); } } class CoveredClass extends CoveredParentClass { - private function privateMethod() + public function publicMethod(): void { + parent::publicMethod(); + $this->protectedMethod(); } - protected function protectedMethod() + protected function protectedMethod(): void { parent::protectedMethod(); $this->privateMethod(); } - public function publicMethod() + private function privateMethod(): void { - parent::publicMethod(); - $this->protectedMethod(); } } diff --git a/tests/_files/CoveredFunction.php b/tests/_files/CoveredFunction.php index 9989eb02ed4..a2b3a3b6aaa 100644 --- a/tests/_files/CoveredFunction.php +++ b/tests/_files/CoveredFunction.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +function globalFunction(): void { } diff --git a/tests/_files/CustomPrinter.php b/tests/_files/CustomPrinter.php index 0db08978cfb..c3eea0504ea 100644 --- a/tests/_files/CustomPrinter.php +++ b/tests/_files/CustomPrinter.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\TextUI\ResultPrinter; class CustomPrinter extends ResultPrinter diff --git a/tests/_files/DataProviderDebugTest.php b/tests/_files/DataProviderDebugTest.php index 3556382c01b..a0a54458823 100644 --- a/tests/_files/DataProviderDebugTest.php +++ b/tests/_files/DataProviderDebugTest.php @@ -1,22 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DataProviderDebugTest extends TestCase { - /** - * @dataProvider provider - */ - public function testProvider() - { - $this->assertTrue(true); - } - public static function provider() { $obj2 = new \stdClass(); $obj2->foo = 'bar'; - $obj3 = (object) [1,2,"Test\r\n",4,5,6,7,8]; + $obj3 = (object) [1, 2, "Test\r\n", 4, 5, 6, 7, 8]; $obj = new \stdClass(); //@codingStandardsIgnoreStart @@ -38,13 +38,21 @@ public static function provider() return [ [null, true, 1, 1.0], - [1.2, fopen('php://memory', 'r'), '1'], - [[[1,2,3], [3,4,5]]], + [1.2, \fopen('php://memory', 'r'), '1'], + [[[1, 2, 3], [3, 4, 5]]], // \n\r and \r is converted to \n ["this\nis\na\nvery\nvery\nvery\nvery\nvery\nvery\rlong\n\rtext"], [new \stdClass(), $obj, [], $storage, $obj3], - [chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5), implode('', array_map('chr', range(0x0e, 0x1f)))], - [chr(0x00) . chr(0x09)] + [\chr(0) . \chr(1) . \chr(2) . \chr(3) . \chr(4) . \chr(5), \implode('', \array_map('chr', \range(0x0e, 0x1f)))], + [\chr(0x00) . \chr(0x09)] ]; } + + /** + * @dataProvider provider + */ + public function testProvider(): void + { + $this->assertTrue(true); + } } diff --git a/tests/_files/DataProviderDependencyTest.php b/tests/_files/DataProviderDependencyTest.php index 5adc0898a5f..a5f745aa3c7 100644 --- a/tests/_files/DataProviderDependencyTest.php +++ b/tests/_files/DataProviderDependencyTest.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class DataProviderDependencyTest extends PHPUnit\Framework\TestCase { - public function testReference() + public function testReference(): void { $this->markTestSkipped('This test should be skipped.'); $this->assertTrue(true); @@ -11,14 +19,17 @@ public function testReference() * @see https://github.com/sebastianbergmann/phpunit/issues/1896 * @depends testReference * @dataProvider provider + * + * @param mixed $param */ - public function testDependency($param) + public function testDependency($param): void { } public function provider() { $this->markTestSkipped('Any test with this data provider should be skipped.'); + return []; } } diff --git a/tests/_files/DataProviderFilterTest.php b/tests/_files/DataProviderFilterTest.php index 156992336dd..0eba83d42c9 100644 --- a/tests/_files/DataProviderFilterTest.php +++ b/tests/_files/DataProviderFilterTest.php @@ -1,16 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DataProviderFilterTest extends TestCase { - /** - * @dataProvider truthProvider - */ - public function testTrue($truth) - { - $this->assertTrue($truth); - } - public static function truthProvider() { return [ @@ -21,14 +21,6 @@ public static function truthProvider() ]; } - /** - * @dataProvider falseProvider - */ - public function testFalse($false) - { - $this->assertFalse($false); - } - public static function falseProvider() { return [ @@ -38,4 +30,24 @@ public static function falseProvider() 'other false test2'=> [false] ]; } + + /** + * @dataProvider truthProvider + * + * @param mixed $truth + */ + public function testTrue($truth): void + { + $this->assertTrue($truth); + } + + /** + * @dataProvider falseProvider + * + * @param mixed $false + */ + public function testFalse($false): void + { + $this->assertFalse($false); + } } diff --git a/tests/_files/DataProviderIncompleteTest.php b/tests/_files/DataProviderIncompleteTest.php index 9ba6da92972..60753e25e18 100644 --- a/tests/_files/DataProviderIncompleteTest.php +++ b/tests/_files/DataProviderIncompleteTest.php @@ -1,20 +1,44 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DataProviderIncompleteTest extends TestCase { + public static function providerMethod() + { + return [ + [0, 0, 0], + [0, 1, 1], + ]; + } + /** * @dataProvider incompleteTestProviderMethod + * + * @param mixed $a + * @param mixed $b + * @param mixed $c */ - public function testIncomplete($a, $b, $c) + public function testIncomplete($a, $b, $c): void { $this->assertTrue(true); } /** * @dataProvider providerMethod + * + * @param mixed $a + * @param mixed $b + * @param mixed $c */ - public function testAdd($a, $b, $c) + public function testAdd($a, $b, $c): void { $this->assertEquals($c, $a + $b); } @@ -28,12 +52,4 @@ public function incompleteTestProviderMethod() [0, 1, 1], ]; } - - public static function providerMethod() - { - return [ - [0, 0, 0], - [0, 1, 1], - ]; - } } diff --git a/tests/_files/DataProviderIssue2833/FirstTest.php b/tests/_files/DataProviderIssue2833/FirstTest.php index 741aabf5813..074a7449c3d 100644 --- a/tests/_files/DataProviderIssue2833/FirstTest.php +++ b/tests/_files/DataProviderIssue2833/FirstTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Foo\DataProviderIssue2833; use PHPUnit\Framework\TestCase; @@ -8,8 +15,10 @@ class FirstTest extends TestCase { /** * @dataProvider provide + * + * @param mixed $x */ - public function testFirst($x) + public function testFirst($x): void { $this->assertTrue(true); } diff --git a/tests/_files/DataProviderIssue2833/SecondTest.php b/tests/_files/DataProviderIssue2833/SecondTest.php index 86adb28bca2..bbe2d10cf0f 100644 --- a/tests/_files/DataProviderIssue2833/SecondTest.php +++ b/tests/_files/DataProviderIssue2833/SecondTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Foo\DataProviderIssue2833; use PHPUnit\Framework\TestCase; @@ -8,7 +15,7 @@ class SecondTest extends TestCase { const DUMMY = 'dummy'; - public function testSecond() + public function testSecond(): void { $this->assertTrue(true); } diff --git a/tests/_files/DataProviderIssue2859/tests/another/TestWithDataProviderTest.php b/tests/_files/DataProviderIssue2859/tests/another/TestWithDataProviderTest.php index 4bffb49aeb2..29963df394c 100644 --- a/tests/_files/DataProviderIssue2859/tests/another/TestWithDataProviderTest.php +++ b/tests/_files/DataProviderIssue2859/tests/another/TestWithDataProviderTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Foo\DataProviderIssue2859; use PHPUnit\Framework\TestCase; @@ -8,8 +15,10 @@ class TestWithDataProviderTest extends TestCase { /** * @dataProvider provide + * + * @param mixed $x */ - public function testFirst($x) + public function testFirst($x): void { $this->assertTrue(true); } diff --git a/tests/_files/DataProviderIssue2922/FirstTest.php b/tests/_files/DataProviderIssue2922/FirstTest.php index 8b3302ca1ca..873c543f8ef 100644 --- a/tests/_files/DataProviderIssue2922/FirstTest.php +++ b/tests/_files/DataProviderIssue2922/FirstTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Foo\DataProviderIssue2922; use PHPUnit\Framework\TestCase; @@ -11,13 +18,15 @@ class FirstTest extends TestCase { /** * @dataProvider provide + * + * @param mixed $x */ - public function testFirst($x) + public function testFirst($x): void { $this->assertTrue(true); } - public function provide() + public function provide(): void { throw new \Exception(); } diff --git a/tests/_files/DataProviderIssue2922/SecondTest.php b/tests/_files/DataProviderIssue2922/SecondTest.php index 570ae560908..3f3251d139a 100644 --- a/tests/_files/DataProviderIssue2922/SecondTest.php +++ b/tests/_files/DataProviderIssue2922/SecondTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Foo\DataProviderIssue2922; use PHPUnit\Framework\TestCase; @@ -7,7 +14,7 @@ // the name of the class cannot match file name - if they match all is fine class SecondHelloWorldTest extends TestCase { - public function testSecond() + public function testSecond(): void { $this->assertTrue(true); } diff --git a/tests/_files/DataProviderSkippedTest.php b/tests/_files/DataProviderSkippedTest.php index 768f25bfb75..70d6614347f 100644 --- a/tests/_files/DataProviderSkippedTest.php +++ b/tests/_files/DataProviderSkippedTest.php @@ -1,20 +1,44 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DataProviderSkippedTest extends TestCase { + public static function providerMethod() + { + return [ + [0, 0, 0], + [0, 1, 1], + ]; + } + /** * @dataProvider skippedTestProviderMethod + * + * @param mixed $a + * @param mixed $b + * @param mixed $c */ - public function testSkipped($a, $b, $c) + public function testSkipped($a, $b, $c): void { $this->assertTrue(true); } /** * @dataProvider providerMethod + * + * @param mixed $a + * @param mixed $b + * @param mixed $c */ - public function testAdd($a, $b, $c) + public function testAdd($a, $b, $c): void { $this->assertEquals($c, $a + $b); } @@ -28,12 +52,4 @@ public function skippedTestProviderMethod() [0, 1, 1], ]; } - - public static function providerMethod() - { - return [ - [0, 0, 0], - [0, 1, 1], - ]; - } } diff --git a/tests/_files/DataProviderTest.php b/tests/_files/DataProviderTest.php index e65e9e86648..50ee9aef4bd 100644 --- a/tests/_files/DataProviderTest.php +++ b/tests/_files/DataProviderTest.php @@ -1,16 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DataProviderTest extends TestCase { - /** - * @dataProvider providerMethod - */ - public function testAdd($a, $b, $c) - { - $this->assertEquals($c, $a + $b); - } - public static function providerMethod() { return [ @@ -20,4 +20,16 @@ public static function providerMethod() [1, 0, 1] ]; } + + /** + * @dataProvider providerMethod + * + * @param mixed $a + * @param mixed $b + * @param mixed $c + */ + public function testAdd($a, $b, $c): void + { + $this->assertEquals($c, $a + $b); + } } diff --git a/tests/_files/DataProviderTestDoxTest.php b/tests/_files/DataProviderTestDoxTest.php index b137f331ae7..e03209408a9 100644 --- a/tests/_files/DataProviderTestDoxTest.php +++ b/tests/_files/DataProviderTestDoxTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DataProviderTestDoxTest extends TestCase @@ -7,7 +15,7 @@ class DataProviderTestDoxTest extends TestCase * @dataProvider provider * @testdox Does something with */ - public function testOne() + public function testOne(): void { $this->assertTrue(true); } @@ -15,7 +23,7 @@ public function testOne() /** * @dataProvider provider */ - public function testDoesSomethingElseWith() + public function testDoesSomethingElseWith(): void { $this->assertTrue(true); } diff --git a/tests/_files/DependencyFailureTest.php b/tests/_files/DependencyFailureTest.php index 36a26a593bd..4695305d73d 100644 --- a/tests/_files/DependencyFailureTest.php +++ b/tests/_files/DependencyFailureTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DependencyFailureTest extends TestCase { - public function testOne() + public function testOne(): void { $this->fail(); } @@ -11,7 +19,7 @@ public function testOne() /** * @depends testOne */ - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); } @@ -19,7 +27,7 @@ public function testTwo() /** * @depends !clone testTwo */ - public function testThree() + public function testThree(): void { $this->assertTrue(true); } @@ -27,7 +35,7 @@ public function testThree() /** * @depends clone testOne */ - public function testFour() + public function testFour(): void { $this->assertTrue(true); } diff --git a/tests/_files/DependencySuccessTest.php b/tests/_files/DependencySuccessTest.php index 66bfe687006..0dd9626c06f 100644 --- a/tests/_files/DependencySuccessTest.php +++ b/tests/_files/DependencySuccessTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DependencySuccessTest extends TestCase { - public function testOne() + public function testOne(): void { $this->assertTrue(true); } @@ -11,7 +19,7 @@ public function testOne() /** * @depends testOne */ - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); } @@ -19,7 +27,7 @@ public function testTwo() /** * @depends DependencySuccessTest::testTwo */ - public function testThree() + public function testThree(): void { $this->assertTrue(true); } diff --git a/tests/_files/DependencyTestSuite.php b/tests/_files/DependencyTestSuite.php index 86ff892bc04..4f0e63ccba1 100644 --- a/tests/_files/DependencyTestSuite.php +++ b/tests/_files/DependencyTestSuite.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestSuite; class DependencyTestSuite diff --git a/tests/_files/DoNoAssertionTestCase.php b/tests/_files/DoNoAssertionTestCase.php new file mode 100644 index 00000000000..b8671462fa8 --- /dev/null +++ b/tests/_files/DoNoAssertionTestCase.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +use PHPUnit\Framework\TestCase; + +class DoNoAssertionTestCase extends TestCase +{ + public function testNothing(): void + { + } +} diff --git a/tests/_files/DoesNotPerformAssertionsButPerformingAssertionsTest.php b/tests/_files/DoesNotPerformAssertionsButPerformingAssertionsTest.php index a992a0ed755..d0d63444cfb 100644 --- a/tests/_files/DoesNotPerformAssertionsButPerformingAssertionsTest.php +++ b/tests/_files/DoesNotPerformAssertionsButPerformingAssertionsTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class DoesNotPerformAssertionsButPerformingAssertionsTest extends TestCase @@ -6,7 +14,7 @@ class DoesNotPerformAssertionsButPerformingAssertionsTest extends TestCase /** * @doesNotPerformAssertions */ - public function testFalseAndTrueAreStillFine() + public function testFalseAndTrueAreStillFine(): void { $this->assertFalse(false); $this->assertTrue(true); diff --git a/tests/_files/DoubleTestCase.php b/tests/_files/DoubleTestCase.php index 08115c9c867..8862e8582a5 100644 --- a/tests/_files/DoubleTestCase.php +++ b/tests/_files/DoubleTestCase.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestResult; class DoubleTestCase implements Test { diff --git a/tests/_files/DummyBarTest.php b/tests/_files/DummyBarTest.php index 421c737ec4a..5958871fd9d 100644 --- a/tests/_files/DummyBarTest.php +++ b/tests/_files/DummyBarTest.php @@ -11,7 +11,7 @@ class DummyBarTest extends TestCase { - public function testBarEqualsBar() + public function testBarEqualsBar(): void { $this->assertEquals('Bar', 'Bar'); } diff --git a/tests/_files/DummyException.php b/tests/_files/DummyException.php index 29a69b997dd..29758e98571 100644 --- a/tests/_files/DummyException.php +++ b/tests/_files/DummyException.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class DummyException extends Exception { } diff --git a/tests/_files/DummyFooTest.php b/tests/_files/DummyFooTest.php index 0a20c8d7982..abfb9e085bb 100644 --- a/tests/_files/DummyFooTest.php +++ b/tests/_files/DummyFooTest.php @@ -11,7 +11,7 @@ class DummyFooTest extends TestCase { - public function testFooEqualsFoo() + public function testFooEqualsFoo(): void { $this->assertEquals('Foo', 'Foo'); } diff --git a/tests/_files/EmptyTestCaseTest.php b/tests/_files/EmptyTestCaseTest.php index 7da38eeaec1..ce9a1dedae6 100644 --- a/tests/_files/EmptyTestCaseTest.php +++ b/tests/_files/EmptyTestCaseTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class EmptyTestCaseTest extends TestCase diff --git a/tests/_files/ExceptionInAssertPostConditionsTest.php b/tests/_files/ExceptionInAssertPostConditionsTest.php index eb58992847e..5b5f6c24ea0 100644 --- a/tests/_files/ExceptionInAssertPostConditionsTest.php +++ b/tests/_files/ExceptionInAssertPostConditionsTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ExceptionInAssertPostConditionsTest extends TestCase @@ -14,24 +22,25 @@ protected function setUp(): void $this->setUp = true; } - protected function assertPreConditions() + protected function tearDown(): void { - $this->assertPreConditions = true; + $this->tearDown = true; } - public function testSomething() + public function testSomething(): void { $this->testSomething = true; } - protected function assertPostConditions() + protected function assertPreConditions(): void { - $this->assertPostConditions = true; - throw new Exception; + $this->assertPreConditions = true; } - protected function tearDown(): void + protected function assertPostConditions(): void { - $this->tearDown = true; + $this->assertPostConditions = true; + + throw new Exception; } } diff --git a/tests/_files/ExceptionInAssertPreConditionsTest.php b/tests/_files/ExceptionInAssertPreConditionsTest.php index 94d08fb4378..ccc9d1acd39 100644 --- a/tests/_files/ExceptionInAssertPreConditionsTest.php +++ b/tests/_files/ExceptionInAssertPreConditionsTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ExceptionInAssertPreConditionsTest extends TestCase @@ -14,24 +22,25 @@ protected function setUp(): void $this->setUp = true; } - protected function assertPreConditions() + protected function tearDown(): void { - $this->assertPreConditions = true; - throw new Exception; + $this->tearDown = true; } - public function testSomething() + public function testSomething(): void { $this->testSomething = true; } - protected function assertPostConditions() + protected function assertPreConditions(): void { - $this->assertPostConditions = true; + $this->assertPreConditions = true; + + throw new Exception; } - protected function tearDown(): void + protected function assertPostConditions(): void { - $this->tearDown = true; + $this->assertPostConditions = true; } } diff --git a/tests/_files/ExceptionInSetUpTest.php b/tests/_files/ExceptionInSetUpTest.php index 8ae0fc0e56b..154fe12da2e 100644 --- a/tests/_files/ExceptionInSetUpTest.php +++ b/tests/_files/ExceptionInSetUpTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ExceptionInSetUpTest extends TestCase @@ -12,26 +20,27 @@ class ExceptionInSetUpTest extends TestCase protected function setUp(): void { $this->setUp = true; + throw new Exception; } - protected function assertPreConditions() + protected function tearDown(): void { - $this->assertPreConditions = true; + $this->tearDown = true; } - public function testSomething() + public function testSomething(): void { $this->testSomething = true; } - protected function assertPostConditions() + protected function assertPreConditions(): void { - $this->assertPostConditions = true; + $this->assertPreConditions = true; } - protected function tearDown(): void + protected function assertPostConditions(): void { - $this->tearDown = true; + $this->assertPostConditions = true; } } diff --git a/tests/_files/ExceptionInTearDownTest.php b/tests/_files/ExceptionInTearDownTest.php index 4f3e968f6f1..c26f254bdb3 100644 --- a/tests/_files/ExceptionInTearDownTest.php +++ b/tests/_files/ExceptionInTearDownTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ExceptionInTearDownTest extends TestCase @@ -14,24 +22,25 @@ protected function setUp(): void $this->setUp = true; } - protected function assertPreConditions() + protected function tearDown(): void { - $this->assertPreConditions = true; + $this->tearDown = true; + + throw new Exception; } - public function testSomething() + public function testSomething(): void { $this->testSomething = true; } - protected function assertPostConditions() + protected function assertPreConditions(): void { - $this->assertPostConditions = true; + $this->assertPreConditions = true; } - protected function tearDown(): void + protected function assertPostConditions(): void { - $this->tearDown = true; - throw new Exception; + $this->assertPostConditions = true; } } diff --git a/tests/_files/ExceptionInTest.php b/tests/_files/ExceptionInTest.php index 6032d065cf3..d33049d735b 100644 --- a/tests/_files/ExceptionInTest.php +++ b/tests/_files/ExceptionInTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ExceptionInTest extends TestCase @@ -14,24 +22,25 @@ protected function setUp(): void $this->setUp = true; } - protected function assertPreConditions() + protected function tearDown(): void { - $this->assertPreConditions = true; + $this->tearDown = true; } - public function testSomething() + public function testSomething(): void { $this->testSomething = true; + throw new Exception; } - protected function assertPostConditions() + protected function assertPreConditions(): void { - $this->assertPostConditions = true; + $this->assertPreConditions = true; } - protected function tearDown(): void + protected function assertPostConditions(): void { - $this->tearDown = true; + $this->assertPostConditions = true; } } diff --git a/tests/_files/ExceptionInTestDetectedInTeardown.php b/tests/_files/ExceptionInTestDetectedInTeardown.php new file mode 100644 index 00000000000..a8f2fb5b83f --- /dev/null +++ b/tests/_files/ExceptionInTestDetectedInTeardown.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +use PHPUnit\Framework\TestCase; + +use PHPUnit\Runner\BaseTestRunner; + +class ExceptionInTestDetectedInTeardown extends TestCase +{ + public $exceptionDetected = false; + + protected function tearDown(): void + { + if (BaseTestRunner::STATUS_ERROR == $this->getStatus()) { + $this->exceptionDetected = true; + } + } + + public function testSomething(): void + { + throw new Exception; + } +} diff --git a/tests/_files/ExceptionNamespaceTest.php b/tests/_files/ExceptionNamespaceTest.php index 70fa56e067e..7713a5d8540 100644 --- a/tests/_files/ExceptionNamespaceTest.php +++ b/tests/_files/ExceptionNamespaceTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace My\Space; class ExceptionNamespaceTest extends \PHPUnit\Framework\TestCase @@ -23,7 +30,7 @@ class ExceptionNamespaceTest extends \PHPUnit\Framework\TestCase * @expectedExceptionMessage My\Space\ExceptionNamespaceTest::ERROR_MESSAGE * @expectedExceptionCode My\Space\ExceptionNamespaceTest::ERROR_CODE */ - public function testConstants() + public function testConstants(): void { } @@ -32,7 +39,7 @@ public function testConstants() * @expectedExceptionCode My\Space\ExceptionNamespaceTest::UNKNOWN_CODE_CONSTANT * @expectedExceptionMessage My\Space\ExceptionNamespaceTest::UNKNOWN_MESSAGE_CONSTANT */ - public function testUnknownConstants() + public function testUnknownConstants(): void { } } diff --git a/tests/_files/ExceptionStackTest.php b/tests/_files/ExceptionStackTest.php index 15e70256434..62bc73319e1 100644 --- a/tests/_files/ExceptionStackTest.php +++ b/tests/_files/ExceptionStackTest.php @@ -1,10 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\ExpectationFailedException; use PHPUnit\Framework\TestCase; class ExceptionStackTest extends TestCase { - public function testPrintingChildException() + public function testPrintingChildException(): void { try { $this->assertEquals([1], [2], 'message'); @@ -15,7 +23,7 @@ public function testPrintingChildException() } } - public function testNestedExceptions() + public function testNestedExceptions(): void { $exceptionThree = new Exception('Three'); $exceptionTwo = new InvalidArgumentException('Two', 0, $exceptionThree); diff --git a/tests/_files/ExceptionTest.php b/tests/_files/ExceptionTest.php index af6895793fd..47855f1ef7d 100644 --- a/tests/_files/ExceptionTest.php +++ b/tests/_files/ExceptionTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ExceptionTest extends TestCase @@ -27,35 +35,35 @@ class ExceptionTest extends TestCase /** * @expectedException FooBarBaz */ - public function testOne() + public function testOne(): void { } /** * @expectedException Foo_Bar_Baz */ - public function testTwo() + public function testTwo(): void { } /** * @expectedException Foo\Bar\Baz */ - public function testThree() + public function testThree(): void { } /** * @expectedException ほげ */ - public function testFour() + public function testFour(): void { } /** * @expectedException Class Message 1234 */ - public function testFive() + public function testFive(): void { } @@ -64,7 +72,7 @@ public function testFive() * @expectedExceptionMessage Message * @expectedExceptionCode 1234 */ - public function testSix() + public function testSix(): void { } @@ -73,7 +81,7 @@ public function testSix() * @expectedExceptionMessage Message * @expectedExceptionCode ExceptionCode */ - public function testSeven() + public function testSeven(): void { } @@ -82,7 +90,7 @@ public function testSeven() * @expectedExceptionMessage Message * @expectedExceptionCode 0 */ - public function testEight() + public function testEight(): void { } @@ -91,12 +99,12 @@ public function testEight() * @expectedExceptionMessage ExceptionTest::ERROR_MESSAGE * @expectedExceptionCode ExceptionTest::ERROR_CODE */ - public function testNine() + public function testNine(): void { } /** @expectedException Class */ - public function testSingleLine() + public function testSingleLine(): void { } @@ -105,7 +113,7 @@ public function testSingleLine() * @expectedExceptionCode ExceptionTest::UNKNOWN_CODE_CONSTANT * @expectedExceptionMessage ExceptionTest::UNKNOWN_MESSAGE_CONSTANT */ - public function testUnknownConstants() + public function testUnknownConstants(): void { } @@ -115,7 +123,7 @@ public function testUnknownConstants() * @expectedExceptionMessage Message * @expectedExceptionMessageRegExp #regex# */ - public function testWithRegexMessage() + public function testWithRegexMessage(): void { } @@ -125,7 +133,7 @@ public function testWithRegexMessage() * @expectedExceptionMessage Message * @expectedExceptionMessageRegExp ExceptionTest::ERROR_MESSAGE_REGEX */ - public function testWithRegexMessageFromClassConstant() + public function testWithRegexMessageFromClassConstant(): void { } @@ -135,7 +143,7 @@ public function testWithRegexMessageFromClassConstant() * @expectedExceptionMessage Message * @expectedExceptionMessageRegExp ExceptionTest::UNKNOWN_MESSAGE_REGEX_CONSTANT */ - public function testWithUnknowRegexMessageFromClassConstant() + public function testWithUnknowRegexMessageFromClassConstant(): void { } } diff --git a/tests/_files/Failure.php b/tests/_files/Failure.php index 52a65fb4216..2ced7cfd8bb 100644 --- a/tests/_files/Failure.php +++ b/tests/_files/Failure.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Failure extends TestCase { - protected function runTest() + protected function runTest(): void { $this->fail(); } diff --git a/tests/_files/FailureTest.php b/tests/_files/FailureTest.php index fd32fc9ef17..e80b7470ace 100644 --- a/tests/_files/FailureTest.php +++ b/tests/_files/FailureTest.php @@ -1,19 +1,27 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class FailureTest extends TestCase { - public function testAssertArrayEqualsArray() + public function testAssertArrayEqualsArray(): void { $this->assertEquals([1], [2], 'message'); } - public function testAssertIntegerEqualsInteger() + public function testAssertIntegerEqualsInteger(): void { $this->assertEquals(1, 2, 'message'); } - public function testAssertObjectEqualsObject() + public function testAssertObjectEqualsObject(): void { $a = new stdClass; $a->foo = 'bar'; @@ -24,53 +32,53 @@ public function testAssertObjectEqualsObject() $this->assertEquals($a, $b, 'message'); } - public function testAssertNullEqualsString() + public function testAssertNullEqualsString(): void { $this->assertEquals(null, 'bar', 'message'); } - public function testAssertStringEqualsString() + public function testAssertStringEqualsString(): void { $this->assertEquals('foo', 'bar', 'message'); } - public function testAssertTextEqualsText() + public function testAssertTextEqualsText(): void { $this->assertEquals("foo\nbar\n", "foo\nbaz\n", 'message'); } - public function testAssertStringMatchesFormat() + public function testAssertStringMatchesFormat(): void { $this->assertStringMatchesFormat('*%s*', '**', 'message'); } - public function testAssertNumericEqualsNumeric() + public function testAssertNumericEqualsNumeric(): void { $this->assertEquals(1, 2, 'message'); } - public function testAssertTextSameText() + public function testAssertTextSameText(): void { $this->assertSame('foo', 'bar', 'message'); } - public function testAssertObjectSameObject() + public function testAssertObjectSameObject(): void { $this->assertSame(new stdClass, new stdClass, 'message'); } - public function testAssertObjectSameNull() + public function testAssertObjectSameNull(): void { $this->assertSame(new stdClass, null, 'message'); } - public function testAssertFloatSameFloat() + public function testAssertFloatSameFloat(): void { $this->assertSame(1.0, 1.5, 'message'); } // Note that due to the implementation of this assertion it counts as 2 asserts - public function testAssertStringMatchesFormatFile() + public function testAssertStringMatchesFormatFile(): void { $this->assertStringMatchesFormatFile(__DIR__ . '/expectedFileFormat.txt', '...BAR...'); } diff --git a/tests/_files/FalsyConstraint.php b/tests/_files/FalsyConstraint.php index 7752375e6af..cd1542d1a10 100644 --- a/tests/_files/FalsyConstraint.php +++ b/tests/_files/FalsyConstraint.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\Constraint\Constraint; final class FalsyConstraint extends Constraint @@ -10,7 +18,7 @@ public function matches($other): bool public function toString(): string { - return sprintf( + return \sprintf( 'is accepted by %s', self::class ); diff --git a/tests/_files/FatalTest.php b/tests/_files/FatalTest.php index bfb9509d5e1..847cfa0238a 100644 --- a/tests/_files/FatalTest.php +++ b/tests/_files/FatalTest.php @@ -1,13 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class FatalTest extends TestCase { - public function testFatalError() + public function testFatalError(): void { - if (extension_loaded('xdebug')) { - xdebug_disable(); + if (\extension_loaded('xdebug')) { + \xdebug_disable(); } eval('class FatalTest {}'); diff --git a/tests/_files/IgnoreCodeCoverageClass.php b/tests/_files/IgnoreCodeCoverageClass.php index 88c86605e5c..f50bbcad77c 100644 --- a/tests/_files/IgnoreCodeCoverageClass.php +++ b/tests/_files/IgnoreCodeCoverageClass.php @@ -1,4 +1,13 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + /** * @codeCoverageIgnore */ diff --git a/tests/_files/IgnoreCodeCoverageClassTest.php b/tests/_files/IgnoreCodeCoverageClassTest.php index 0281e258bf3..73cc027b61f 100644 --- a/tests/_files/IgnoreCodeCoverageClassTest.php +++ b/tests/_files/IgnoreCodeCoverageClassTest.php @@ -1,15 +1,23 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class IgnoreCodeCoverageClassTest extends TestCase { - public function testReturnTrue() + public function testReturnTrue(): void { $sut = new IgnoreCodeCoverageClass(); $this->assertTrue($sut->returnTrue()); } - public function testReturnFalse() + public function testReturnFalse(): void { $sut = new IgnoreCodeCoverageClass(); $this->assertFalse($sut->returnFalse()); diff --git a/tests/_files/IncompleteTest.php b/tests/_files/IncompleteTest.php index 350b367a491..15cddd9dc72 100644 --- a/tests/_files/IncompleteTest.php +++ b/tests/_files/IncompleteTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class IncompleteTest extends TestCase { - public function testIncomplete() + public function testIncomplete(): void { $this->markTestIncomplete('Test incomplete'); } diff --git a/tests/_files/Inheritance/InheritanceA.php b/tests/_files/Inheritance/InheritanceA.php index 1fa5fd3fc23..fc4f9be68c5 100644 --- a/tests/_files/Inheritance/InheritanceA.php +++ b/tests/_files/Inheritance/InheritanceA.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ require_once __DIR__ . '/InheritanceB.php'; class InheritanceA extends InheritanceB diff --git a/tests/_files/Inheritance/InheritanceB.php b/tests/_files/Inheritance/InheritanceB.php index cfae7b3399b..796f1a7433a 100644 --- a/tests/_files/Inheritance/InheritanceB.php +++ b/tests/_files/Inheritance/InheritanceB.php @@ -1,10 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class InheritanceB extends TestCase { - public function testSomething() + public function testSomething(): void { } } diff --git a/tests/_files/InheritedTestCase.php b/tests/_files/InheritedTestCase.php index 3df721563e0..9fef5141625 100644 --- a/tests/_files/InheritedTestCase.php +++ b/tests/_files/InheritedTestCase.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class InheritedTestCase extends OneTestCase { - public function test2() + public function test2(): void { } } diff --git a/tests/_files/IniTest.php b/tests/_files/IniTest.php index 7773c4629fa..45517d4d1c2 100644 --- a/tests/_files/IniTest.php +++ b/tests/_files/IniTest.php @@ -1,10 +1,18 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class IniTest extends TestCase { - public function testIni() + public function testIni(): void { - $this->assertEquals('application/x-test', ini_get('default_mimetype')); + $this->assertEquals('application/x-test', \ini_get('default_mimetype')); } } diff --git a/tests/_files/IsolationTest.php b/tests/_files/IsolationTest.php index c67ae1cd93a..63f7141dec2 100644 --- a/tests/_files/IsolationTest.php +++ b/tests/_files/IsolationTest.php @@ -1,14 +1,22 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class IsolationTest extends TestCase { - public function testIsInIsolationReturnsFalse() + public function testIsInIsolationReturnsFalse(): void { $this->assertFalse($this->isInIsolation()); } - public function testIsInIsolationReturnsTrue() + public function testIsInIsolationReturnsTrue(): void { $this->assertTrue($this->isInIsolation()); } diff --git a/tests/_files/MockRunner.php b/tests/_files/MockRunner.php index 5da5b2f2df9..be9442fade1 100644 --- a/tests/_files/MockRunner.php +++ b/tests/_files/MockRunner.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Runner\BaseTestRunner; class MockRunner extends BaseTestRunner { - protected function runFailed($message) + protected function runFailed($message): void { } } diff --git a/tests/_files/Mockable.php b/tests/_files/Mockable.php index 95024e9ed80..9e425be4ffe 100644 --- a/tests/_files/Mockable.php +++ b/tests/_files/Mockable.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Mockable { public $constructorCalled = false; @@ -9,18 +17,18 @@ public function __construct() $this->constructorCalled = false; } - public function foo() + public function __clone() { - return true; + $this->cloned = true; } - public function bar() + public function foo() { return true; } - public function __clone() + public function bar() { - $this->cloned = true; + return true; } } diff --git a/tests/_files/MultiDependencyTest.php b/tests/_files/MultiDependencyTest.php index 0fca2fd6af2..4d3d7320a62 100644 --- a/tests/_files/MultiDependencyTest.php +++ b/tests/_files/MultiDependencyTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class MultiDependencyTest extends TestCase @@ -20,8 +28,11 @@ public function testTwo() /** * @depends testOne * @depends testTwo + * + * @param mixed $a + * @param mixed $b */ - public function testThree($a, $b) + public function testThree($a, $b): void { $this->assertEquals('foo', $a); $this->assertEquals('bar', $b); diff --git a/tests/_files/MultipleDataProviderTest.php b/tests/_files/MultipleDataProviderTest.php index 087c3cbfa41..f87986a589e 100644 --- a/tests/_files/MultipleDataProviderTest.php +++ b/tests/_files/MultipleDataProviderTest.php @@ -1,26 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class MultipleDataProviderTest extends TestCase { - /** - * @dataProvider providerA - * @dataProvider providerB - * @dataProvider providerC - */ - public function testOne() - { - } - - /** - * @dataProvider providerD - * @dataProvider providerE - * @dataProvider providerF - */ - public function testTwo() - { - } - public static function providerA() { return [ @@ -51,14 +41,18 @@ public static function providerC() public static function providerD() { yield ['ok', null, null]; + yield ['ok', null, null]; + yield ['ok', null, null]; } public static function providerE() { yield [null, 'ok', null]; + yield [null, 'ok', null]; + yield [null, 'ok', null]; } @@ -74,4 +68,22 @@ public static function providerF() return $object->getIterator(); } + + /** + * @dataProvider providerA + * @dataProvider providerB + * @dataProvider providerC + */ + public function testOne(): void + { + } + + /** + * @dataProvider providerD + * @dataProvider providerE + * @dataProvider providerF + */ + public function testTwo(): void + { + } } diff --git a/tests/_files/MyCommand.php b/tests/_files/MyCommand.php index 02947858102..390f7fea0a4 100644 --- a/tests/_files/MyCommand.php +++ b/tests/_files/MyCommand.php @@ -1,16 +1,24 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\TextUI\Command; class MyCommand extends Command { public function __construct() { - $this->longOptions['my-option='] = 'myHandler'; + $this->longOptions['my-option='] = 'myHandler'; $this->longOptions['my-other-option'] = null; } - public function myHandler($value) + public function myHandler($value): void { - echo __METHOD__ . " $value\n"; + print __METHOD__ . " $value\n"; } } diff --git a/tests/_files/NamedConstraint.php b/tests/_files/NamedConstraint.php index 55aec256a42..4916cd79bf7 100644 --- a/tests/_files/NamedConstraint.php +++ b/tests/_files/NamedConstraint.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\Constraint\Constraint; final class NamedConstraint extends Constraint diff --git a/tests/_files/NamespaceCoverageClassExtendedTest.php b/tests/_files/NamespaceCoverageClassExtendedTest.php index 5348aed5daf..7c60471198f 100644 --- a/tests/_files/NamespaceCoverageClassExtendedTest.php +++ b/tests/_files/NamespaceCoverageClassExtendedTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageClassExtendedTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageClassExtendedTest extends TestCase /** * @covers Foo\CoveredClass */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageClassTest.php b/tests/_files/NamespaceCoverageClassTest.php index 2b91f1fdd75..efb6a447d3b 100644 --- a/tests/_files/NamespaceCoverageClassTest.php +++ b/tests/_files/NamespaceCoverageClassTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageClassTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageClassTest extends TestCase /** * @covers Foo\CoveredClass */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageCoversClassPublicTest.php b/tests/_files/NamespaceCoverageCoversClassPublicTest.php index d3bc1a93b0d..4e6d56d9a26 100644 --- a/tests/_files/NamespaceCoverageCoversClassPublicTest.php +++ b/tests/_files/NamespaceCoverageCoversClassPublicTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -9,7 +17,7 @@ class NamespaceCoverageCoversClassPublicTest extends TestCase /** * @covers ::publicMethod */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageCoversClassTest.php b/tests/_files/NamespaceCoverageCoversClassTest.php index 67752dd9c56..78970cf08c7 100644 --- a/tests/_files/NamespaceCoverageCoversClassTest.php +++ b/tests/_files/NamespaceCoverageCoversClassTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** @@ -14,7 +22,7 @@ class NamespaceCoverageCoversClassTest extends TestCase * @covers \Foo\CoveredParentClass::protectedMethod * @covers \Foo\CoveredParentClass::publicMethod */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageMethodTest.php b/tests/_files/NamespaceCoverageMethodTest.php index f83ae5f0e52..2b9cfd6eabb 100644 --- a/tests/_files/NamespaceCoverageMethodTest.php +++ b/tests/_files/NamespaceCoverageMethodTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageMethodTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageMethodTest extends TestCase /** * @covers Foo\CoveredClass::publicMethod */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageNotPrivateTest.php b/tests/_files/NamespaceCoverageNotPrivateTest.php index b4983c74763..63fe46d5fe4 100644 --- a/tests/_files/NamespaceCoverageNotPrivateTest.php +++ b/tests/_files/NamespaceCoverageNotPrivateTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageNotPrivateTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageNotPrivateTest extends TestCase /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageNotProtectedTest.php b/tests/_files/NamespaceCoverageNotProtectedTest.php index ceb7b35bf9a..5d64a564908 100644 --- a/tests/_files/NamespaceCoverageNotProtectedTest.php +++ b/tests/_files/NamespaceCoverageNotProtectedTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageNotProtectedTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageNotProtectedTest extends TestCase /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageNotPublicTest.php b/tests/_files/NamespaceCoverageNotPublicTest.php index 60aff7a0184..eed2b0f3aa3 100644 --- a/tests/_files/NamespaceCoverageNotPublicTest.php +++ b/tests/_files/NamespaceCoverageNotPublicTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageNotPublicTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageNotPublicTest extends TestCase /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoveragePrivateTest.php b/tests/_files/NamespaceCoveragePrivateTest.php index d5eb77ec027..370f2ed4324 100644 --- a/tests/_files/NamespaceCoveragePrivateTest.php +++ b/tests/_files/NamespaceCoveragePrivateTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoveragePrivateTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoveragePrivateTest extends TestCase /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoverageProtectedTest.php b/tests/_files/NamespaceCoverageProtectedTest.php index 6a6eaca47e6..031a6cf60dd 100644 --- a/tests/_files/NamespaceCoverageProtectedTest.php +++ b/tests/_files/NamespaceCoverageProtectedTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoverageProtectedTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoverageProtectedTest extends TestCase /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoveragePublicTest.php b/tests/_files/NamespaceCoveragePublicTest.php index f32803ecf80..87a146f0de4 100644 --- a/tests/_files/NamespaceCoveragePublicTest.php +++ b/tests/_files/NamespaceCoveragePublicTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NamespaceCoveragePublicTest extends TestCase @@ -6,7 +14,7 @@ class NamespaceCoveragePublicTest extends TestCase /** * @covers Foo\CoveredClass:: */ - public function testSomething() + public function testSomething(): void { $o = new Foo\CoveredClass; $o->publicMethod(); diff --git a/tests/_files/NamespaceCoveredClass.php b/tests/_files/NamespaceCoveredClass.php index 5bd0ddfb237..40651ba76f4 100644 --- a/tests/_files/NamespaceCoveredClass.php +++ b/tests/_files/NamespaceCoveredClass.php @@ -1,38 +1,46 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Foo; class CoveredParentClass { - private function privateMethod() + public function publicMethod(): void { + $this->protectedMethod(); } - protected function protectedMethod() + protected function protectedMethod(): void { $this->privateMethod(); } - public function publicMethod() + private function privateMethod(): void { - $this->protectedMethod(); } } class CoveredClass extends CoveredParentClass { - private function privateMethod() + public function publicMethod(): void { + parent::publicMethod(); + $this->protectedMethod(); } - protected function protectedMethod() + protected function protectedMethod(): void { parent::protectedMethod(); $this->privateMethod(); } - public function publicMethod() + private function privateMethod(): void { - parent::publicMethod(); - $this->protectedMethod(); } } diff --git a/tests/_files/NamespaceCoveredFunction.php b/tests/_files/NamespaceCoveredFunction.php index afc00d7c32b..62d9582e067 100644 --- a/tests/_files/NamespaceCoveredFunction.php +++ b/tests/_files/NamespaceCoveredFunction.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace foo; function func() diff --git a/tests/_files/NoArgTestCaseTest.php b/tests/_files/NoArgTestCaseTest.php index 1715d8ba6c0..f00c87fa68f 100644 --- a/tests/_files/NoArgTestCaseTest.php +++ b/tests/_files/NoArgTestCaseTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NoArgTestCaseTest extends TestCase { - public function testNothing() + public function testNothing(): void { } } diff --git a/tests/_files/NoTestCaseClass.php b/tests/_files/NoTestCaseClass.php index d64e4e1c609..7dace27bb4f 100644 --- a/tests/_files/NoTestCaseClass.php +++ b/tests/_files/NoTestCaseClass.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class NoTestCaseClass { } diff --git a/tests/_files/NoTestCases.php b/tests/_files/NoTestCases.php index 4c352765257..1ec9957f5ec 100644 --- a/tests/_files/NoTestCases.php +++ b/tests/_files/NoTestCases.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NoTestCases extends TestCase { - public function noTestCase() + public function noTestCase(): void { } } diff --git a/tests/_files/NonStatic.php b/tests/_files/NonStatic.php index 8cb064e8de7..1c9839e419e 100644 --- a/tests/_files/NonStatic.php +++ b/tests/_files/NonStatic.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class NonStatic { - public function suite() + public function suite(): void { } } diff --git a/tests/_files/NotExistingCoveredElementTest.php b/tests/_files/NotExistingCoveredElementTest.php index 0836a8c84ae..a92f6dda3e4 100644 --- a/tests/_files/NotExistingCoveredElementTest.php +++ b/tests/_files/NotExistingCoveredElementTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NotExistingCoveredElementTest extends TestCase @@ -6,21 +14,21 @@ class NotExistingCoveredElementTest extends TestCase /** * @covers NotExistingClass */ - public function testOne() + public function testOne(): void { } /** * @covers NotExistingClass::notExistingMethod */ - public function testTwo() + public function testTwo(): void { } /** * @covers NotExistingClass:: */ - public function testThree() + public function testThree(): void { } } diff --git a/tests/_files/NotPublicTestCase.php b/tests/_files/NotPublicTestCase.php index 3a9a14939bd..5175cabfc1f 100644 --- a/tests/_files/NotPublicTestCase.php +++ b/tests/_files/NotPublicTestCase.php @@ -1,13 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NotPublicTestCase extends TestCase { - public function testPublic() + public function testPublic(): void { } - protected function testNotPublic() + protected function testNotPublic(): void { } } diff --git a/tests/_files/NotVoidTestCase.php b/tests/_files/NotVoidTestCase.php index 77ee99e457b..4c8853eb72f 100644 --- a/tests/_files/NotVoidTestCase.php +++ b/tests/_files/NotVoidTestCase.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NotVoidTestCase extends TestCase diff --git a/tests/_files/NothingTest.php b/tests/_files/NothingTest.php index 08533855f52..88c91eefa5a 100644 --- a/tests/_files/NothingTest.php +++ b/tests/_files/NothingTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class NothingTest extends TestCase { - public function testNothing() + public function testNothing(): void { } } diff --git a/tests/_files/OneTestCase.php b/tests/_files/OneTestCase.php index 4b86753c9cc..118bfcb436d 100644 --- a/tests/_files/OneTestCase.php +++ b/tests/_files/OneTestCase.php @@ -1,13 +1,21 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class OneTestCase extends TestCase { - public function noTestCase() + public function noTestCase(): void { } - public function testCase($arg = '') + public function testCase($arg = ''): void { } } diff --git a/tests/_files/OutputTestCase.php b/tests/_files/OutputTestCase.php index 5c8fcc227ef..52a46e96928 100644 --- a/tests/_files/OutputTestCase.php +++ b/tests/_files/OutputTestCase.php @@ -1,27 +1,35 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class OutputTestCase extends TestCase { - public function testExpectOutputStringFooActualFoo() + public function testExpectOutputStringFooActualFoo(): void { $this->expectOutputString('foo'); print 'foo'; } - public function testExpectOutputStringFooActualBar() + public function testExpectOutputStringFooActualBar(): void { $this->expectOutputString('foo'); print 'bar'; } - public function testExpectOutputRegexFooActualFoo() + public function testExpectOutputRegexFooActualFoo(): void { $this->expectOutputRegex('/foo/'); print 'foo'; } - public function testExpectOutputRegexFooActualBar() + public function testExpectOutputRegexFooActualBar(): void { $this->expectOutputRegex('/foo/'); print 'bar'; diff --git a/tests/_files/OverrideTestCase.php b/tests/_files/OverrideTestCase.php index fcc276c50fe..6cdb2dcfc9d 100644 --- a/tests/_files/OverrideTestCase.php +++ b/tests/_files/OverrideTestCase.php @@ -1,7 +1,15 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class OverrideTestCase extends OneTestCase { - public function testCase($arg = '') + public function testCase($arg = ''): void { } } diff --git a/tests/_files/ParseTestMethodAnnotationsMock.php b/tests/_files/ParseTestMethodAnnotationsMock.php index 69ea33171e0..81f5bb28e80 100644 --- a/tests/_files/ParseTestMethodAnnotationsMock.php +++ b/tests/_files/ParseTestMethodAnnotationsMock.php @@ -1,4 +1,13 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + /** * @theClassAnnotation */ diff --git a/tests/_files/RequirementsClassBeforeClassHookTest.php b/tests/_files/RequirementsClassBeforeClassHookTest.php index 88420151e1a..c06fed146e0 100644 --- a/tests/_files/RequirementsClassBeforeClassHookTest.php +++ b/tests/_files/RequirementsClassBeforeClassHookTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; /** diff --git a/tests/_files/RequirementsClassDocBlockTest.php b/tests/_files/RequirementsClassDocBlockTest.php index c420afb5b7d..db10d9eae7a 100644 --- a/tests/_files/RequirementsClassDocBlockTest.php +++ b/tests/_files/RequirementsClassDocBlockTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ /** * @requires PHP 5.3 @@ -16,7 +24,7 @@ class RequirementsClassDocBlockTest * @requires function testFuncMethod * @requires extension testExtMethod */ - public function testMethod() + public function testMethod(): void { } } diff --git a/tests/_files/RequirementsTest.php b/tests/_files/RequirementsTest.php index 2df8838b765..43de8ea374d 100644 --- a/tests/_files/RequirementsTest.php +++ b/tests/_files/RequirementsTest.php @@ -11,21 +11,21 @@ class RequirementsTest extends TestCase { - public function testOne() + public function testOne(): void { } /** * @requires PHPUnit 1.0 */ - public function testTwo() + public function testTwo(): void { } /** * @requires PHP 2.0 */ - public function testThree() + public function testThree(): void { } @@ -33,49 +33,49 @@ public function testThree() * @requires PHPUnit 2.0 * @requires PHP 1.0 */ - public function testFour() + public function testFour(): void { } /** * @requires PHP 5.4.0RC6 */ - public function testFive() + public function testFive(): void { } /** * @requires PHP 5.4.0-alpha1 */ - public function testSix() + public function testSix(): void { } /** * @requires PHP 5.4.0beta2 */ - public function testSeven() + public function testSeven(): void { } /** * @requires PHP 5.4-dev */ - public function testEight() + public function testEight(): void { } /** * @requires function testFunc */ - public function testNine() + public function testNine(): void { } /** * @requires extension testExt */ - public function testTen() + public function testTen(): void { } @@ -83,7 +83,7 @@ public function testTen() * @requires OS SunOS * @requires OSFAMILY Solaris */ - public function testEleven() + public function testEleven(): void { } @@ -98,63 +98,63 @@ public function testEleven() * @requires extension testExtThree 2.0 * @requires setting not_a_setting Off */ - public function testAllPossibleRequirements() + public function testAllPossibleRequirements(): void { } /** * @requires function array_merge */ - public function testExistingFunction() + public function testExistingFunction(): void { } /** * @requires function ReflectionMethod::setAccessible */ - public function testExistingMethod() + public function testExistingMethod(): void { } /** * @requires extension spl */ - public function testExistingExtension() + public function testExistingExtension(): void { } /** * @requires OS .* */ - public function testExistingOs() + public function testExistingOs(): void { } /** * @requires PHPUnit 1111111 */ - public function testAlwaysSkip() + public function testAlwaysSkip(): void { } /** * @requires PHP 9999999 */ - public function testAlwaysSkip2() + public function testAlwaysSkip2(): void { } /** * @requires OS DOESNOTEXIST */ - public function testAlwaysSkip3() + public function testAlwaysSkip3(): void { } /** * @requires OSFAMILY DOESNOTEXIST */ - public function testAlwaysSkip4() + public function testAlwaysSkip4(): void { } @@ -162,203 +162,203 @@ public function testAlwaysSkip4() * @requires extension spl * @requires OS .* */ - public function testSpace() + public function testSpace(): void { } /** * @requires extension testExt 1.8.0 */ - public function testSpecificExtensionVersion() + public function testSpecificExtensionVersion(): void { } /** * @requires PHP < 5.4 */ - public function testPHPVersionOperatorLessThan() + public function testPHPVersionOperatorLessThan(): void { } /** * @requires PHP <= 5.4 */ - public function testPHPVersionOperatorLessThanEquals() + public function testPHPVersionOperatorLessThanEquals(): void { } /** * @requires PHP > 99 */ - public function testPHPVersionOperatorGreaterThan() + public function testPHPVersionOperatorGreaterThan(): void { } /** * @requires PHP >= 99 */ - public function testPHPVersionOperatorGreaterThanEquals() + public function testPHPVersionOperatorGreaterThanEquals(): void { } /** * @requires PHP = 5.4 */ - public function testPHPVersionOperatorEquals() + public function testPHPVersionOperatorEquals(): void { } /** * @requires PHP == 5.4 */ - public function testPHPVersionOperatorDoubleEquals() + public function testPHPVersionOperatorDoubleEquals(): void { } /** * @requires PHP != 99 */ - public function testPHPVersionOperatorBangEquals() + public function testPHPVersionOperatorBangEquals(): void { } /** * @requires PHP <> 99 */ - public function testPHPVersionOperatorNotEquals() + public function testPHPVersionOperatorNotEquals(): void { } /** * @requires PHP >=99 */ - public function testPHPVersionOperatorNoSpace() + public function testPHPVersionOperatorNoSpace(): void { } /** * @requires PHPUnit < 1.0 */ - public function testPHPUnitVersionOperatorLessThan() + public function testPHPUnitVersionOperatorLessThan(): void { } /** * @requires PHPUnit <= 1.0 */ - public function testPHPUnitVersionOperatorLessThanEquals() + public function testPHPUnitVersionOperatorLessThanEquals(): void { } /** * @requires PHPUnit > 99 */ - public function testPHPUnitVersionOperatorGreaterThan() + public function testPHPUnitVersionOperatorGreaterThan(): void { } /** * @requires PHPUnit >= 99 */ - public function testPHPUnitVersionOperatorGreaterThanEquals() + public function testPHPUnitVersionOperatorGreaterThanEquals(): void { } /** * @requires PHPUnit = 1.0 */ - public function testPHPUnitVersionOperatorEquals() + public function testPHPUnitVersionOperatorEquals(): void { } /** * @requires PHPUnit == 1.0 */ - public function testPHPUnitVersionOperatorDoubleEquals() + public function testPHPUnitVersionOperatorDoubleEquals(): void { } /** * @requires PHPUnit != 99 */ - public function testPHPUnitVersionOperatorBangEquals() + public function testPHPUnitVersionOperatorBangEquals(): void { } /** * @requires PHPUnit <> 99 */ - public function testPHPUnitVersionOperatorNotEquals() + public function testPHPUnitVersionOperatorNotEquals(): void { } /** * @requires PHPUnit >=99 */ - public function testPHPUnitVersionOperatorNoSpace() + public function testPHPUnitVersionOperatorNoSpace(): void { } /** * @requires extension testExtOne < 1.0 */ - public function testExtensionVersionOperatorLessThan() + public function testExtensionVersionOperatorLessThan(): void { } /** * @requires extension testExtOne <= 1.0 */ - public function testExtensionVersionOperatorLessThanEquals() + public function testExtensionVersionOperatorLessThanEquals(): void { } /** * @requires extension testExtOne > 99 */ - public function testExtensionVersionOperatorGreaterThan() + public function testExtensionVersionOperatorGreaterThan(): void { } /** * @requires extension testExtOne >= 99 */ - public function testExtensionVersionOperatorGreaterThanEquals() + public function testExtensionVersionOperatorGreaterThanEquals(): void { } /** * @requires extension testExtOne = 1.0 */ - public function testExtensionVersionOperatorEquals() + public function testExtensionVersionOperatorEquals(): void { } /** * @requires extension testExtOne == 1.0 */ - public function testExtensionVersionOperatorDoubleEquals() + public function testExtensionVersionOperatorDoubleEquals(): void { } /** * @requires extension testExtOne != 99 */ - public function testExtensionVersionOperatorBangEquals() + public function testExtensionVersionOperatorBangEquals(): void { } /** * @requires extension testExtOne <> 99 */ - public function testExtensionVersionOperatorNotEquals() + public function testExtensionVersionOperatorNotEquals(): void { } /** * @requires extension testExtOne >=99 */ - public function testExtensionVersionOperatorNoSpace() + public function testExtensionVersionOperatorNoSpace(): void { } @@ -366,7 +366,7 @@ public function testExtensionVersionOperatorNoSpace() * @requires PHP ~1.0 * @requires PHPUnit ~2.0 */ - public function testVersionConstraintTildeMajor() + public function testVersionConstraintTildeMajor(): void { } @@ -374,7 +374,7 @@ public function testVersionConstraintTildeMajor() * @requires PHP ^1.0 * @requires PHPUnit ^2.0 */ - public function testVersionConstraintCaretMajor() + public function testVersionConstraintCaretMajor(): void { } @@ -382,7 +382,7 @@ public function testVersionConstraintCaretMajor() * @requires PHP ~3.4.7 * @requires PHPUnit ~4.7.1 */ - public function testVersionConstraintTildeMinor() + public function testVersionConstraintTildeMinor(): void { } @@ -390,7 +390,7 @@ public function testVersionConstraintTildeMinor() * @requires PHP ^7.0.17 * @requires PHPUnit ^4.7.1 */ - public function testVersionConstraintCaretMinor() + public function testVersionConstraintCaretMinor(): void { } @@ -398,7 +398,7 @@ public function testVersionConstraintCaretMinor() * @requires PHP ^5.6 || ^7.0 * @requires PHPUnit ^5.0 || ^6.0 */ - public function testVersionConstraintCaretOr() + public function testVersionConstraintCaretOr(): void { } @@ -406,7 +406,7 @@ public function testVersionConstraintCaretOr() * @requires PHP ~5.6.22 || ~7.0.17 * @requires PHPUnit ^5.0.5 || ^6.0.6 */ - public function testVersionConstraintTildeOr() + public function testVersionConstraintTildeOr(): void { } @@ -414,14 +414,15 @@ public function testVersionConstraintTildeOr() * @requires PHP ~5.6.22 || ^7.0 * @requires PHPUnit ~5.6.22 || ^7.0 */ - public function testVersionConstraintTildeOrCaret() + public function testVersionConstraintTildeOrCaret(): void { } + /** * @requires PHP ^5.6 || ~7.0.17 * @requires PHPUnit ^5.6 || ~7.0.17 */ - public function testVersionConstraintCaretOrTilde() + public function testVersionConstraintCaretOrTilde(): void { } @@ -429,26 +430,28 @@ public function testVersionConstraintCaretOrTilde() * @requires PHP ~5.6.22 || ~7.0.17 * @requires PHPUnit ~5.6.22 || ~7.0.17 */ - public function testVersionConstraintRegexpIgnoresWhitespace() + public function testVersionConstraintRegexpIgnoresWhitespace(): void { } /** * @requires PHP ~^12345 */ - public function testVersionConstraintInvalidPhpConstraint() + public function testVersionConstraintInvalidPhpConstraint(): void { } + /** * @requires PHPUnit ~^12345 */ - public function testVersionConstraintInvalidPhpUnitConstraint() + public function testVersionConstraintInvalidPhpUnitConstraint(): void { } + /** * @requires setting display_errors On */ - public function testSettingDisplayErrorsOn() + public function testSettingDisplayErrorsOn(): void { } } diff --git a/tests/_files/SampleArrayAccess.php b/tests/_files/SampleArrayAccess.php index ff6f0bffbf6..3bd6501ed46 100644 --- a/tests/_files/SampleArrayAccess.php +++ b/tests/_files/SampleArrayAccess.php @@ -1,9 +1,11 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ class SampleArrayAccess implements ArrayAccess { @@ -13,22 +15,26 @@ public function __construct() { $this->container = []; } - public function offsetSet($offset, $value) + + public function offsetSet($offset, $value): void { - if (is_null($offset)) { + if (\is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } + public function offsetExists($offset) { return isset($this->container[$offset]); } - public function offsetUnset($offset) + + public function offsetUnset($offset): void { unset($this->container[$offset]); } + public function offsetGet($offset) { return $this->container[$offset] ?? null; diff --git a/tests/_files/SampleClass.php b/tests/_files/SampleClass.php index b908bc78441..1042a1c4d85 100644 --- a/tests/_files/SampleClass.php +++ b/tests/_files/SampleClass.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class SampleClass { public $a; diff --git a/tests/_files/Singleton.php b/tests/_files/Singleton.php index bfdf3bb0aea..0bfeb3ef5e1 100644 --- a/tests/_files/Singleton.php +++ b/tests/_files/Singleton.php @@ -1,16 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Singleton { private static $uniqueInstance = null; - protected function __construct() - { - } - - final private function __clone() - { - } - public static function getInstance() { if (self::$uniqueInstance === null) { @@ -19,4 +19,12 @@ public static function getInstance() return self::$uniqueInstance; } + + protected function __construct() + { + } + + private function __clone() + { + } } diff --git a/tests/_files/StackTest.php b/tests/_files/StackTest.php index 5b6de0abed3..76537d93747 100644 --- a/tests/_files/StackTest.php +++ b/tests/_files/StackTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class StackTest extends TestCase @@ -9,7 +17,7 @@ public function testPush() $this->assertCount(0, $stack); $stack[] = 'foo'; - $this->assertEquals('foo', end($stack)); + $this->assertEquals('foo', \end($stack)); $this->assertCount(1, $stack); return $stack; @@ -18,9 +26,9 @@ public function testPush() /** * @depends testPush */ - public function testPop(array $stack) + public function testPop(array $stack): void { - $this->assertEquals('foo', array_pop($stack)); + $this->assertEquals('foo', \array_pop($stack)); $this->assertCount(0, $stack); } } diff --git a/tests/_files/StatusTest.php b/tests/_files/StatusTest.php index 07761697873..8f891dffc1d 100644 --- a/tests/_files/StatusTest.php +++ b/tests/_files/StatusTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace vendor\project; use PHPUnit\Framework\TestCase; @@ -6,36 +14,36 @@ class StatusTest extends TestCase { - public function testSuccess() + public function testSuccess(): void { $this->assertTrue(true); } - public function testFailure() + public function testFailure(): void { $this->assertTrue(false); } - public function testError() + public function testError(): void { throw new \RuntimeException; } - public function testIncomplete() + public function testIncomplete(): void { $this->markTestIncomplete(); } - public function testSkipped() + public function testSkipped(): void { $this->markTestSkipped(); } - public function testRisky() + public function testRisky(): void { } - public function testWarning() + public function testWarning(): void { throw new Warning; } diff --git a/tests/_files/StopOnWarningTestSuite.php b/tests/_files/StopOnWarningTestSuite.php index a4b6f131da6..862b37eb910 100644 --- a/tests/_files/StopOnWarningTestSuite.php +++ b/tests/_files/StopOnWarningTestSuite.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestSuite; class StopOnWarningTestSuite diff --git a/tests/_files/StopsOnWarningTest.php b/tests/_files/StopsOnWarningTest.php index 8967309ca49..2018d059dc9 100644 --- a/tests/_files/StopsOnWarningTest.php +++ b/tests/_files/StopsOnWarningTest.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class StopsOnWarningTest extends TestCase { - public function testOne() + public function testOne(): void { } } diff --git a/tests/_files/Struct.php b/tests/_files/Struct.php index 12977a996af..6344b43ed3c 100644 --- a/tests/_files/Struct.php +++ b/tests/_files/Struct.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class Struct { public $var; diff --git a/tests/_files/Success.php b/tests/_files/Success.php index b444c006ba4..14c2ff92146 100644 --- a/tests/_files/Success.php +++ b/tests/_files/Success.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class Success extends TestCase { - protected function runTest() + protected function runTest(): void { $this->assertTrue(true); } diff --git a/tests/_files/TemplateMethodsTest.php b/tests/_files/TemplateMethodsTest.php index e6677f78625..c2f68b4c5e1 100644 --- a/tests/_files/TemplateMethodsTest.php +++ b/tests/_files/TemplateMethodsTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TemplateMethodsTest extends TestCase @@ -8,46 +16,47 @@ public static function setUpBeforeClass(): void print __METHOD__ . "\n"; } - protected function setUp(): void + public static function tearDownAfterClass(): void { print __METHOD__ . "\n"; } - protected function assertPreConditions() + protected function setUp(): void { print __METHOD__ . "\n"; } - public function testOne() + protected function tearDown(): void { print __METHOD__ . "\n"; - $this->assertTrue(true); } - public function testTwo() + public function testOne(): void { print __METHOD__ . "\n"; - $this->assertTrue(false); + $this->assertTrue(true); } - protected function assertPostConditions() + public function testTwo(): void { print __METHOD__ . "\n"; + $this->assertTrue(false); } - protected function tearDown(): void + protected function assertPreConditions(): void { print __METHOD__ . "\n"; } - public static function tearDownAfterClass(): void + protected function assertPostConditions(): void { print __METHOD__ . "\n"; } - protected function onNotSuccessfulTest(Throwable $t) + protected function onNotSuccessfulTest(Throwable $t): void { print __METHOD__ . "\n"; + throw $t; } } diff --git a/tests/_files/TestAutoreferenced.php b/tests/_files/TestAutoreferenced.php index 8145bbc80c7..280d73c9f02 100644 --- a/tests/_files/TestAutoreferenced.php +++ b/tests/_files/TestAutoreferenced.php @@ -1,11 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TestAutoreferenced extends TestCase { - public $myTestData = null; + public $myTestData; - public function testJsonEncodeException($data) + public function testJsonEncodeException($data): void { $this->myTestData = $data; } diff --git a/tests/_files/TestDoxGroupTest.php b/tests/_files/TestDoxGroupTest.php index 9f3fbfcfcca..4ad06293a4d 100644 --- a/tests/_files/TestDoxGroupTest.php +++ b/tests/_files/TestDoxGroupTest.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TestDoxGroupTest extends TestCase @@ -7,7 +14,7 @@ class TestDoxGroupTest extends TestCase /** * @group one */ - public function testOne() + public function testOne(): void { $this->assertTrue(true); } @@ -15,7 +22,7 @@ public function testOne() /** * @group two */ - public function testTwo() + public function testTwo(): void { $this->assertTrue(true); } diff --git a/tests/_files/TestGeneratorMaker.php b/tests/_files/TestGeneratorMaker.php index df7cb1e5a6e..bd8650ea83a 100644 --- a/tests/_files/TestGeneratorMaker.php +++ b/tests/_files/TestGeneratorMaker.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class TestGeneratorMaker { public function create($array = []) diff --git a/tests/_files/TestIncomplete.php b/tests/_files/TestIncomplete.php index 66768146b05..3ae44f3082e 100644 --- a/tests/_files/TestIncomplete.php +++ b/tests/_files/TestIncomplete.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TestIncomplete extends TestCase { - protected function runTest() + protected function runTest(): void { $this->markTestIncomplete('Incomplete test'); } diff --git a/tests/_files/TestIterator.php b/tests/_files/TestIterator.php index d26ac853b43..23eee3f045f 100644 --- a/tests/_files/TestIterator.php +++ b/tests/_files/TestIterator.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class TestIterator implements Iterator { protected $array; @@ -9,14 +17,14 @@ public function __construct($array = []) $this->array = $array; } - public function rewind() + public function rewind(): void { $this->position = 0; } public function valid() { - return $this->position < count($this->array); + return $this->position < \count($this->array); } public function key() @@ -29,7 +37,7 @@ public function current() return $this->array[$this->position]; } - public function next() + public function next(): void { $this->position++; } diff --git a/tests/_files/TestIterator2.php b/tests/_files/TestIterator2.php index 3b47fa36757..676141e7eba 100644 --- a/tests/_files/TestIterator2.php +++ b/tests/_files/TestIterator2.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class TestIterator2 implements Iterator { protected $data; @@ -10,26 +18,26 @@ public function __construct(array $array) public function current() { - return current($this->data); + return \current($this->data); } - public function next() + public function next(): void { - next($this->data); + \next($this->data); } public function key() { - return key($this->data); + return \key($this->data); } public function valid() { - return key($this->data) !== null; + return \key($this->data) !== null; } - public function rewind() + public function rewind(): void { - reset($this->data); + \reset($this->data); } } diff --git a/tests/_files/TestIteratorAggregate.php b/tests/_files/TestIteratorAggregate.php index 21424f2b1af..7c98561361e 100644 --- a/tests/_files/TestIteratorAggregate.php +++ b/tests/_files/TestIteratorAggregate.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class TestIteratorAggregate implements IteratorAggregate { private $traversable; diff --git a/tests/_files/TestIteratorAggregate2.php b/tests/_files/TestIteratorAggregate2.php index e02b89a03dd..338e340fac7 100644 --- a/tests/_files/TestIteratorAggregate2.php +++ b/tests/_files/TestIteratorAggregate2.php @@ -1,8 +1,13 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -/* This class is used for testing a chain of IteratorAggregate objects, since - * PHP does allow IteratorAggregate::getIterator() to return an instance of the - * same class. */ class TestIteratorAggregate2 implements IteratorAggregate { private $traversable; diff --git a/tests/_files/TestSkipped.php b/tests/_files/TestSkipped.php index 7a237738281..00bab2be0ce 100644 --- a/tests/_files/TestSkipped.php +++ b/tests/_files/TestSkipped.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TestSkipped extends TestCase { - protected function runTest() + protected function runTest(): void { $this->markTestSkipped('Skipped test'); } diff --git a/tests/_files/TestTestError.php b/tests/_files/TestTestError.php index 103957910dd..92f6c9b6337 100644 --- a/tests/_files/TestTestError.php +++ b/tests/_files/TestTestError.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TestError extends TestCase { - protected function runTest() + protected function runTest(): void { throw new Exception; } diff --git a/tests/_files/TestWithTest.php b/tests/_files/TestWithTest.php index 5bae95f3073..7806c804c5d 100644 --- a/tests/_files/TestWithTest.php +++ b/tests/_files/TestWithTest.php @@ -1,19 +1,16 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class TestWithTest extends TestCase { - /** - * @testWith [0, 0, 0] - * [0, 1, 1] - * [1, 2, 3] - * [20, 22, 42] - */ - public function testAdd($a, $b, $c) - { - $this->assertEquals($c, $a + $b); - } - public static function providerMethod() { return [ @@ -23,4 +20,19 @@ public static function providerMethod() [1, 0, 1] ]; } + + /** + * @testWith [0, 0, 0] + * [0, 1, 1] + * [1, 2, 3] + * [20, 22, 42] + * + * @param mixed $a + * @param mixed $b + * @param mixed $c + */ + public function testAdd($a, $b, $c): void + { + $this->assertEquals($c, $a + $b); + } } diff --git a/tests/_files/ThrowExceptionTestCase.php b/tests/_files/ThrowExceptionTestCase.php index 0c325f94b15..203750b5d2f 100644 --- a/tests/_files/ThrowExceptionTestCase.php +++ b/tests/_files/ThrowExceptionTestCase.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ThrowExceptionTestCase extends TestCase { - public function test() + public function test(): void { throw new RuntimeException('A runtime error occurred'); } diff --git a/tests/_files/ThrowNoExceptionTestCase.php b/tests/_files/ThrowNoExceptionTestCase.php index f4a5da624d1..a759f3279cf 100644 --- a/tests/_files/ThrowNoExceptionTestCase.php +++ b/tests/_files/ThrowNoExceptionTestCase.php @@ -1,9 +1,17 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class ThrowNoExceptionTestCase extends TestCase { - public function test() + public function test(): void { } } diff --git a/tests/_files/TruthyConstraint.php b/tests/_files/TruthyConstraint.php index 77dc10d02fc..825ba8c2d8c 100644 --- a/tests/_files/TruthyConstraint.php +++ b/tests/_files/TruthyConstraint.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\Constraint\Constraint; final class TruthyConstraint extends Constraint @@ -10,7 +18,7 @@ public function matches($other): bool public function toString(): string { - return sprintf( + return \sprintf( 'is accepted by %s', self::class ); diff --git a/tests/_files/VariousIterableDataProviderTest.php b/tests/_files/VariousIterableDataProviderTest.php index 2da4492c9b6..bff499e1feb 100644 --- a/tests/_files/VariousIterableDataProviderTest.php +++ b/tests/_files/VariousIterableDataProviderTest.php @@ -1,16 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class VariousIterableDataProviderTest { - /** - * @dataProvider asArrayProvider - * @dataProvider asIteratorProvider - * @dataProvider asTraversableProvider - */ - public function test() - { - } - public static function asArrayProvider() { return [ @@ -23,7 +21,9 @@ public static function asArrayProvider() public static function asIteratorProvider() { yield ['D']; + yield ['E']; + yield ['F']; } @@ -35,4 +35,13 @@ public static function asTraversableProvider() ['I'], ]); } + + /** + * @dataProvider asArrayProvider + * @dataProvider asIteratorProvider + * @dataProvider asTraversableProvider + */ + public function test(): void + { + } } diff --git a/tests/_files/WasRun.php b/tests/_files/WasRun.php index bf15dde4ff8..ea3d057afb3 100644 --- a/tests/_files/WasRun.php +++ b/tests/_files/WasRun.php @@ -1,11 +1,19 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\Framework\TestCase; class WasRun extends TestCase { public $wasRun = false; - protected function runTest() + protected function runTest(): void { $this->wasRun = true; } diff --git a/tests/_files/WrapperIteratorAggregate.php b/tests/_files/WrapperIteratorAggregate.php index eae8647dfc9..0dadad641ec 100644 --- a/tests/_files/WrapperIteratorAggregate.php +++ b/tests/_files/WrapperIteratorAggregate.php @@ -1,5 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ class WrapperIteratorAggregate implements IteratorAggregate { /** @@ -9,7 +16,7 @@ class WrapperIteratorAggregate implements IteratorAggregate public function __construct($baseCollection) { - assert(is_array($baseCollection) || $baseCollection instanceof Traversable); + \assert(\is_array($baseCollection) || $baseCollection instanceof Traversable); $this->baseCollection = $baseCollection; } diff --git a/tests/_files/phpunit-example-extension/tests/OneTest.php b/tests/_files/phpunit-example-extension/tests/OneTest.php index 485276d4828..dc61f99dc23 100644 --- a/tests/_files/phpunit-example-extension/tests/OneTest.php +++ b/tests/_files/phpunit-example-extension/tests/OneTest.php @@ -1,4 +1,12 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ use PHPUnit\ExampleExtension\TestCaseTrait; use PHPUnit\Framework\TestCase; @@ -6,7 +14,7 @@ class OneTest extends TestCase { use TestCaseTrait; - public function testOne() + public function testOne(): void { $this->assertTrue(true); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a3d83bbfb1e..548dc7bf269 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,30 +1,52 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +if (!\defined('TEST_FILES_PATH')) { + \define('TEST_FILES_PATH', __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR); } -ini_set('precision', 14); -ini_set('serialize_precision', 14); +\ini_set('precision', 14); +\ini_set('serialize_precision', 14); require_once __DIR__ . '/../vendor/autoload.php'; -// TODO: Figure out why (some of) these are required (the classes should be autoloaded instead) +// TODO: Figure out why these are required (the classes should be autoloaded instead) require_once TEST_FILES_PATH . 'BeforeAndAfterTest.php'; + require_once TEST_FILES_PATH . 'BeforeClassAndAfterClassTest.php'; + require_once TEST_FILES_PATH . 'TestWithTest.php'; + require_once TEST_FILES_PATH . 'BeforeClassWithOnlyDataProviderTest.php'; + require_once TEST_FILES_PATH . 'DataProviderSkippedTest.php'; + require_once TEST_FILES_PATH . 'DataProviderDependencyTest.php'; + require_once TEST_FILES_PATH . 'DataProviderIncompleteTest.php'; + require_once TEST_FILES_PATH . 'InheritedTestCase.php'; + require_once TEST_FILES_PATH . 'NoTestCaseClass.php'; + require_once TEST_FILES_PATH . 'NoTestCases.php'; + require_once TEST_FILES_PATH . 'NotPublicTestCase.php'; + require_once TEST_FILES_PATH . 'NotVoidTestCase.php'; + require_once TEST_FILES_PATH . 'OverrideTestCase.php'; + require_once TEST_FILES_PATH . 'RequirementsClassBeforeClassHookTest.php'; + require_once TEST_FILES_PATH . 'NoArgTestCaseTest.php'; + require_once TEST_FILES_PATH . 'Singleton.php'; -require_once TEST_FILES_PATH . 'Mockable.php'; -require_once TEST_FILES_PATH . 'CoverageNamespacedFunctionTest.php'; -require_once TEST_FILES_PATH . 'NamespaceCoveredFunction.php'; + +require_once TEST_FILES_PATH . 'DoNoAssertionTestCase.php';