【发布时间】:2018-10-03 17:41:29
【问题描述】:
我们如何在 Laravel 单元测试中模拟 Stripe,而不使用像 stripe-mock 等任何外部包?
工作是测试控制器功能,其中密码是硬编码的,并且由于哪个测试失败。
【问题讨论】:
标签: laravel mocking stripe-payments
我们如何在 Laravel 单元测试中模拟 Stripe,而不使用像 stripe-mock 等任何外部包?
工作是测试控制器功能,其中密码是硬编码的,并且由于哪个测试失败。
【问题讨论】:
标签: laravel mocking stripe-payments
嘿,我遇到了同样的问题,
我正在使用来自codeception的aspectmock。设置它让我有些悲伤,但我现在能够用 json 响应模拟所有响应。这样,json 数据通过条带类并抛出正确的错误并返回相同的对象。
希望对您有所帮助
https://github.com/Codeception/AspectMock
public function testAll()
{
$customerClass = new StripeCustomers();
test::double('Stripe\HttpClient\CurlClient', ['request' => [json_encode($this->allJsonData), 200, []]]);
$customer = $customerClass->all();
$this->assertArrayHasKey('data', $customer);
}
【讨论】: