]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - t/4_app_00_base.t
CGI::Ex 2.08
[chaz/p5-CGI-Ex] / t / 4_app_00_base.t
index 59bfa52dd0fa8be4c5744679198b47cbe8b41be7..1520d7abcbfcc518f3ae8f6ba9ea7dfc35631582 100644 (file)
@@ -4,9 +4,15 @@
 
 4_app_00_base.t - Check for the basic functionality of CGI::Ex::App.
 
+=head1 NOTE
+
+These tests are extremely stripped down to test the basic path flow.  Normally
+unit tests are useful for garnering information about a module.  For CGI::Ex::App
+it is suggested to stick to live use cases or the CGI::Ex::App perldoc.
+
 =cut
 
-use Test::More tests => 3;
+use Test::More tests => 9;
 use strict;
 
 {
@@ -38,6 +44,8 @@ use strict;
 
   sub step2_hash_validation { return {wow => {required => 1, required_error => 'wow is required'}} }
 
+  sub step2_path_info_map { [[qr{^/step2/(\w+)$}, 'wow']] }
+
   sub step2_file_print { return \ "Some step2 content ([% foo %], [% one %]) <input type=text name=wow>[% wow_error %]" }
 
   sub step2_hash_swap { return {foo => 'bar', one => 'two'} }
@@ -50,6 +58,7 @@ use strict;
 
   sub step3_file_print { return \ "All good" }
 
+
 }
 
 ###----------------------------------------------------------------###
@@ -60,7 +69,7 @@ use strict;
 Foo->new({
   form => {},
 })->navigate;
-ok($Foo::test_stdout eq "Main Content");
+ok($Foo::test_stdout eq "Main Content", "Got the right output");
 
 ###----------------------------------------------------------------###
 
@@ -70,7 +79,7 @@ ok($Foo::test_stdout eq "Main Content");
 Foo->new({
   form => {step => 'step2'},
 })->navigate;
-ok($Foo::test_stdout eq "Some step2 content (bar, two) <input type=text name=wow value=\"wee\">wow is required");
+ok($Foo::test_stdout eq "Some step2 content (bar, two) <input type=text name=wow value=\"wee\">wow is required", "Got the right output");
 
 ###----------------------------------------------------------------###
 
@@ -80,4 +89,42 @@ ok($Foo::test_stdout eq "Some step2 content (bar, two) <input type=text name=wow
 Foo->new({
   form=> {step => 'step2', wow => 'something'},
 })->navigate;
-ok($Foo::test_stdout eq "All good");
+ok($Foo::test_stdout eq "All good", "Got the right output");
+
+###----------------------------------------------------------------###
+
+#$ENV{'REQUEST_METHOD'} = 'GET';
+#$ENV{'QUERY_STRING'}   = '';
+local $ENV{'PATH_INFO'} = '/step2';
+
+Foo->new({
+  form=> {},
+})->navigate;
+ok($Foo::test_stdout eq "Some step2 content (bar, two) <input type=text name=wow value=\"wee\">wow is required", "Got the right output");
+
+###----------------------------------------------------------------###
+
+#$ENV{'REQUEST_METHOD'} = 'GET';
+#$ENV{'QUERY_STRING'}   = 'wow=something';
+local $ENV{'PATH_INFO'} = '/step2';
+
+my $f = Foo->new({
+  form=> {wow => 'something'},
+})->navigate;
+ok($Foo::test_stdout eq "All good", "Got the right output");
+ok($f->form->{'step'} eq 'step2', "Got the right variable set in form");
+
+###----------------------------------------------------------------###
+
+#$ENV{'REQUEST_METHOD'} = 'GET';
+#$ENV{'QUERY_STRING'}   = '';
+local $ENV{'PATH_INFO'} = '/step2/something';
+
+$f = Foo->new({
+  form => {},
+})->navigate;
+ok($Foo::test_stdout eq "All good", "Got the right output");
+ok($f->form->{'step'} eq 'step2',     "Got the right variable set in form");
+ok($f->form->{'wow'}  eq 'something', "Got the right variable set in form");
+
+###----------------------------------------------------------------###
This page took 0.019278 seconds and 4 git commands to generate.