enabling new lifecycle in test + FIXME
[catagits/Catalyst-Runtime.git] / t / lib / TestCustomContainer.pm
CommitLineData
850a9bbe 1package TestCustomContainer;
2use Moose;
3use namespace::autoclean;
4use Test::More;
5
6has app_name => (
7 is => 'ro',
8 isa => 'Str',
9 default => 'TestAppCustomContainer',
10);
11
12has container_class => (
13 is => 'ro',
14 isa => 'Str',
15 lazy_build => 1,
16);
17
18has sugar => (
19 is => 'ro',
20 isa => 'Int',
21);
22
95dda84f 23# Reason for this class:
24# I wanted have a set of tests that would test both the sugar version of the
25# container, as the sugar-less. I figured I shouldn't just copy and paste
26# the tests. So after struggling for hours to find a way to test twice
27# against the same TestApp using only one file, I decided to break it
28# into a separate class (this one), and call it at
29# - live_container_custom_container_sugar.t and
30# - live_container_custom_container_nosugar.t
31# setting only the sugar attribute.
32
850a9bbe 33sub BUILD {
34 my $self = shift;
35
36 $ENV{TEST_APP_CURRENT_CONTAINER} = $self->container_class;
37
38 require Catalyst::Test;
39 Catalyst::Test->import($self->app_name);
40
41 is(get('/container_class'), $self->container_class);
42 is(get('/container_isa'), $self->container_class);
43
44 done_testing;
45}
46
47sub _build_container_class {
48 my $self = shift;
49
50 my $sugar = $self->sugar ? '' : 'No';
51
52 return $self->app_name . "::${sugar}SugarContainer";
53}
54
55__PACKAGE__->meta->make_immutable;
56
571;