update distar url
[catagits/Catalyst-Runtime.git] / t / execute_exception.t
CommitLineData
68b4caec 1use warnings;
2use strict;
3use Test::More;
4use HTTP::Request::Common;
5
6{
7 package MyApp::Controller::Root;
8 $INC{'MyApp/Controller/Root.pm'} = __FILE__;
9
10 use base 'Catalyst::Controller';
11
12 MyApp::Controller::Root->config(namespace=>'');
13
14 sub could_throw :Private {
15 my ($self, $c) = @_;
16 if ($c->req->args->[0] eq 'y') {
17 die 'Bad stuff happened';
18 }
19 else {
20 return 5;
21 }
22 }
23
24 sub do_throw :Local {
25 my ($self, $c) = @_;
26
27 my $ret = $c->forward('/could_throw/y');
28 Test::More::is($c->state, 0, 'Throwing: state is correct');
29 Test::More::is($ret, 0, 'Throwing: return is correct');
30 Test::More::ok($c->has_errors, 'Throwing: has errors');
31 }
32
33 sub dont_throw :Local {
34 my ($self, $c) = @_;
35
36 my $ret = $c->forward('/could_throw/n');
37 Test::More::is($c->state, 5, 'Not throwing: state is correct');
38 Test::More::is($ret, 5, 'Not throwing: return is correct');
39 Test::More::ok(!$c->has_errors, 'Throwing: no errors');
40 }
41
42 package MyApp;
43 use Catalyst;
44
45 MyApp->config(show_internal_actions=>1);
53c7cc10 46 MyApp->setup('-Log=fatal');
68b4caec 47}
48
49use Catalyst::Test 'MyApp';
50
51{
52 my ($res, $c);
53
54 ctx_request("/dont_throw");
55 ctx_request("/do_throw");
56 ctx_request("/dont_throw");
57}
58
59done_testing;
60