编程语言
首页 > 编程语言> > php – Laravel 5模拟PasswordBroker

php – Laravel 5模拟PasswordBroker

作者:互联网

从样板文件PasswordController :: postEmail()我试图模拟(使用Mockery)这部分:

// $this->password is an instance of PasswordBroker
$response = $this->passwords->sendResetLink($request->only('email'), function($m)
    {
        $m->subject($this->getEmailSubject());
    });

在我的测试用例中,我正在调用 – > shouldReceive(‘sendResetLink’) – > with($postData,???)

由于这是一个闭包,我确定我必须通过一个闭包,并且还要模拟$m->主题($this-> getEmailSubject());但我对这个问题一无所知,因为我对TDD比较陌生.

我可以获得一些指示吗?

解决方法:

->shouldReceive('sendResetLink')
->once()
->with($postData, \Mockery::type('Closure'));

标签:php,unit-testing,laravel,laravel-5,mockery
来源: https://codeday.me/bug/20190623/1274202.html