带有数组名称输入的Laravel单元测试 [英] Laravel unit test with input with array name
本文介绍了带有数组名称输入的Laravel单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要填写的输入内容:
<input type="text" id="order-number" name="order_numbers[]" class="form-control">
我的单元测试代码:
public function testSearch()
{
$this->actAsUser();
$this->visit('/orders')
->type('12001546', 'order_numbers[]');
}
我得到的错误:
1) OrdersTest::testSearch
InvalidArgumentException: Unreachable field ""
推荐答案
我遇到了同样的问题,找不到比
I had the same problem, couldn't find a better solution than
// TestCase.php
protected function storeArrayInput($values, $name)
{
$this->inputs[$name] = $values;
return $this;
}
// YourTest.php
public function testSearch()
{
$this->actAsUser();
$this->visit('/orders')
->storeArrayInput(['12001546'], 'order_numbers');
}
这篇关于带有数组名称输入的Laravel单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文