diff options
author | Struan Donald <struan@exo.org.uk> | 2011-05-13 16:36:13 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-05-13 16:36:13 +0100 |
commit | fbb8d5ca4e3bfecf5c276f4a8dd43fb5fc4002d9 (patch) | |
tree | e0d50673d0f564bce7c5a937a193ac1afedbd01f /t/app/controller/contact.t | |
parent | 84053fd846af39f03c8e6087e9f1df41dffe62ff (diff) |
contact form validation and post submission page
Diffstat (limited to 't/app/controller/contact.t')
-rw-r--r-- | t/app/controller/contact.t | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 412b834f3..a5135c60a 100644 --- a/t/app/controller/contact.t +++ b/t/app/controller/contact.t @@ -69,4 +69,80 @@ for my $test ( }; } +for my $test ( + { + fields => { + em => ' ', + name => '', + subject => '', + message => '', + }, + errors => [ + 'Please give your name', + 'Please give your email', + 'Please give a subject', + 'Please write a message', + ] + }, + { + fields => { + em => 'invalidemail', + name => '', + subject => '', + message => '', + }, + errors => [ + 'Please give your name', + 'Please give a valid email address', + 'Please give a subject', + 'Please write a message', + ] + }, + { + fields => { + em => 'test@example.com', + name => 'A name', + subject => '', + message => '', + }, + errors => [ 'Please give a subject', 'Please write a message', ] + }, + { + fields => { + em => 'test@example.com', + name => 'A name', + subject => 'A subject', + message => '', + }, + errors => [ 'Please write a message', ] + }, + { + fields => { + em => 'test@example.com', + name => 'A name', + subject => ' ', + message => '', + }, + errors => [ 'Please give a subject', 'Please write a message', ] + }, + { + fields => { + em => 'test@example.com', + name => 'A name', + subject => 'A subject', + message => ' ', + }, + errors => [ 'Please write a message', ] + }, + + ) +{ + subtest 'check submit page error handling' => sub { + $mech->get_ok('/contact'); + $mech->submit_form_ok( { with_fields => $test->{fields} } ); + is_deeply $mech->form_errors, $test->{errors}; + is_deeply $mech->visible_form_values, $test->{fields}; + }; +} + done_testing(); |