php - Laravel - Functional Testing: current route is not get cleared -
we using laravel version 5.0, perhaps issue apply laravel 5.0+ too.
in functional tests if call paths, router finds matching routes, if call 404 url, router not resets current route:
public function testpages() { $response = $this->call('get', '/about'); $this->assertequals(200, $response->getstatuscode()); // \route::current() not null // call 404-route $response = $this->call('get', '/asdfasdfasdf'); $this->assertequals(404, $response->getstatuscode()); }
when handling 404 call \route::current()
in view composers, , running tests not null
, running in browser null
.
how reset laravel state initial between $this->call()
s?
my current solution add $this->refreshapplication()
before each of $this->call()
:
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null) { $this->refreshapplication(); if (0 !== strpos($uri, 'http://') && 0 !== strpos($uri, 'https://')) { $uri = env('app_url') . $uri; } return parent::call($method, $uri, $parameters, $cookies, $files, $server, $content); }
Comments
Post a Comment