diff --git a/src/Framework/DataProviderTestSuite.php b/src/Framework/DataProviderTestSuite.php index ce7f38de0fb..c66e1704398 100644 --- a/src/Framework/DataProviderTestSuite.php +++ b/src/Framework/DataProviderTestSuite.php @@ -26,6 +26,13 @@ final class DataProviderTestSuite extends TestSuite */ private $isLoaded = false; + public function __construct($theClass = '', $name = '') + { + parent::__construct($theClass, $name); + + $this->loadData(); + } + /** * @param string[] $dependencies */ @@ -59,7 +66,6 @@ public function injectFilter(Factory $filter): void { $this->iteratorFilter = $filter; -// print "%%% load() in injectFilter()\n"; $this->loadData(); } @@ -106,7 +112,7 @@ public function loadData(): void $message .= "\n" . $_message; } - $this->addTest(new IncompleteTestCase($message)); + $this->addTest(new IncompleteTestCase($className, $name, $message)); } catch (SkippedTestError $e) { $message = \sprintf( 'Test for %s::%s skipped by data provider', @@ -120,7 +126,7 @@ public function loadData(): void $message .= "\n" . $_message; } - $this->addTest(new SkippedTestCase($message)); + $this->addTest(new SkippedTestCase($className, $name, $message)); } catch (Exception $e) { $message = \sprintf( 'The data provider specified for %s::%s is invalid.', diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 54e9866a3e0..6178aa77f62 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -2210,4 +2210,15 @@ private function recordDoubledType($originalClassName): void } } } + + public function unloadData(): void + { + if (empty($this->data)) { + return; + } + + // MVP unloading: this needs a deeper look + $this->data = []; + $this->dataName = "__UNLOADED__"; + } } diff --git a/src/Framework/TestSuite.php b/src/Framework/TestSuite.php index 0545a1f6e92..9b5a31a3ade 100644 --- a/src/Framework/TestSuite.php +++ b/src/Framework/TestSuite.php @@ -658,6 +658,10 @@ public function run(TestResult $result = null): TestResult } $test->run($result); + + if ($test instanceof TestCase and $test->usesDataProvider()) { + $test->unloadData(); + } } try { @@ -710,6 +714,8 @@ public function testAt(int $index) /** * Returns the tests as an enumeration. + * + * @return TestCase[] */ public function tests(): array {