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