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 27
27
use PHPUnit \Framework \MockObject \Generator \NameAlreadyInUseException ;
28
28
use PHPUnit \Framework \TestCase ;
29
29
use PHPUnit \TestFixture \MockObject \AbstractClass ;
30
- use PHPUnit \TestFixture \MockObject \ExtendableClassCallingMethodInConstructor ;
31
30
use PHPUnit \TestFixture \MockObject \ExtendableClass ;
31
+ use PHPUnit \TestFixture \MockObject \ExtendableClassCallingMethodInConstructor ;
32
32
use PHPUnit \TestFixture \MockObject \InterfaceWithReturnTypeDeclaration ;
33
33
use PHPUnit \TestFixture \MockObject \TraitWithConcreteAndAbstractMethod ;
34
34
Original file line number Diff line number Diff line change 13
13
use PHPUnit \Framework \Attributes \IgnorePhpunitDeprecations ;
14
14
use PHPUnit \Framework \Attributes \RequiresPhp ;
15
15
use PHPUnit \Framework \Attributes \TestDox ;
16
+ use PHPUnit \Framework \Attributes \Ticket ;
16
17
use PHPUnit \Framework \TestCase ;
18
+ use PHPUnit \TestFixture \MockObject \ExtendableClassCallingMethodInDestructor ;
17
19
use PHPUnit \TestFixture \MockObject \ExtendableClassWithCloneMethod ;
18
20
use PHPUnit \TestFixture \MockObject \ExtendableReadonlyClassWithCloneMethod ;
19
21
use PHPUnit \TestFixture \MockObject \InterfaceWithMethodThatExpectsObject ;
@@ -293,6 +295,19 @@ public function testMethodNameCanOnlyBeConfiguredOnce(): void
293
295
->willReturn (true );
294
296
}
295
297
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
+
296
311
/**
297
312
* @psalm-template RealInstanceType of object
298
313
*
You can’t perform that action at this time.
0 commit comments