作者:yuyiyin乐悠悠_964 | 来源:互联网 | 2023-02-03 11:35
Imtryingtocreateamocktosatisfyatypehintwiththiscode(Mockery):我正在尝试创建一个mock,以满足这个代码的类型
I'm trying to create a mock to satisfy a typehint with this code (Mockery):
我正在尝试创建一个mock,以满足这个代码的类型提示(伪代码):
return \Mockery::mock('\Contracts\Helpers\iFileSystemWrapper');
or this (PHPUnit):
或者这个(PHPUnit)):
return $this->getMock('\Contracts\Helpers\iFileSystemWrapper');
But the mock returned is called Mockery\Mock Object
or Mock_iFileSystemWrapper_a5f91049
. How am I supposed to type check this when it isn't an instance of what I need at all with either framework?
但是返回的mock模拟对象或Mock_iFileSystemWrapper_a5f91049。当这两个框架都不是我所需要的实例时,我应该如何输入check this ?
Why exactly is the mock framework trying to load the real class? If I wanted the real class I would include the real class.
为什么模拟框架要加载真实的类?如果我想要真正的课程,我会包括真正的课程。
This problem has slowed me down so many times when writing tests I'm about to just toss type hinting out the window and check class names instead, or simply use production objects as mocks are a pain to use.
当我编写测试时,这个问题已经让我慢了很多次,我只需要在窗口中输入暗示,然后检查类名,或者简单地使用产品对象作为模拟是很痛苦的。
2 个解决方案