X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=t%2F4_app_00_base.t;fp=t%2F4_app_00_base.t;h=5d86acaeaa245e2e14bb367572c93cc6e3e54095;hp=2ed1676683b07981047fa137a96db86e68052822;hb=febed4ec71f803b083c3e61b82b9464e9bfb0992;hpb=ed00221d27dfab1e82ec2ea040ab4c399a91c545 diff --git a/t/4_app_00_base.t b/t/4_app_00_base.t index 2ed1676..5d86aca 100644 --- a/t/4_app_00_base.t +++ b/t/4_app_00_base.t @@ -13,9 +13,10 @@ we do try to put it through most paces. =cut -use Test::More tests => 214; +use Test::More tests => 234; use strict; use warnings; +use CGI::Ex::Dump qw(debug); { package Foo; @@ -46,7 +47,7 @@ use warnings; sub main_info_complete { 0 } - sub main_file_print { return \ "Main Content" } + sub main_file_print { return \ "Main Content [%~ extra %]" } sub main_path_info_map { shift->{'main_path_info_map'} } @@ -64,7 +65,7 @@ use warnings; sub step3_info_complete { 0 } - sub step3_file_print { return \ "All good" } + sub step3_file_print { return \ "All good [%~ extra %]" } sub step4_file_val { return {wow => {required => 1, required_error => 'wow is required'}} } @@ -78,12 +79,15 @@ use warnings; sub step4_finalize { shift->append_path('step3') } + sub step5__part_a_file_print { return \ "Step 5 Nested ([% step %])" } + + sub step5__part_a_info_complete { 0 } + } ###----------------------------------------------------------------### ###----------------------------------------------------------------### -###----------------------------------------------------------------### -###----------------------------------------------------------------### +print "#-----------------------------------------\n"; print "### Test some basic returns ###\n"; ok(! eval { CGI::Ex::App::new() }, "Invalid new"); @@ -107,16 +111,22 @@ ok($app->morph_package('foo_bar') eq 'CGI::Ex::App::FooBar', "Got a good morph_p ok(ref($app->path), "Got a good path"); ok(@{ $app->path } == 0, "Got a good path"); -ok($app->default_step eq 'main', "Got a good default_step"); -ok($app->login_step eq '__login', "Got a good login_step"); -ok($app->error_step eq '__error', "Got a good error_step"); -ok($app->forbidden_step eq '__forbidden', "Got a good forbidden_step"); -ok($app->js_step eq 'js', "Got a good js_step"); +is($app->default_step, 'main', "Got a good default_step"); +is($app->login_step, '__login', "Got a good login_step"); +is($app->error_step, '__error', "Got a good error_step"); +is($app->forbidden_step, '__forbidden', "Got a good forbidden_step"); +is($app->js_step, 'js', "Got a good js_step"); + +# check for different step types +is($app->run_hook('file_print', '__leading_underbars'), 'foo_bar/__leading_underbars.html', 'file_print - __ is preserved at beginning of step'); +is($app->run_hook('file_print', 'central__underbars'), 'foo_bar/central/underbars.html', 'file_print - __ is used in middle of step'); +my $ref = ref($app); +is($app->run_hook('morph_package', '__leading_underbars'), "${ref}::LeadingUnderbars", 'morph_package - __ is works at beginning of step'); +is($app->run_hook('morph_package', 'central__underbars'), "${ref}::Central::Underbars", 'morph_package - __ is used in middle of step'); ###----------------------------------------------------------------### ###----------------------------------------------------------------### -###----------------------------------------------------------------### -###----------------------------------------------------------------### +print "#-----------------------------------------\n"; print "### Test basic step selection/form input/validation/filling/template swapping methods ###\n"; #$ENV{'REQUEST_METHOD'} = 'GET'; @@ -175,6 +185,8 @@ ok($Foo::test_stdout eq "Main Content post", "Got the right output for Foo2_4"); Foo2_4->new({_no_post_navigate => 1})->navigate; ok($Foo::test_stdout eq "Main Content", "Got the right output for Foo2_4"); +my $f; + ###----------------------------------------------------------------### local $ENV{'REQUEST_METHOD'} = 'POST'; @@ -190,6 +202,16 @@ Foo->new({ })->navigate; ok($Foo::test_stdout =~ /Some step4 content.*wow is required.*