diff --git a/ChangeLog-5.7.md b/ChangeLog-5.7.md index 96acdbe3414..c39373c40d0 100644 --- a/ChangeLog-5.7.md +++ b/ChangeLog-5.7.md @@ -2,6 +2,12 @@ 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.24] - 2017-MM-DD + +### 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 @@ -183,6 +189,7 @@ All notable changes of the PHPUnit 5.7 release series are documented in this fil * 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.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 diff --git a/ChangeLog-6.4.md b/ChangeLog-6.4.md index d0dfb48e8fa..ec6e90331e4 100644 --- a/ChangeLog-6.4.md +++ b/ChangeLog-6.4.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 6.4 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## [6.4.5] - 2017-MM-DD + +### Fixed + +* Fixed [#2833](https://github.com/sebastianbergmann/phpunit/issues/2833): Test class loaded during data provider execution is not discovered + ## [6.4.4] - 2017-11-08 ### Fixed @@ -51,6 +57,7 @@ All notable changes of the PHPUnit 6.4 release series are documented in this fil * Fixed [#2750](https://github.com/sebastianbergmann/phpunit/issues/2750): Useless call to `array_map()` +[6.4.5]: https://github.com/sebastianbergmann/phpunit/compare/6.4.4...6.4.5 [6.4.4]: https://github.com/sebastianbergmann/phpunit/compare/6.4.3...6.4.4 [6.4.3]: https://github.com/sebastianbergmann/phpunit/compare/6.4.2...6.4.3 [6.4.2]: https://github.com/sebastianbergmann/phpunit/compare/6.4.1...6.4.2 diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index 90fa54d3507..01b277341d4 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -99,6 +99,11 @@ class TestSuite implements Test, SelfDescribing, IteratorAggregate */ private $iteratorFilter; + /** + * @var array + */ + private $declaredClasses; + /** * Constructs a new TestSuite: * @@ -123,6 +128,8 @@ class TestSuite implements Test, SelfDescribing, IteratorAggregate */ public function __construct($theClass = '', $name = '') { + $this->declaredClasses = \get_declared_classes(); + $argumentsValid = false; if (\is_object($theClass) && @@ -317,7 +324,7 @@ public function addTestFile($filename) // test class itself. Figure out the actual test class. $classes = \get_declared_classes(); $filename = Fileloader::checkAndLoad($filename); - $newClasses = \array_diff(\get_declared_classes(), $classes); + $newClasses = \array_diff(\get_declared_classes(), $this->declaredClasses); // The diff is empty in case a parent class (with test methods) is added // AFTER a child class that inherited from it. To account for that case, @@ -327,7 +334,8 @@ public function addTestFile($filename) // On the assumption that test classes are defined first in files, // process discovered classes in approximate LIFO order, so as to // avoid unnecessary reflection. - $this->foundClasses = \array_merge($newClasses, $this->foundClasses); + $this->foundClasses = \array_merge($newClasses, $this->foundClasses); + $this->declaredClasses = \get_declared_classes(); } // The test class's name must match the filename, either in full, or as diff --git a/tests/TextUI/dataprovider-pair.phpt b/tests/TextUI/dataprovider-pair.phpt new file mode 100644 index 00000000000..ef4c5a7e893 --- /dev/null +++ b/tests/TextUI/dataprovider-pair.phpt @@ -0,0 +1,17 @@ +--TEST-- +phpunit ../_files/DataProviderPair +--FILE-- +assertTrue(true); + } + + public function provide() + { + SecondTest::DUMMY; + + return [[true]]; + } +} diff --git a/tests/_files/DataProviderPair/SecondTest.php b/tests/_files/DataProviderPair/SecondTest.php new file mode 100644 index 00000000000..92e48e65d2c --- /dev/null +++ b/tests/_files/DataProviderPair/SecondTest.php @@ -0,0 +1,15 @@ +assertTrue(true); + } +}