Commit | Line | Data |
68b4caec |
1 | use warnings; |
2 | use strict; |
3 | use Test::More; |
4 | use 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); |
46 | MyApp->setup; |
47 | } |
48 | |
49 | use 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 | |
59 | done_testing; |
60 | |