From 973a49ff01f2b4041d44a7aa40582f97fb55d335 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 9 Jan 2025 08:31:44 +0100 Subject: [PATCH] Add test for #6095 --- tests/end-to-end/regression/6095.phpt | 31 +++++++++++++++++++ .../regression/6095/Issue6095Test.php | 28 +++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/end-to-end/regression/6095.phpt create mode 100644 tests/end-to-end/regression/6095/Issue6095Test.php diff --git a/tests/end-to-end/regression/6095.phpt b/tests/end-to-end/regression/6095.phpt new file mode 100644 index 00000000000..f59f5cb4a90 --- /dev/null +++ b/tests/end-to-end/regression/6095.phpt @@ -0,0 +1,31 @@ +--TEST-- +https://github.com/sebastianbergmann/phpunit/issues/6095 +--XFAIL-- +https://github.com/sebastianbergmann/phpunit/issues/6095 +--FILE-- +run($_SERVER['argv']); +--EXPECTF-- +PHPUnit %s by Sebastian Bergmann and contributors. + +Runtime: %s + +F 1 / 1 (100%) + +Time: %s, Memory: %s + +There was 1 failure: + +1) PHPUnit\TestFixture\Issue6095\Issue6095Test::testOne +PHPUnit\TestFixture\MockObject\AnInterface::doSomething() was not expected to be called more than once. + +%sIssue6095Test.php:26 + +FAILURES! +Tests: 1, Assertions: 1, Failures: 1. diff --git a/tests/end-to-end/regression/6095/Issue6095Test.php b/tests/end-to-end/regression/6095/Issue6095Test.php new file mode 100644 index 00000000000..9c737beaca1 --- /dev/null +++ b/tests/end-to-end/regression/6095/Issue6095Test.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TestFixture\Issue6095; + +use PHPUnit\Framework\TestCase; +use PHPUnit\TestFixture\MockObject\AnInterface; + +final class Issue6095Test extends TestCase +{ + public function testOne(): void + { + $mock = $this->createMock(AnInterface::class); + + $mock + ->expects($this->once()) + ->method('doSomething'); + + $mock->doSomething(); + $mock->doSomething(); + } +}