added MANIFEST.SKIP
[catagits/Catalyst-View-Email.git] / t / lib / TestApp / Controller / Root.pm
1 package  # Hide from PAUSE
2     TestApp::Controller::Root;
3
4 use base qw(Catalyst::Controller);
5
6 use Encode;
7
8 sub default : Private {
9     my ( $self, $c ) = @_;
10
11     $c->res->body(qq{Nothing Here});
12 }
13
14 sub email : Global('email') {
15     my ($self, $c, @args) = @_;
16
17     my $time = $c->req->params->{time} || time;
18
19     $c->stash->{email} = {
20         to      => 'test-email@example.com',
21         from    => 'no-reply@example.com',
22         subject => 'Email Test',
23         body    => "Email Sent at: $time"
24     };
25
26     $c->forward('TestApp::View::Email');
27
28     if ( scalar( @{ $c->error } ) ) {
29         $c->res->status(500);
30         $c->res->body('Email Failed');
31     } else {
32         $c->res->body('Plain Email Ok');
33     }
34 }
35
36 sub email_app_config : Global('email_app_config') {
37     my ($self, $c, @args) = @_;
38
39     my $time = $c->req->params->{time} || time;
40
41     $c->stash->{email} = {
42         to      => 'test-email@example.com',
43         from    => 'no-reply@example.com',
44         subject => 'Email Test',
45         body    => "Email Sent at: $time"
46     };
47
48     $c->forward('TestApp::View::Email::AppConfig');
49
50     if ( scalar( @{ $c->error } ) ) {
51         $c->res->status(500);
52         $c->res->body('Email Failed');
53     } else {
54         $c->res->body('Plain Email Ok');
55     }
56 }
57
58 sub template_email : Global('template_email') {
59     my ($self, $c, @args) = @_;
60
61     $c->stash->{time} = $c->req->params->{time} || time;
62
63     $c->stash->{email} = {
64         to           => 'test-email@example.com',
65         from         => 'no-reply@example.com',
66         subject      => 'Just a test',
67         content_type => 'multipart/alternative',
68         templates => [
69             {
70                 template        => 'text_plain/test.tt',
71                 content_type    => 'text/plain',
72             },
73             {
74                 view            => 'TT',
75                 template        => 'text_html/test.tt',
76                 content_type    => 'text/html',
77             },
78         ],
79     };
80
81     $c->forward('TestApp::View::Email::Template');    
82
83     if ( scalar( @{ $c->error } ) ) {
84         $c->res->status(500);
85         $c->res->body('Template Email Failed');
86     } else {
87         $c->res->body('Template Email Ok');
88     }
89 }
90
91 sub template_email_single : Global('template_email_single') {
92     my ($self, $c, @args) = @_;
93
94     $c->stash->{time} = $c->req->params->{time} || time;
95
96     $c->stash->{email} = {
97         to           => 'test-email@example.com',
98         from         => 'no-reply@example.com',
99         subject      => 'Just a test',
100         content_type => 'multipart/alternative',
101         templates =>  {
102             view            => 'TT',
103             template        => 'text_html/test.tt',
104             content_type    => 'text/html',
105         },
106         
107     };
108
109     $c->forward('TestApp::View::Email::Template');    
110
111     if ( scalar( @{ $c->error } ) ) {
112         $c->res->status(500);
113         $c->res->body('Template Email Failed');
114     } else {
115         $c->res->body('Template Email Ok');
116     }
117 }
118
119 sub template_email_utf8 : Global('template_email_utf8') {
120     my ($self, $c, @args) = @_;
121
122     $c->stash->{time} = $c->req->params->{time} || time;
123
124     $c->stash->{chars} = decode('utf-8', "✔ ✈ ✉");
125
126     $c->stash->{email} = {
127         to           => 'test-email@example.com',
128         from         => 'no-reply@example.com',
129         subject      => 'Just a test',
130         content_type => 'multipart/alternative',
131        templates => [
132             {
133                 template        => 'text_plain/test.tt',
134                 content_type    => 'text/plain',
135                 charset      => 'utf-8',
136                 encoding     => 'quoted-printable',
137             },
138             {
139                 view            => 'TT',
140                 template        => 'text_html/test_utf8.tt',
141                 content_type    => 'text/html',
142                 charset      => 'utf-8',
143                 encoding     => 'quoted-printable',
144              },
145         ],
146     };
147
148     $c->forward('TestApp::View::Email::Template');    
149
150     if ( scalar( @{ $c->error } ) ) {
151         $c->res->status(500);
152         $c->res->body('Template Email Failed');
153     } else {
154         $c->res->body('Template Email Ok');
155     }
156 }
157
158
159
160 sub template_email_app_config : Global('template_email_app_config') {
161     my ($self, $c, @args) = @_;
162
163     $c->stash->{time} = $c->req->params->{time} || time;
164
165     $c->stash->{template_email} = {
166         to      => 'test-email@example.com',
167         from    => 'no-reply@example.com',
168         subject => 'Just a test',
169         templates => [
170             {
171                 template        => 'text_plain/test.tt',
172                 content_type    => 'text/plain',
173             },
174             {
175                 view            => 'TT',
176                 template        => 'text_html/test.tt',
177                 content_type    => 'text/html',
178             },
179         ],
180     };
181
182     $c->forward('TestApp::View::Email::Template::AppConfig');
183
184     if ( scalar( @{ $c->error } ) ) {
185         $c->res->status(500);
186         $c->res->body('Template Email Failed');
187     } else {
188         $c->res->body('Template Email Ok');
189     }
190 }
191
192 sub mason_email : Global('mason_email') {
193     my ($self, $c, @args) = @_;
194
195     $c->stash->{time} = $c->req->params->{time} || time;
196
197     $c->stash->{email} = {
198         to      => 'test-email@example.com',
199         from    => 'no-reply@example.com',
200         subject => 'Just a test',
201         templates => [
202             {
203                 view            => 'Mason',
204                         template        => 'text_plain/test.m',
205                 content_type    => 'text/plain',
206             },
207             {
208                 view            => 'Mason',
209                 template        => 'text_html/test.m',
210                 content_type    => 'text/html',
211             },
212         ],
213     };
214
215     $c->forward('TestApp::View::Email::Template');    
216
217     if ( scalar( @{ $c->error } ) ) {
218         $c->res->status(500);
219         $c->res->body('Mason Email Failed');
220     } else {
221         $c->res->body('Mason Email Ok');
222     }
223 }
224
225
226 1;