File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed
unit/Framework/MockObject Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+ /*
3+ * This file is part of PHPUnit.
4+ *
5+ * (c) Sebastian Bergmann <[email protected] > 6+ *
7+ * For the full copyright and license information, please view the LICENSE
8+ * file that was distributed with this source code.
9+ */
10+ namespace PHPUnit \TestFixture \MockObject ;
11+
12+ class ExtendableClassCallingMethodInDestructor
13+ {
14+ public function __destruct ()
15+ {
16+ $ this ->doSomethingElse ();
17+ }
18+
19+ public function doSomething (): static
20+ {
21+ return $ this ;
22+ }
23+
24+ public function doSomethingElse (): void
25+ {
26+ }
27+ }
Original file line number Diff line number Diff line change 2727use PHPUnit \Framework \MockObject \Generator \NameAlreadyInUseException ;
2828use PHPUnit \Framework \TestCase ;
2929use PHPUnit \TestFixture \MockObject \AbstractClass ;
30- use PHPUnit \TestFixture \MockObject \ExtendableClassCallingMethodInConstructor ;
3130use PHPUnit \TestFixture \MockObject \ExtendableClass ;
31+ use PHPUnit \TestFixture \MockObject \ExtendableClassCallingMethodInConstructor ;
3232use PHPUnit \TestFixture \MockObject \InterfaceWithReturnTypeDeclaration ;
3333use PHPUnit \TestFixture \MockObject \TraitWithConcreteAndAbstractMethod ;
3434
Original file line number Diff line number Diff line change 1313use PHPUnit \Framework \Attributes \IgnorePhpunitDeprecations ;
1414use PHPUnit \Framework \Attributes \RequiresPhp ;
1515use PHPUnit \Framework \Attributes \TestDox ;
16+ use PHPUnit \Framework \Attributes \Ticket ;
1617use PHPUnit \Framework \TestCase ;
18+ use PHPUnit \TestFixture \MockObject \ExtendableClassCallingMethodInDestructor ;
1719use PHPUnit \TestFixture \MockObject \ExtendableClassWithCloneMethod ;
1820use PHPUnit \TestFixture \MockObject \ExtendableReadonlyClassWithCloneMethod ;
1921use PHPUnit \TestFixture \MockObject \InterfaceWithMethodThatExpectsObject ;
@@ -293,6 +295,19 @@ public function testMethodNameCanOnlyBeConfiguredOnce(): void
293295 ->willReturn (true );
294296 }
295297
298+ #[Ticket('https://github.com/sebastianbergmann/phpunit/issues/5874 ' )]
299+ public function testDoubledMethodsCanBeCalledFromDestructorOnTestDoubleCreatedByTheReturnValueGenerator (): void
300+ {
301+ $ this ->markTestIncomplete ('https://github.com/sebastianbergmann/phpunit/issues/5874 ' );
302+
303+ $ double = $ this ->createTestDouble (ExtendableClassCallingMethodInDestructor::class);
304+
305+ $ this ->assertInstanceOf (
306+ ExtendableClassCallingMethodInDestructor::class,
307+ $ double ->doSomething (),
308+ );
309+ }
310+
296311 /**
297312 * @psalm-template RealInstanceType of object
298313 *
You can’t perform that action at this time.
0 commit comments