Search code examples
phplaravellaravel-5.3

Laravel 5.3 has the testing method onPage been removed?


I'm following through a video series on Laracasts to help me understand how to run tests in Laravel.

The test described is:

$this->visit('/')
     ->type('some query', '#term')
     ->press('Search')
     ->see('Search results for "some query"')
     ->onPage('search-results');

However Laravel complains that onPage is not a valid method. I've looked through the docs but can't seem to find a change which best describes what alternative method to use.

I tried to do:

$this->visit('/')
     ->type('some query', '#term')
     ->press('Search')
     ->visit('/search-results')
     ->see('Search results for "some query"');

But it seems that the behaviour of that is to redirect to /search-results before the form submits, meaning the output message is not the same and the assertion fails.


Solution

  • You can use seePageIs method.

    Source code

    Assert that the current page matches a given URI.

    You can see more tips at the docs.