From: Tomas Doran Date: Thu, 26 Aug 2010 00:18:07 +0000 (+0000) Subject: Merge 'trunk' into 'Catalyst-Test-base-href' X-Git-Tag: 5.80026~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=0de7c4a458cb3d2420f20481ed5cddd20eb5d800;hp=34ff7cb5029ba62ab821542c67b8e9b33153abe3 Merge 'trunk' into 'Catalyst-Test-base-href' r15777@t0mlaptop (orig r13468): lukes | 2010-08-04 15:25:18 +0100 moved component name sort that happens in setup_components to locate_components to allow methods to wrap around locate_components r15779@t0mlaptop (orig r13470): rbuels | 2010-08-04 21:04:14 +0100 don't load Catalyst::Exception in Utils.pm BEGIN, because some Scripts::* load Utils before MyApp.pm, meaning that ::Exception::CATALYST_EXCEPTION_CLASS in MyApp.pm will not be respected r15823@t0mlaptop (orig r13513): dduncan | 2010-08-22 04:25:42 +0100 C-R-5-8 : Makefile.PL : remove bogus comment r15824@t0mlaptop (orig r13514): ferz | 2010-08-22 15:03:36 +0100 Discovered some inconsistency in precedence behavior of chained actions. r15825@t0mlaptop (orig r13515): ferz | 2010-08-22 16:04:58 +0100 Checks for any action now. r15826@t0mlaptop (orig r13516): bricas | 2010-08-23 18:55:43 +0100 Fix two warnings: - Fix warning about "excludes" during role application - Fix warning from MooseX::Getopt regarding duplicate "help" aliases r15830@t0mlaptop (orig r13520): hobbs | 2010-08-25 02:31:50 +0100 Add the app for ChainedActionsApp test. It's still failing, but differently now... r15838@t0mlaptop (orig r13528): t0m | 2010-08-25 14:46:22 +0100 Fix bug with parse_on_demand r15839@t0mlaptop (orig r13529): t0m | 2010-08-25 14:47:01 +0100 Back out 13528, cocked that up. r15840@t0mlaptop (orig r13530): t0m | 2010-08-25 14:47:23 +0100 Fix bug with parse_on_demand (take 2) r15844@t0mlaptop (orig r13534): t0m | 2010-08-25 23:53:20 +0100 Fix RT#59738, show_internal_actions produces warnings in debug mode r15845@t0mlaptop (orig r13535): t0m | 2010-08-26 00:07:21 +0100 Fix test output, as per RT#56590 r15846@t0mlaptop (orig r13536): t0m | 2010-08-26 00:14:42 +0100 Update changelog r15847@t0mlaptop (orig r13537): t0m | 2010-08-26 00:17:50 +0100 Test::Aggregate does not like __END__ r15848@t0mlaptop (orig r13538): t0m | 2010-08-26 00:26:14 +0100 No passing TODOs r15849@t0mlaptop (orig r13539): t0m | 2010-08-26 00:31:03 +0100 Omit the run method for scripts which new Pod::Coverage finds r15850@t0mlaptop (orig r13540): t0m | 2010-08-26 00:39:56 +0100 No idea why but lack of this causes a void context warning when run under the test harness r15851@t0mlaptop (orig r13541): t0m | 2010-08-26 01:01:20 +0100 Unify options, get rid of -h which only worked on the CGI script anyway (-h is host in ::Server). This technically breaks back-compat slightly, but for the command line options for help in the script you never run from command line anyway, I don't care r15852@t0mlaptop (orig r13542): t0m | 2010-08-26 01:08:24 +0100 Rename test, to merge --- diff --git a/Makefile.PL b/Makefile.PL index ed91b4c..47e26c0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -28,6 +28,7 @@ requires 'CGI::Simple::Cookie' => '1.109'; requires 'Data::Dump'; requires 'Data::OptList'; requires 'HTML::Entities'; +requires 'HTML::HeadParser'; requires 'HTTP::Body' => '1.06'; # ->cleanup(1) requires 'HTTP::Headers' => '1.64'; requires 'HTTP::Request' => '5.814'; diff --git a/lib/Catalyst/Test.pm b/lib/Catalyst/Test.pm index e940be0..397e98d 100644 --- a/lib/Catalyst/Test.pm +++ b/lib/Catalyst/Test.pm @@ -239,6 +239,21 @@ sub local_request { my $response = $cgi->restore->response; $response->request( $request ); + + # HTML head parsing based on LWP::UserAgent + + require HTML::HeadParser; + + my $parser = HTML::HeadParser->new(); + $parser->xml_mode(1) if $response->content_is_xhtml; + $parser->utf8_mode(1) if $] >= 5.008 && $HTML::Parser::VERSION >= 3.40; + + $parser->parse( $response->content ); + my $h = $parser->header; + for my $f ( $h->header_field_names ) { + $response->init_header( $f, [ $h->header($f) ] ); + } + return $response; } diff --git a/t/lib/TestApp/Controller/Root.pm b/t/lib/TestApp/Controller/Root.pm index 5b29201..18c6db8 100644 --- a/t/lib/TestApp/Controller/Root.pm +++ b/t/lib/TestApp/Controller/Root.pm @@ -49,6 +49,22 @@ sub recursion_test : Local { $c->forward( 'recursion_test' ); } +sub base_href_test : Local { + my ( $self, $c ) = @_; + + my $body = <<"EndOfBody"; + + + + + + + +EndOfBody + + $c->response->body($body); +} + sub end : Private { my ($self,$c) = @_; } diff --git a/t/live_catalyst_test.t b/t/live_catalyst_test.t index f4f695e..1adecbb 100644 --- a/t/live_catalyst_test.t +++ b/t/live_catalyst_test.t @@ -3,7 +3,7 @@ use lib "$FindBin::Bin/lib"; use Catalyst::Test 'TestApp', {default_host => 'default.com'}; use Catalyst::Request; -use Test::More tests => 8; +use Test::More tests => 9; content_like('/',qr/root/,'content check'); action_ok('/','Action ok ok','normal action ok'); @@ -11,6 +11,12 @@ action_redirect('/engine/response/redirect/one','redirect check'); action_notfound('/engine/response/status/s404','notfound check'); contenttype_is('/action/local/one','text/plain','Contenttype check'); +### local_request() was not setting response base from base href +{ + my $response = request('/base_href_test'); + is( $response->base, 'http://www.example.com/', 'response base set from base href'); +} + my $creq; my $req = '/dump/request';