From: André Walker Date: Wed, 3 Aug 2011 03:52:37 +0000 (-0300) Subject: small sketch for custom container tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=850a9bbec594167f8b2f789bd108751215a0430f small sketch for custom container tests --- diff --git a/t/aggregate/live_container_custom_container_nosugar.t b/t/aggregate/live_container_custom_container_nosugar.t new file mode 100644 index 0000000..79eaff1 --- /dev/null +++ b/t/aggregate/live_container_custom_container_nosugar.t @@ -0,0 +1,7 @@ +use warnings; +use strict; +use FindBin '$Bin'; +use lib "$Bin/../lib"; +use TestCustomContainer; + +TestCustomContainer->new(sugar => 0); diff --git a/t/aggregate/live_container_custom_container_sugar.t b/t/aggregate/live_container_custom_container_sugar.t new file mode 100644 index 0000000..0a6ee67 --- /dev/null +++ b/t/aggregate/live_container_custom_container_sugar.t @@ -0,0 +1,7 @@ +use warnings; +use strict; +use FindBin '$Bin'; +use lib "$Bin/../lib"; +use TestCustomContainer; + +TestCustomContainer->new(sugar => 1); diff --git a/t/lib/TestCustomContainer.pm b/t/lib/TestCustomContainer.pm new file mode 100644 index 0000000..310cc19 --- /dev/null +++ b/t/lib/TestCustomContainer.pm @@ -0,0 +1,47 @@ +package TestCustomContainer; +use Moose; +use namespace::autoclean; +use Test::More; + +has app_name => ( + is => 'ro', + isa => 'Str', + default => 'TestAppCustomContainer', +); + +has container_class => ( + is => 'ro', + isa => 'Str', + lazy_build => 1, +); + +has sugar => ( + is => 'ro', + isa => 'Int', +); + +sub BUILD { + my $self = shift; + + $ENV{TEST_APP_CURRENT_CONTAINER} = $self->container_class; + + require Catalyst::Test; + Catalyst::Test->import($self->app_name); + + is(get('/container_class'), $self->container_class); + is(get('/container_isa'), $self->container_class); + + done_testing; +} + +sub _build_container_class { + my $self = shift; + + my $sugar = $self->sugar ? '' : 'No'; + + return $self->app_name . "::${sugar}SugarContainer"; +} + +__PACKAGE__->meta->make_immutable; + +1;