implemented action dispatching by type
[catagits/CatalystX-Declare.git] / t / 060_exception_handling.t
CommitLineData
392e5076 1#!/usr/bin/env perl
2use strict;
3use warnings;
4
5no warnings 'redefine';
6
7use FindBin;
8use lib "$FindBin::Bin/lib";
9
10use Test::More;
11use Test::Output;
12use Catalyst::Test 'TestApp';
13
14my $get = sub { get(join '/', '/errors/signature_error_on_foo', @_) };
15my $subget = sub { get(join '/', '/sub_errors/signature_error_on_foo', @_) };
16my $modget = sub { get(join '/', '/sub_errors/signature_error_on_foo_modify', @_) };
17
18
19local *TestApp::debug = sub { 0 };
20
392e5076 21stderr_like {
22
23 like $get->('bar'), qr/come back later/i, 'normal handling of method validation error';
24
25} qr/Validation failed/, 'method error throws validation error to error log';
26
27stderr_like {
28
29 like $subget->('bar'), qr/come back later/i, 'normal handling of method validation error (child)';
30
31} qr/Validation failed/, 'method error throws validation error to error log (child)';
32
33stderr_like {
34
35 like $modget->('bar'), qr/come back later/i, 'normal handling of method validation error (modified)';
36
37} qr/Validation failed/, 'method error throws validation error to error log (modified)';
38
39is $get->('baz'), 'FOO BAR', 'make sure all works without any errors happening';
40is $subget->('baz'), 'FOO BAR', 'make sure all works without any errors happening (child)';
41is $modget->('baz'), 'FOO_MODIFY BAR', 'make sure all works without any errors happening (child)';
42
43
44local *TestApp::debug = sub { 1 };
45
392e5076 46stderr_unlike {
47
48 is $get->('baz'), 'FOO BAR', 'make sure all works without any errors happening in debug mode';
49
50} qr/\[error\]/i, 'no errors in output';
51
52stderr_unlike {
53
54 is $subget->('baz'), 'FOO BAR', 'make sure all works without any errors happening in debug mode (child)';
55
56} qr/\[error\]/i, 'no errors in output (child)';
57
58stderr_unlike {
59
60 is $modget->('baz'), 'FOO_MODIFY BAR', 'make sure all works without any errors happening in debug mode (modified)';
61
62} qr/\[error\]/i, 'no errors in output (modified)';
63
64
65done_testing;