That error is probably being thrown from somewhere else - check the stack trace and post the full error here.
Dec 7, 2016
2
Level 1
Error when using json() method in test
I have been testing an application I am developing and up until today all of my tests were working fine.
Now when I try to run tests I am getting an error: ErrorException: substr() expects parameter 1 to be string, array given that is being produced from the json() method.
/** @test */
public function admin_can_remove_facebook_ad_account_from_campaign()
{
$facebookAd = factory(App\FacebookAd::class)->make();
$this->campaign->facebookAds()->save($facebookAd);
$this->actingAs($this->admin, 'admin')
->json('DELETE', 'facebookAd/' . $facebookAd->id);
$this->assertNull(App\FacebookAd::find($facebookAd->id));
}
Any ideas as to why the substr() method thinks the string 'DELETE' is an array?
Level 1
Well I figured out what the issue was. I had added a custom variable to the .env file and made it available app wide by creating an alias in the config/app.php file to env variables. A syntax error was causing the error and the stack trace did not make it clear what code was throwing the exception.
1 like
Please or to participate in this conversation.