有没有办法在功能测试中使用铸造模型进行身份验证?
1) App\Tests\Controller\Admin\Api\Promotion\PromotionDeleteControllerTest::test_deleting_promotion
LogicException: The first argument of "Symfony\Bundle\FrameworkBundle\KernelBrowser::loginUser" must be instance of "Symfony\Component\Security\Core\User\UserInterface", "Zenstruck\Foundry\Proxy" provided.
我正在使用phpunit库编写功能测试。我想创建用于使用AdminFactory测试的管理对象(扩展铸造Modelfactory),然后使用带有内置的Symfony方法使用给定对象对我的API请求进行身份验证
$this->client->loginUser($admin, 'admin');
?
1) App\Tests\Controller\Admin\Api\Promotion\PromotionDeleteControllerTest::test_deleting_promotion
LogicException: The first argument of "Symfony\Bundle\FrameworkBundle\KernelBrowser::loginUser" must be instance of "Symfony\Component\Security\Core\User\UserInterface", "Zenstruck\Foundry\Proxy" provided.
I am writing functional test with phpunit library. I want to create admin object for testing with AdminFactory (extends Foundry ModelFactory) and then authenticate my API request using given object with built in Symfony method
$this->client->loginUser($admin, 'admin');
How can I make it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我自己找到了一个解决方案。您必须做这样的事情:
这应该返回实体而不是铸造代理
Okay, I've found a solution myself. You have to do something like this:
This should return Entity instead of Foundry Proxy
只需要求实际对象:
请参阅 zenstruckfundryrybundrybundrybundrybundly文档。
Just ask for the actual object:
See ZenstruckFoundryBundle Documentation.