Support testing against two apps in same perl interpreter
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / CattySession.pm
1 package CattySession;
2
3 use strict;
4
5 #use Catalyst;
6 use Catalyst qw/
7     Session
8     Session::State::Cookie
9     Session::Store::Dummy
10     /;
11 use Cwd;
12 use MIME::Base64;
13
14 our $VERSION = '0.01';
15
16 CattySession->config(
17     name => 'CattySession',
18     root => cwd . '/t/root',
19 );
20
21 CattySession->setup();
22
23 sub auto : Private {
24     my ( $self, $context ) = @_;
25     if ( $context->session ) {
26         return 1;
27     }
28
29 }
30
31 sub default : Private {
32     my ( $self, $context ) = @_;
33     my $html = html( "Root", "This is the root page" );
34     $context->response->content_type("text/html");
35     $context->response->output($html);
36 }
37
38 sub name : Global {
39     my ($self, $c) = @_;
40
41     my $html = html( $c->config->{name}, "This is the die page" );
42     $c->response->content_type("text/html");
43     $c->response->output($html);
44 }
45
46
47 sub html {
48     my ( $title, $body ) = @_;
49     return qq{
50 <html>
51 <head><title>$title</title></head>
52 <body>
53 $body
54 <a href="/hello/">Hello</a>.
55 </body></html>
56 };
57 }
58
59 1;
60