Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Codeception中使用SubmitForm()附加文件_Php_Codeception - Fatal编程技术网

Php 如何在Codeception中使用SubmitForm()附加文件

Php 如何在Codeception中使用SubmitForm()附加文件,php,codeception,Php,Codeception,我正在通过SubmitForm()函数测试表单,因为表单使用javascript循环遍历每个单独的项 示例: $I->submitForm('#form', array( 'feet' => '1', 'inches' => '2', ), 'submit'); 这工作正常,但我有一个文件上传输入问题 $I->submitForm('#form', array( 'feet' => '1', 'inches' => '2',

我正在通过
SubmitForm()
函数测试表单,因为表单使用javascript循环遍历每个单独的项

示例:

$I->submitForm('#form', array(
    'feet' => '1',
    'inches' => '2',

), 'submit');
这工作正常,但我有一个文件上传输入问题

$I->submitForm('#form', array(
    'feet' => '1',
    'inches' => '2',
    'file' => ???

 ), 'submit');

我尝试发送一个数组来模拟
$\u文件
数组,但这显然不是正确的方法。这可能吗?

我也遇到过这个问题,我唯一能看到的方法是手动填写字段并单击提交按钮

比如说

$I->fillField(['name' => 'name'], 'Test');
$I->attachFile('input[name=photo]', 'test.jpg');
$I->click('#formId button[type=submit]');
$I->seeCurrentRouteIs('route.index');
$I->see('Model has been updated.');
您可以将任何测试文件存储在Codeception tests/\u数据文件夹中


这确实有效,但遗憾的是,在我目前的情况下,这对我没有帮助,因为我有一个表单,可以动态填充各种选择元素,所以我需要
提交表单
,因为我不能手动
选择选项
,因为这些选项是根据其他表单的完成情况填充的。

我也遇到了这个问题,这是我能看到的唯一方法要手动填写字段,请单击“提交”按钮

比如说

$I->fillField(['name' => 'name'], 'Test');
$I->attachFile('input[name=photo]', 'test.jpg');
$I->click('#formId button[type=submit]');
$I->seeCurrentRouteIs('route.index');
$I->see('Model has been updated.');
您可以将任何测试文件存储在Codeception tests/\u数据文件夹中

这确实有效,但遗憾的是,这对我目前的处境没有帮助,因为我有一个表单,可以动态填充各种选择元素,所以我需要
submitForm
,因为我无法手动
selectOption
,因为这些选项是根据其他表单完成情况填充的