Skip to content

Commit f92ceb1

Browse files
Merge branch '10.5'
2 parents 19fbba4 + 41861f1 commit f92ceb1

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
interface AnInterfaceForIssue5593
13+
{
14+
public function doSomething(): AnotherInterfaceForIssue5593;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
interface AnotherInterfaceForIssue5593
13+
{
14+
public function doSomethingElse(): static;
15+
}

tests/unit/Framework/MockObject/ReturnValueGeneratorTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
use PHPUnit\Framework\Attributes\Group;
1919
use PHPUnit\Framework\Attributes\Small;
2020
use PHPUnit\Framework\Attributes\TestDox;
21+
use PHPUnit\Framework\Attributes\Ticket;
2122
use PHPUnit\Framework\TestCase;
2223
use PHPUnit\TestFixture\MockObject\AnInterface;
24+
use PHPUnit\TestFixture\MockObject\AnInterfaceForIssue5593;
2325
use PHPUnit\TestFixture\MockObject\AnotherInterface;
26+
use PHPUnit\TestFixture\MockObject\AnotherInterfaceForIssue5593;
2427
use PHPUnit\TestFixture\MockObject\YetAnotherInterface;
2528
use stdClass;
2629

@@ -162,6 +165,22 @@ public function test_Generates_new_instance_of_test_stub_for_static(): void
162165
$this->assertInstanceOf($stubClassName, $this->generate('static', $stubClassName));
163166
}
164167

168+
#[Ticket('https://github.com/sebastianbergmann/phpunit/issues/5593')]
169+
public function test_Generates_new_instance_of_test_stub_for_static_when_used_recursively(): void
170+
{
171+
$a = $this->createStub(AnInterfaceForIssue5593::class);
172+
173+
$this->assertInstanceOf(AnInterfaceForIssue5593::class, $a);
174+
175+
$b = $a->doSomething();
176+
177+
$this->assertInstanceOf(AnotherInterfaceForIssue5593::class, $b);
178+
179+
$c = $b->doSomethingElse();
180+
181+
$this->assertInstanceOf(AnotherInterfaceForIssue5593::class, $c);
182+
}
183+
165184
#[DataProvider('unionProvider')]
166185
#[TestDox('Generates $expected for $union')]
167186
public function test_Generates_return_value_for_union(mixed $expected, string $union): void

0 commit comments

Comments
 (0)