-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
Hello guys. I have a controller called UserController. And i have a UserService that call getById method that returns some object. How can i mock this call when i test UserController?
I tries this code
` /** @var \Hyperf\Di\Container $c */
$c = \Hyperf\Utils\ApplicationContext::getContainer();
$queryServiceMock = $this->createMock(QueryService::class);
$queryServiceMock->method('appByKeyAndDomain')->willReturn((object)[
'id' => 1,
'key' => 'test',
'timezone' => 'UTC'
]);
$c->set(QueryService::class, $queryServiceMock);
\Hyperf\Utils\ApplicationContext::setContainer($c);`
but it would not work.
Metadata
Metadata
Assignees
Labels
No labels