首页 > 解决方案 > Mockery\Exception\NoMatchingExpectationException:没有为 Mockery_1_::make 找到匹配的处理程序

问题描述

我编写了这个返回以下错误的测试:

Mockery\Exception\NoMatchingExpectationException:没有为 Mockery_1_My_Class::make(array('valid_until'=>'2020-03-04',)) 找到匹配的处理程序。该方法是意外的,或者它的参数与该方法的预期参数列表不匹配

现在我的测试中有这段代码:

$rateValidator->shouldReceive('make')->once()
            ->withArgs([$attributes])->andReturn(mockery::self());

$rateValidator->shouldReceive('addContext')
            ->withArgs(['update_rate_validity'])->andReturn(mockery::self());

这是这个测试正在测试的代码:

$attributes = [
    'valid_until' => $command->validUntilDate
];

$validator = $this->rateValidator->make($attributes)->addContext('update_rate_validity');

我在这里做错了什么?对我来说,唯一的问题可能是该方法正在接收的arguments( ),但我不知道那可能是什么?$attributesmake

标签: phpunit-testinglaravel-5phpunit

解决方案


推荐阅读