这是我的测试代码:
public function testTransceiverEntityCreate()
{
$transceiver_driver = Mockery::mock('Recoder\Drivers\TransceiverDriverInterface');
$transceiver_driver->shouldReceive('load');
$transceiver_utils = Mockery::mock('TransceiverUtils');
new Transceiver('1F2D03', $transceiver_utils, $transceiver_driver);
}
当我运行测试时,它返回以下错误:
1) TransceiverTest::testTransceiverEntityCreate
Argument 2 passed to Recoder\Entities\Transceiver::__construct() must be an instance of Recoder\TransceiverUtils, instance of Mockery_2__TransceiverUtils given, called in /var/www/solidoptics-recorder/private/application/libraries/Recoder/tests/Entities/TransceiverTest.php on line 35 and defined
为什么Mockery_2__TransceiverUtils?我会很高兴任何想法。感谢。
答案 0 :(得分:1)
当找不到类时会发生这种情况,所以Mockery完全嘲笑它而不是扩展它。该类必须已加载,或通过自动加载加载。