Codeception - 通过REST sendPost发送文件

first of all, I am almost completely new to programming and completely new to codeception and PHP.

I'm wondering if anyone could help me with how I use codeception to send a file using the sendPost method in the REST module http://codeception.com/docs/modules/REST#sendPOST .

The help file describes sending it via an array but honestly can't figure it out.

The most sensible way I can come up with is the following

$I->sendPost(array("filename"))

Like I said, completely new at this.

The file is located in the directory that Codeception has been installed hence why I didn't think I needed to specify it's location. I'm also aware of how to send a Post without an attached file, just not one with an attached file.

I hope that's enough information.

Apologies if it isn't.

I would put the file into the tests/_data directory, and then get the path to it using codecept_data_dir:

$I->sendPOST('/my-endpoint', ['field' => 'value'], [ 'someFile' => codecept_data_dir('file.png')]);

I tried the approach suggested by Jesper Jonsson, but it didn't work for me. After browsing the source code of Codeception framework, I worked out another solution described in my answer here. Briefly, you should put a mock of $_FILES array as the third argument to sendPOST().