Merge branch 'nerdstrike-master'
[catagits/Catalyst-Runtime.git] / t / undef-params.t
CommitLineData
4f96d61c 1use warnings;
2use strict ;
3use Test::More;
4use HTTP::Request::Common;
5use Plack::Test;
6
7# If someone does $c->req->params(undef) you don't get a very good
8# error message. This is a test to see if the proposed change improves
9# that.
10
11
12{
13 package MyApp::Controller::Root;
14 $INC{'MyApp/Controller/Root.pm'} = __FILE__;
15
16 use base 'Catalyst::Controller';
17
18 sub test :Local {
19 my ($self, $c) = @_;
20 my $value = $c->req->param(undef);
21
22 $c->response->body("This is the body");
23 }
24
25 package MyApp;
26 use Catalyst;
27
28 $SIG{__WARN__} = sub {
29 my $error = shift;
30 Test::More::is($error, "You called ->params with an undefined value at t/undef-params.t line 20.\n");
31 };
32
33 MyApp->setup, 'setup app';
34}
35
36ok my $psgi = MyApp->psgi_app, 'build psgi app';
37
38test_psgi $psgi, sub {
39 my $cb = shift;
40 my $res = $cb->(GET "/root/test");
41 is $res->code, 200, 'OK';
42};
43
44done_testing;