| 1 | use Test::More tests=>7; |
| 2 | |
| 3 | # Include the test hierarchy |
| 4 | use lib 't/lib'; |
| 5 | |
| 6 | use CGI; |
| 7 | use TestCGI; |
| 8 | use TestApp9; |
| 9 | |
| 10 | # Prevent output to STDOUT |
| 11 | $ENV{CGI_APP_RETURN_ONLY} = 1; |
| 12 | |
| 13 | # Test making a modification to the output body |
| 14 | { |
| 15 | my $q = CGI->new({rm=>"postrun_body"}); |
| 16 | my $app = TestApp9->new(QUERY=>$q); |
| 17 | my $output = $app->run(); |
| 18 | like($output, qr/^Content\-Type\:\ text\/html/, "Postrun body has headers"); |
| 19 | like($output, qr/Hello world: postrun_body/, "Hello world: postrun_body"); |
| 20 | like($output, qr/postrun\ was\ here/, "Postrun was here"); |
| 21 | } |
| 22 | |
| 23 | |
| 24 | # Test changing HTTP headers |
| 25 | { |
| 26 | my $q = CGI->new({rm=>"postrun_header"}); |
| 27 | my $app = TestApp9->new(QUERY=>$q); |
| 28 | my $output = $app->run(); |
| 29 | like($output, qr/^Status: 302/, "Postrun header is redirect"); |
| 30 | like($output, qr/postrun.html/, "Postrun header is redirect to postrun.html"); |
| 31 | like($output, qr/Hello world: postrun_header/, "Hello world: postrun_header"); |
| 32 | unlike($output, qr/postrun\ was\ here/, "Postrun was NOT here"); |
| 33 | } |