[Catalyst] Test::WWW::Mechanize::Catalyst and
Catalyst::Controller::HTML::FormFu
Ash Berlin
ash_cpan at firemirror.com
Mon Jun 22 20:50:00 GMT 2009
On 22 Jun 2009, at 19:50, Kiffin Gish wrote:
> I'm using Test::WWW::Mechanize::Catalyst to test my Catalyst App, more
> specifically the process for registering new user accounts.
>
> The application form is generated by
> Catalyst::Controller::HTML::FormFu
> with the expected fields: username, password, confirm_password, email
> and the submit => 'Register' button (indicator).
>
> When using the good ol' browser the form is submitted and an email
> sent
> for validation, no problem.
>
> However, making the exact same call with
> Test::WWW::Mechanize::Catalyst
> as follows:
>
> my $fields = {
> username => $username,
> password => $password,
> confirm_password => $password,
> password_hint => $password_hint,
> email => $email,
> submit => 'Register'
> };
>
> $mech->submit_form(
> form_number => 0,
> fields => $fields,
> );
>
> will not work because within the sub register : Global FormConfig of
> my
> controller, $form->submitted_and_valid is returning false for some
> weird
> reason.
>
> I tried debugging the HTML::FormFu stuff but this is all very
> complicated.
>
> Can anyone help me here?
I'm guessing HTML::FormFu determines that the form is submitted by the
value of the input from the submit button (rather that it just being a
post request which is my personal preference)
To get WWW::Mechanize to send this value do, call
$mech->submit_form(
with_fields => $fields,
button => 'submit' # or what ever the name attr of the submit
button is.
);
More information about the Catalyst
mailing list