Skip to content

Commit 08107a5

Browse files
committed
[CodeQuality] Handle on static closure on WithCallbackIdenticalToStandaloneAssertsRector
1 parent 501420d commit 08107a5

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\WithCallbackIdenticalToStandaloneAssertsRector\Fixture;
6+
7+
use PHPUnit\Framework\TestCase;
8+
9+
final class OnStaticClosure extends TestCase
10+
{
11+
public function test()
12+
{
13+
$this->createMock('SomeClass')
14+
->expects($this->once())
15+
->method('someMethod')
16+
->with($this->callback(static function (array $args): bool {
17+
return count($args) === 2 && $args[0] === 'correct';
18+
}));
19+
}
20+
}
21+
22+
?>
23+
-----
24+
<?php
25+
26+
declare(strict_types=1);
27+
28+
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\WithCallbackIdenticalToStandaloneAssertsRector\Fixture;
29+
30+
use PHPUnit\Framework\TestCase;
31+
32+
final class OnStaticClosure extends TestCase
33+
{
34+
public function test()
35+
{
36+
$this->createMock('SomeClass')
37+
->expects($this->once())
38+
->method('someMethod')
39+
->with($this->callback(static function (array $args): bool {
40+
self::assertCount(2, $args);
41+
self::assertSame('correct', $args[0]);
42+
return true;
43+
}));
44+
}
45+
}
46+
47+
?>

0 commit comments

Comments
 (0)