Skip to content

Conversation

@TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Oct 31, 2025

 use PHPUnit\Framework\TestCase;

 final class SomeTest extends TestCase
 {
     public function test()
     {
         $this->createMock('SomeClass')
             ->expects($this->once())
             ->method('someMethod')
-            ->with($this->callback(function (array $args): bool {
-                return true;
-            }))
-            ->willReturn(['some item']);
+            ->willReturnCallback(function (array $args): array {
+                return ['some item'];
+            });
     }
 }

@TomasVotruba TomasVotruba merged commit 8488dcc into main Oct 31, 2025
6 checks passed
@TomasVotruba TomasVotruba deleted the tv-with-callback-will-return-merger branch October 31, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants