From: Rafael Kitover Date: Tue, 9 Jun 2009 12:46:43 +0000 (+0000) Subject: added test for ->view() with one view not returning a blessed instance X-Git-Tag: 5.80006~62 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=aa2e6d9e59b1373b13fe7c37725f3fab3b8a1e92;hp=7d665b582162163415de0d7579403218cf4e66a6 added test for ->view() with one view not returning a blessed instance --- diff --git a/t/aggregate/live_component_view_single.t b/t/aggregate/live_component_view_single.t new file mode 100644 index 0000000..6c50c18 --- /dev/null +++ b/t/aggregate/live_component_view_single.t @@ -0,0 +1,33 @@ +#!perl + +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; + +our $iters; + +BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } + +use Test::More tests => 3*$iters; +use Catalyst::Test 'TestAppOneView'; + +if ( $ENV{CAT_BENCHMARK} ) { + require Benchmark; + Benchmark::timethis( $iters, \&run_tests ); +} +else { + for ( 1 .. $iters ) { + run_tests(); + } +} + +sub run_tests { + { + is(get('/view_by_name?view=Dummy'), 'TestAppOneView::View::Dummy', + '$c->view("name") returns blessed instance'); + is(get('/view_no_args'), 'TestAppOneView::View::Dummy', + '$c->view() returns blessed instance'); + } +} diff --git a/t/lib/TestAppOneView.pm b/t/lib/TestAppOneView.pm new file mode 100644 index 0000000..59354b3 --- /dev/null +++ b/t/lib/TestAppOneView.pm @@ -0,0 +1,8 @@ +package TestAppOneView; +use strict; +use warnings; +use Catalyst; + +__PACKAGE__->setup; + +1; diff --git a/t/lib/TestAppOneView/Controller/Root.pm b/t/lib/TestAppOneView/Controller/Root.pm new file mode 100644 index 0000000..1da451c --- /dev/null +++ b/t/lib/TestAppOneView/Controller/Root.pm @@ -0,0 +1,24 @@ +package TestAppOneView::Controller::Root; + +use base 'Catalyst::Controller'; +use Scalar::Util (); + +__PACKAGE__->config->{namespace} = ''; + +sub view_no_args : Local { + my ( $self, $c ) = @_; + + my $v = $c->view; + + $c->res->body(Scalar::Util::blessed($v)); +} + +sub view_by_name : Local { + my ( $self, $c ) = @_; + + my $v = $c->view($c->req->param('view')); + + $c->res->body(Scalar::Util::blessed($v)); +} + +1; diff --git a/t/lib/TestAppOneView/View/Dummy.pm b/t/lib/TestAppOneView/View/Dummy.pm new file mode 100644 index 0000000..bba0855 --- /dev/null +++ b/t/lib/TestAppOneView/View/Dummy.pm @@ -0,0 +1,5 @@ +package TestAppOneView::View::Dummy; + +use base 'Catalyst::View'; + +1;