Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the "BrowserTestCase::prepareUrl" convinience method #52

Open
aik099 opened this issue Apr 7, 2015 · 2 comments
Open

Add the "BrowserTestCase::prepareUrl" convinience method #52

aik099 opened this issue Apr 7, 2015 · 2 comments

Comments

@aik099
Copy link
Member

aik099 commented Apr 7, 2015

I've had an interesting use case reported in #51 today: the value of baseUrl setting in browser configuration isn't applied when $this->getSession()->visit('/some/relative/path') call is made.

The person was most likely working with Behat/MinkExtension before and expected similar to happen here as well. Of course this won't work in this library due absence of Gherkin or similar language that later would be transformed into actual PHP code. Here PHP code is written directly.

If there a need, then maybe the prepareUrl($url) protected method needs to be added to the test case class, that would:

  • parse given url
  • if it's a relative url, then prepend value from baseUrl setting in browser configuration
  • if it's an absolute url, then return as is

We can actually take these methods from MinkExtension itself.


I'm not sure if this is feature, that will be widely adopted among library users though.

@stof
Copy link
Member

stof commented Apr 7, 2015

Note that $this->getSession()->visit('/some/relative/path') does not apply the base path either in MinkExtension. There is 2 ways to have the base path applied:

// MinkExtension 1.x or 2.x:
$this->getSession()->visit($this->locatePath('/some/relative/path'));

// MinkExtension 2.x shortcut (using the code above internally)
$this->visit('/some/relative/path');

@aik099
Copy link
Member Author

aik099 commented Apr 7, 2015

Yes, separate visit method, that would translate relative paths was my 2nd idea, but I wasn't sure if that won't create any more confusion knowing that $this->getSession() provides direct session access.

@parhamdoustdar, if you would like, then you can send PR for that feature (described above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants