From 853e43c1c8c331d2a2fef93150201618889143c9 Mon Sep 17 00:00:00 2001 From: Alex Sladkov Date: Fri, 26 Jan 2018 16:50:03 +0300 Subject: [PATCH 1/7] Fix: PHPUnit shouldn't fail when a test suite contains both *.phpt files and unconventionally named tests There's no point in calling the TestSuite constructor with any class which is not instance of TestSuite and does not extend TestCase. --- src/Framework/TestSuite.php | 2 +- tests/Regression/GitHub/2972.phpt | 18 ++++++++++++++++++ .../GitHub/2972/issue-2972-test.phpt | 10 ++++++++++ .../2972/unconventiallyNamedIssue2972Test.php | 10 ++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/Regression/GitHub/2972.phpt create mode 100644 tests/Regression/GitHub/2972/issue-2972-test.phpt create mode 100644 tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index f96e479d6af..a1c665a7ed1 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -277,7 +277,7 @@ public function addTestSuite($testClass) } } - if (!$suiteMethod && !$testClass->isAbstract()) { + if (!$suiteMethod && !$testClass->isAbstract() && $testClass->isSubclassOf(TestCase::class)) { $this->addTest(new self($testClass)); } } else { diff --git a/tests/Regression/GitHub/2972.phpt b/tests/Regression/GitHub/2972.phpt new file mode 100644 index 00000000000..db9e56963dc --- /dev/null +++ b/tests/Regression/GitHub/2972.phpt @@ -0,0 +1,18 @@ +--TEST-- +GH-2972: Test suite shouldn't fail when it contains both *.phpt files and unconventionally named tests +--FILE-- + +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +.. 2 / 2 (100%) + +Time: %s, Memory: %s + +OK (2 tests, 2 assertions) diff --git a/tests/Regression/GitHub/2972/issue-2972-test.phpt b/tests/Regression/GitHub/2972/issue-2972-test.phpt new file mode 100644 index 00000000000..040f3d37627 --- /dev/null +++ b/tests/Regression/GitHub/2972/issue-2972-test.phpt @@ -0,0 +1,10 @@ +--TEST-- +Just a sample test dor issue 2972, does not actually test anything +--FILE-- + +===DONE=== +--EXPECT-- +Hello world +===DONE=== diff --git a/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php b/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php new file mode 100644 index 00000000000..b8dc363944d --- /dev/null +++ b/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php @@ -0,0 +1,10 @@ +assertNotEmpty('Hello world!'); + } +} From 20ffc440dd6b3b6f4a2c7be1832fb1e5f912c2a2 Mon Sep 17 00:00:00 2001 From: Alex Sladkov Date: Fri, 26 Jan 2018 17:05:43 +0300 Subject: [PATCH 2/7] typo --- tests/Regression/GitHub/2972/issue-2972-test.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Regression/GitHub/2972/issue-2972-test.phpt b/tests/Regression/GitHub/2972/issue-2972-test.phpt index 040f3d37627..4d09cf5a94e 100644 --- a/tests/Regression/GitHub/2972/issue-2972-test.phpt +++ b/tests/Regression/GitHub/2972/issue-2972-test.phpt @@ -1,5 +1,5 @@ --TEST-- -Just a sample test dor issue 2972, does not actually test anything +Just a sample test for issue 2972, does not actually test anything --FILE-- Date: Fri, 26 Jan 2018 17:07:18 +0300 Subject: [PATCH 3/7] code style requires a namespace --- .../GitHub/2972/unconventiallyNamedIssue2972Test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php b/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php index b8dc363944d..3fd57f018ec 100644 --- a/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php +++ b/tests/Regression/GitHub/2972/unconventiallyNamedIssue2972Test.php @@ -1,4 +1,7 @@ Date: Fri, 26 Jan 2018 17:45:57 +0100 Subject: [PATCH 4/7] Make this compatible with PHPUnit 5.7 --- src/Framework/TestSuite.php | 2 +- tests/Regression/GitHub/2972.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index a1c665a7ed1..0ed6be4f13c 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -277,7 +277,7 @@ public function addTestSuite($testClass) } } - if (!$suiteMethod && !$testClass->isAbstract() && $testClass->isSubclassOf(TestCase::class)) { + if (!$suiteMethod && !$testClass->isAbstract() && $testClass->isSubclassOf(PHPUnit_Framework_TestCase::class)) { $this->addTest(new self($testClass)); } } else { diff --git a/tests/Regression/GitHub/2972.phpt b/tests/Regression/GitHub/2972.phpt index db9e56963dc..a46ced14a4b 100644 --- a/tests/Regression/GitHub/2972.phpt +++ b/tests/Regression/GitHub/2972.phpt @@ -6,7 +6,7 @@ $_SERVER['argv'][1] = '--no-configuration'; $_SERVER['argv'][2] = __DIR__ . '/2972/'; require __DIR__ . '/../../bootstrap.php'; -PHPUnit\TextUI\Command::main(); +PHPUnit_TextUI_Command::main(); ?> --EXPECTF-- PHPUnit %s by Sebastian Bergmann and contributors. From e92a128096c1cf00050212fb64253f40757ab5a2 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 26 Jan 2018 17:47:27 +0100 Subject: [PATCH 5/7] Update ChangeLog --- ChangeLog-5.7.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog-5.7.md b/ChangeLog-5.7.md index bdd0723c6a5..dd4e4bc25b3 100644 --- a/ChangeLog-5.7.md +++ b/ChangeLog-5.7.md @@ -7,6 +7,8 @@ All notable changes of the PHPUnit 5.7 release series are documented in this fil ### 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 From ed61c120e75b19421bfafab6452ee2155daf9e5c Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 26 Jan 2018 17:47:46 +0100 Subject: [PATCH 6/7] Revert "Make this compatible with PHPUnit 5.7" This reverts commit d125b4ec8f308a2e5aa8dc5db3f89ca299e9820d. --- src/Framework/TestSuite.php | 2 +- tests/Regression/GitHub/2972.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index 64a933bd931..1f014f37a55 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -286,7 +286,7 @@ public function addTestSuite($testClass) } } - if (!$suiteMethod && !$testClass->isAbstract() && $testClass->isSubclassOf(PHPUnit_Framework_TestCase::class)) { + if (!$suiteMethod && !$testClass->isAbstract() && $testClass->isSubclassOf(TestCase::class)) { $this->addTest(new self($testClass)); } } else { diff --git a/tests/Regression/GitHub/2972.phpt b/tests/Regression/GitHub/2972.phpt index a46ced14a4b..db9e56963dc 100644 --- a/tests/Regression/GitHub/2972.phpt +++ b/tests/Regression/GitHub/2972.phpt @@ -6,7 +6,7 @@ $_SERVER['argv'][1] = '--no-configuration'; $_SERVER['argv'][2] = __DIR__ . '/2972/'; require __DIR__ . '/../../bootstrap.php'; -PHPUnit_TextUI_Command::main(); +PHPUnit\TextUI\Command::main(); ?> --EXPECTF-- PHPUnit %s by Sebastian Bergmann and contributors. From c4cdf0e12b3a5de0ee433338c95f6ec40a28bdfd Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 26 Jan 2018 17:48:21 +0100 Subject: [PATCH 7/7] Update ChangeLog --- ChangeLog-6.5.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog-6.5.md b/ChangeLog-6.5.md index f8ae36fd2ec..6ff08c06bf5 100644 --- a/ChangeLog-6.5.md +++ b/ChangeLog-6.5.md @@ -7,6 +7,8 @@ All notable changes of the PHPUnit 6.5 release series are documented in this fil ### 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 ## [6.5.5] - 2017-12-17