From c4ccbf6978839f4113e9ecf6c9ad645429cb4301 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Tue, 26 Nov 2024 14:36:09 +0100 Subject: [PATCH] Add test --- .../ExpectedAndUnexpectedAssertionsTest.php | 39 +++++++++++++++ .../expected-and-unexpected-assertions.phpt | 47 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 tests/end-to-end/event/_files/ExpectedAndUnexpectedAssertionsTest.php create mode 100644 tests/end-to-end/event/expected-and-unexpected-assertions.phpt diff --git a/tests/end-to-end/event/_files/ExpectedAndUnexpectedAssertionsTest.php b/tests/end-to-end/event/_files/ExpectedAndUnexpectedAssertionsTest.php new file mode 100644 index 0000000000..06118eb390 --- /dev/null +++ b/tests/end-to-end/event/_files/ExpectedAndUnexpectedAssertionsTest.php @@ -0,0 +1,39 @@ + + * + * 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\Attributes\DoesNotPerformAssertions; +use PHPUnit\Framework\TestCase; + +final class ExpectedAndUnexpectedAssertionsTest extends TestCase +{ + #[DoesNotPerformAssertions] + public function testOne(): void + { + } + + public function testTwo(): void + { + $this->expectNotToPerformAssertions(); + } + + #[DoesNotPerformAssertions] + public function testThree(): void + { + $this->assertTrue(true); + } + + public function testFour(): void + { + $this->expectNotToPerformAssertions(); + + $this->assertTrue(true); + } +} diff --git a/tests/end-to-end/event/expected-and-unexpected-assertions.phpt b/tests/end-to-end/event/expected-and-unexpected-assertions.phpt new file mode 100644 index 0000000000..7342748311 --- /dev/null +++ b/tests/end-to-end/event/expected-and-unexpected-assertions.phpt @@ -0,0 +1,47 @@ +--TEST-- +The right events are emitted in the right order when a test that is not expected to perform assertions does not perform assertions and when a test that is not expected to perform assertions does perform assertions +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit Started (PHPUnit %s using %s) +Test Runner Configured +Test Suite Loaded (4 tests) +Event Facade Sealed +Test Runner Started +Test Suite Sorted +Test Runner Execution Started (4 tests) +Test Suite Started (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest, 4 tests) +Test Preparation Started (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testOne) +Test Prepared (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testOne) +Test Passed (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testOne) +Test Finished (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testOne) +Test Preparation Started (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testTwo) +Test Prepared (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testTwo) +Test Passed (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testTwo) +Test Finished (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testTwo) +Test Preparation Started (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testThree) +Test Prepared (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testThree) +Assertion Succeeded (Constraint: is true, Value: true) +Test Passed (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testThree) +Test Considered Risky (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testThree) +This test is not expected to perform assertions but performed 1 assertion +Test Finished (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testThree) +Test Preparation Started (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testFour) +Test Prepared (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testFour) +Assertion Succeeded (Constraint: is true, Value: true) +Test Passed (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testFour) +Test Considered Risky (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testFour) +This test is not expected to perform assertions but performed 1 assertion +Test Finished (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest::testFour) +Test Suite Finished (PHPUnit\TestFixture\Event\ExpectedAndUnexpectedAssertionsTest, 4 tests) +Test Runner Execution Finished +Test Runner Finished +PHPUnit Finished (Shell Exit Code: 0)