【问题标题】:What I doing wrong with Mockery我对嘲弄做错了什么
【发布时间】:2014-06-17 15:30:33
【问题描述】:

这是我的测试代码:

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?我会很高兴有任何想法。谢谢。

【问题讨论】:

    标签: php unit-testing phpunit mockery


    【解决方案1】:

    当找不到类时会发生这种情况,因此 Mockery 完全模拟它而不是扩展它。该类必须已经加载,或者可以通过自动加载加载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-07
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      相关资源
      最近更新 更多