如何在测试中设置
$this->getUser();
我尝试这样做:
$token = $this->getMockBuilder(Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface::class)
->disableOriginalConstructor()
->setMethods(['getUser'])
->getMock();
$token->expects($this->any())
->method('getUser')
->willReturn($user);
$service = $this->getMockBuilder('Symfony\Component\Security\Core\SecurityContextInterface')
->disableOriginalConstructor()
->getMock();
$service->expects($this->any())
->method('getToken')
->willReturn($token);
$client4->getContainer()
->set('security.token_storage', $token);
我试试谷歌,但没有任何帮助我...