minkphp / MinkGoutteDriver

Goutte driver for Mink framework
MIT License
299 stars 52 forks source link

Submitting a form with empty action and base href #50

Closed wouterj closed 10 years ago

wouterj commented 10 years ago

I'm using ~1.0 of this driver and I try to submit a form with an empty action. The form should be posted to its own file, but for some reason the href value of the <base> element is taken instead. This means all my tests fail :(

To replicate this issue:

http://localhost/some/form.phtml

<!doctype html>

<base href="http://localhost/">

<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  echo 'Whoa!';
}
?>

<form action="#" method="POST">
  <input type="submit" value="submit">
</form>

formtest.php

<?php

require 'vendor/autoload.php';

use Behat\Mink\Mink,
    Behat\Mink\Session,
    Behat\Mink\Driver\GoutteDriver,
    Behat\Mink\Driver\Goutte\Client as GoutteClient;

$mink = new Mink(array(
    'goutte' => new Session(new GoutteDriver(new GoutteClient())),
));

$session = $mink->getSession('goutte');
$session->visit('http://localhost/some/form.phtml');
$btn = $session->getPage()->findButton('submit');
$btn->click();

echo $session->getCurrentUrl(); // returns 'http://localhost#' should be 'http://localhost/some/form.phtml#'
stof commented 10 years ago

This looks like an issue in BrowserKit here. Can you try to run the same kind of form submission in a BrowserKit testcase to verify it ?

Also, what is the version of the Symfony component that you use currently ?

wouterj commented 10 years ago

@stof how could I do this with a browserkit test case, I do need some sort of Client implementation, don't I?

I'm using 2.5.5

wouterj commented 10 years ago

Hmm, tried it with the DomCrawler and it indeed gave me the wrong URL. I'll reopen this issue in the symfony repo

wouterj commented 10 years ago

see https://github.com/symfony/symfony/issues/12143