From cda644ee532b2926d77aac92d034e8f758a41666 Mon Sep 17 00:00:00 2001 From: Marcin Michalski Date: Sat, 25 Mar 2023 20:02:02 +0000 Subject: [PATCH] Fail run with invalid data providers --- ...alidDataProviderWithOneTestPassingTest.php | 33 +++++++++++++ ...valid-data-provider-with-passing-test.phpt | 47 +++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 tests/end-to-end/event/_files/InvalidDataProviderWithOneTestPassingTest.php create mode 100644 tests/end-to-end/event/invalid-data-provider-with-passing-test.phpt diff --git a/tests/end-to-end/event/_files/InvalidDataProviderWithOneTestPassingTest.php b/tests/end-to-end/event/_files/InvalidDataProviderWithOneTestPassingTest.php new file mode 100644 index 00000000000..66b7c62f8b8 --- /dev/null +++ b/tests/end-to-end/event/_files/InvalidDataProviderWithOneTestPassingTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\Event; + +use PHPUnit\Framework\TestCase; + +final class InvalidDataProviderWithOneTestPassingTest extends TestCase +{ + public static function provider(): array + { + return [0]; + } + + /** + * @dataProvider provider + */ + public function testOne(): void + { + $this->assertTrue(true); + } + + public function testTwo(): void + { + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/event/invalid-data-provider-with-passing-test.phpt b/tests/end-to-end/event/invalid-data-provider-with-passing-test.phpt new file mode 100644 index 00000000000..ea4f3397988 --- /dev/null +++ b/tests/end-to-end/event/invalid-data-provider-with-passing-test.phpt @@ -0,0 +1,47 @@ +--TEST-- +The right events are emitted in the right order for a test that uses a data provider that returns an invalid array +--SKIPIF-- +run($_SERVER['argv']); + +print file_get_contents($traceFile); + +unlink($traceFile); +--EXPECTF-- +PHPUnit Started (PHPUnit %s using %s) +Test Runner Configured +Test Triggered PHPUnit Error (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest::testOne) +The data provider specified for PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest::testOne is invalid +Data set #0 is invalid + +Test Suite Loaded (1 test) +Event Facade Sealed +Test Runner Started +Test Suite Sorted +Test Runner Execution Started (1 test) +Test Suite Started (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest, 1 test) +Test Preparation Started (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest::testTwo) +Test Prepared (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest::testTwo) +Assertion Succeeded (Constraint: is true, Value: true) +Test Passed (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest::testTwo) +Test Finished (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest::testTwo) +Test Suite Finished (PHPUnit\TestFixture\Event\InvalidDataProviderWithOneTestPassingTest, 1 test) +Test Runner Execution Finished +Test Runner Finished +PHPUnit Finished (Shell Exit Code: 1)