unmark +x and remove shebangs
[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
235d641e 25 sub set_params :Local {
26 my ($self, $c) = @_;
27 $c->req->param(foo => 'a', 'b', 'c');
28 $c->res->body(join ',', $c->req->param('foo'));
29 }
30
4f96d61c 31 package MyApp;
32 use Catalyst;
33
34 $SIG{__WARN__} = sub {
35 my $error = shift;
a7ab9aa9 36 Test::More::like($error, qr[You called ->params with an undefined value])
501605db 37 unless MyApp->debug;
4f96d61c 38 };
39
2f613fb5 40 MyApp->setup;
4f96d61c 41}
42
43ok my $psgi = MyApp->psgi_app, 'build psgi app';
44
45test_psgi $psgi, sub {
46 my $cb = shift;
235d641e 47
48 {
49 my $res = $cb->(GET "/root/test");
50 is $res->code, 200, 'OK';
51 }
52
53 {
54 my $res = $cb->(GET "/root/set_params");
55 is $res->code, 200, 'OK';
56 is $res->content, 'a,b,c';
57 }
4f96d61c 58};
59
60done_testing;