small sketch for custom container tests
[catagits/Catalyst-Runtime.git] / t / lib / TestCustomContainer.pm
1 package TestCustomContainer;
2 use Moose;
3 use namespace::autoclean;
4 use Test::More;
5
6 has app_name => (
7     is => 'ro',
8     isa => 'Str',
9     default => 'TestAppCustomContainer',
10 );
11
12 has container_class => (
13     is => 'ro',
14     isa => 'Str',
15     lazy_build => 1,
16 );
17
18 has sugar => (
19     is => 'ro',
20     isa => 'Int',
21 );
22
23 sub BUILD {
24     my $self = shift;
25
26     $ENV{TEST_APP_CURRENT_CONTAINER} = $self->container_class;
27
28     require Catalyst::Test;
29     Catalyst::Test->import($self->app_name);
30
31     is(get('/container_class'), $self->container_class);
32     is(get('/container_isa'), $self->container_class);
33
34     done_testing;
35 }
36
37 sub _build_container_class {
38     my $self = shift;
39
40     my $sugar = $self->sugar ? '' : 'No';
41
42     return $self->app_name . "::${sugar}SugarContainer";
43 }
44
45 __PACKAGE__->meta->make_immutable;
46
47 1;