php - Unit testing in Laravel5 - Error -


according to:

/**  * call given uri , return 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() 

in order pass headers, set them in $server parameter, i'm doing so:

public function testcreatelocation(){   $response = $this->call('post', '/api/v1/token', $this->test_token_request);   $tokenobject = json_decode($response->getcontent());    /** run test */   $response = $this->call('post', '/api/v1/location', $this->test_1_create_tag,     [], ['authorization' => 'bearer '.$tokenobject->token]);    /** read response */   $this->assertresponseok(); } 

however, when run unit test, following error:

vagrant@homestead:~/code$ php phpunit.phar tests/locationmodeltest.php phpunit 4.6.2 sebastian bergmann , contributors.  configuration read /home/vagrant/code/phpunit.xml.dist  eff  time: 3.75 seconds, memory: 35.75mb  there 1 error:  1) locationmodeltest::testcreatelocation invalidargumentexception: uploaded file must array or instance of uploadedfile. 

i've tried passing in null , empty array states, error never resolved. have ideas?

i ran problem on laravel 5.1 well. once checked date documentation on call() method saw issue though:

call(string $method, string $uri, array $parameters = array(), **array $cookies = array(),** array $files = array(), array $server = array(), string $content = null) 

somewhere along way parameter (cookies) got added method.

so add empty array , should good:

$response = $this->call('post', '/api/v1/location', $this->test_1_create_tag, [], [], ['authorization' => 'bearer '.$tokenobject->token]); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -