Skip to content

Commit 1a1069e

Browse files
committed
fixup! [phpunit 12] Add /ExpressionCreateMockToCreateStubRector
1 parent 9a9f3f4 commit 1a1069e

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Rector\PHPUnit\Tests\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector\Source\ClassWithDependency;
7+
8+
final class SkipMocking extends TestCase
9+
{
10+
public function test()
11+
{
12+
$mock = $this->createMock(\stdClass::class);
13+
$mock->expects($this->once())->method('someMethod')->willReturn('someValue');
14+
15+
$someObject = new ClassWithDependency($mock);
16+
$this->assertSame($mock, $someObject->getDependency());
17+
}
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Rector\PHPUnit\Tests\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector\Fixture;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Rector\PHPUnit\Tests\PHPUnit120\Rector\ClassMethod\ExpressionCreateMockToCreateStubRector\Source\ClassWithDependency;
7+
8+
final class SkipUsedOutsideArg extends TestCase
9+
{
10+
public function test()
11+
{
12+
$mock = $this->createMock(\stdClass::class);
13+
14+
if ($mock instanceof \stdClass) {
15+
// do something
16+
}
17+
18+
$someObject = new ClassWithDependency($mock);
19+
$this->assertSame($mock, $someObject->getDependency());
20+
}
21+
}

0 commit comments

Comments
 (0)