【问题标题】:Mockery method shouldRecieve() is not found on this mock object [closed]在此模拟对象上找不到模拟方法 shouldRecieve() [关闭]
【发布时间】:2013-03-02 17:09:38
【问题描述】:

我正在使用带有 Laravel 和 PHPunit 的 padraic/mockery 包。我在 PHP 5.4.3 上。

当尝试创建一个模拟对象来测试控制器时,我收到一个错误:

"BadMethodCallException: Method ... shouldRecieve() is not found on this mock object"

我的代码在下面,我非常关注教程,但无法弄清楚为什么我的模拟对象似乎没有正确实例化。

public function testItWorks()
{
    $mocked = m::mock('SearchRepositoryInterface');
    App::instance('SearchRepositoryInterface', $mocked);

    $mocked->shouldRecieve('test')->once()->andReturn('NOT hitting the db');
    $response = $this->call('GET', 'search');

    $this->assertTrue($response->isOK());
}

【问题讨论】:

    标签: php laravel phpunit laravel-4 mockery


    【解决方案1】:

    你有一个错字。 它是shouldReceive 而不是shouldRecieve

    【讨论】:

    • 该死!我花了几个小时试图弄清楚这里发生了什么。我差点放弃嘲讽!它总是很小的东西......不过,谢谢,好地方!
    • i 在 e 之前,c 之后除外
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-13
    • 1970-01-01
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 2019-08-13
    • 1970-01-01
    相关资源
    最近更新 更多