We are developing our projects in Laravel 4. One of our integration tests performs two consecutive HTTP requests to the same controller:
public function testFetchingPaginatedEntities() {
$response = $this->call('GET', "foos?page=1&page_size=1");
// assertions
$response = $this->call('GET', "foos");
// some more assertions
}
As you can see, the second request does not carry any query string parameters. However, we noticed that our controller was receiving page
and page_size
in both requests.
We were able to fix this by restarting the test client between calls (as explained in Laravel 4 controller tests - ErrorException after too many $this->call() - why? ):
public function testFetchingPaginatedEntities() {
$response = $this->call('GET', "foos?page=1&page_size=1");
// assertions
$this->client->restart();
$response = $this->call('GET', "foos");
// some more assertions
}
We are now considering porting our project to Laravel 5, but it looks like $this->client
is no longer available in tests since L5 no longer uses Illuminate\\Foundation\\Testing\\Client
.
Could anybody provide an alternative for resetting the test client? Or maybe a way to avoid restarting it at all?
$this->refreshApplication();
在电话之间解决了Laravel 5.4上的问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.