2
/**
* Call the given URI and return the Response.
*
* @param string $method
* @param string $uri
* @param array $parameters
* @param array $files
* @param array $server
* @param string $content
* @param bool $changeHistory
* @return \Illuminate\Http\Response
*/
public function call()
为了通过头,我在$server
参数,我做的,像这样将它们设置:
public function testCreateLocation(){
$response = $this->call('POST', '/api/v1/token', $this->test_token_request);
$tokenObject = json_decode($response->getContent());
/** Run the test */
$response = $this->call('POST', '/api/v1/location', $this->test_1_create_tag,
[], ['Authorization' => 'Bearer '.$tokenObject->token]);
/** Read the response */
$this->assertResponseOk();
}
然而,当我运行单元测试时,出现以下错误:
[email protected]:~/Code$ php phpunit.phar tests/LocationModelTest.php
PHPUnit 4.6.2 by Sebastian Bergmann and contributors.
Configuration read from /home/vagrant/Code/phpunit.xml.dist
EFF
Time: 3.75 seconds, Memory: 35.75Mb
There was 1 error:
1) LocationModelTest::testCreateLocation
InvalidArgumentException: An uploaded file must be an array or an instance of UploadedFile.
我试过在null
和一个空数组,因为它声明,但错误永远不会解决。有人有主意吗?
你在你的控制器/请求/其他方法使用的文件在启动?如果是的话,你应该显示他们的声明 –
@MarcinNabiałek没有,没有文件正在上传。此测试用于检索新的api JWT令牌,然后将其应用于任何后续api调用以测试身份验证。 – LokiSinclair