I am trying to run a phpunit test on one of my controllers. I am using a function provided by the laravel frame work called action() and am consistently getting a 1) ListTest::testCreateList ErrorException: Array to string conversion. I have been stuck on this for hours and have NO idea why this would be happening.
1) ListTest::testCreateList ErrorException: Array to string conversion
ConsoleOutput
/Users/jacobshafi/Desktop/Code/api/vendor/laravel/framework/src/Illuminate/Support/helpers.php:686
/Users/jacobshafi/Desktop/Code/api/bootstrap/compiled.php:3976
/Users/jacobshafi/Desktop/Code/api/bootstrap/compiled.php:3966
/Users/jacobshafi/Desktop/Code/api/bootstrap/compiled.php:3959
/Users/jacobshafi/Desktop/Code/api/bootstrap/compiled.php:4043
/Users/jacobshafi/Desktop/Code/api/vendor/laravel/framework/src/Illuminate/Foundation/Testing/ApplicationTrait.php:90
/Users/jacobshafi/Desktop/Code/api/app/tests/ListControllerTest.php:58
ApplicationTrait.php (the action method that is being called in the controller)
public function action($method, $action, $wildcards = array(), $parameters = array(), $files = array(), $server = array(), $content = null, $changeHistory = true)
{
$uri = $this->app['url']->action($action, $wildcards, true);
return $this->call($method, $uri, $parameters, $files, $server, $content, $changeHistory);
}
ListController.php
class ListController extends BaseController
{
public function postCreate()
{
some code...
}
ListControllerTest.php
class ListTest extends TestCase {
public function testCreateList()
{
$response = $this->action(
'POST',
'App\Controllers\v2\ListController@postCreate',
[
'body' => array(
"name" => "open,shared",
"users" => array(array("user_id" => $user_id)),
"visibility" => "2",
"joinability" => "2",
"adminship" => "1",
"color" => "#2bc069"
),
'headers' => array('Auth' => getTestAuthSender())
]
);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire