7 use Catalyst::Test 'MyApp1';
8 use HTTP::Request::Common qw( GET PUT POST DELETE );
11 request( GET '/foo', ( Accept => 'application/json' ) );
14 $MyApp1::Controller::C1::REQ{get}, 1,
15 'GET request for /foo went to the right sub'
18 request( GET '/foo', ( Accept => '*/*' ) );
21 $MyApp1::Controller::C1::REQ{get_html}, 1,
22 'GET request for /foo that looks like a browser went to the right sub'
25 request( POST '/foo' );
28 $MyApp1::Controller::C1::REQ{post}, 1,
29 'POST request for /foo went to the right sub'
32 request( PUT '/foo' );
35 $MyApp1::Controller::C1::REQ{put}, 1,
36 'PUT request for /foo went to the right sub'
39 request( DELETE '/foo' );
42 $MyApp1::Controller::C1::REQ{delete}, 1,
43 'DELETE request for /foo went to the right sub'
48 request( GET '/c1/bar', ( Accept => 'application/json' ) );
51 $MyApp1::Controller::C1::REQ{get}, 2,
52 'GET request for /c1/bar went to the right sub'
55 request( GET '/c1/bar', ( Accept => '*/*', ) );
58 $MyApp1::Controller::C1::REQ{get_html}, 2,
59 'GET request for /c1/bar that looks like a browser went to the right sub'
62 request( POST '/c1/bar' );
65 $MyApp1::Controller::C1::REQ{post}, 2,
66 'POST request for /c1/bar went to the right sub'
69 request( PUT '/c1/bar' );
72 $MyApp1::Controller::C1::REQ{put}, 2,
73 'PUT request for /c1/bar went to the right sub'
76 request( DELETE '/c1/bar' );
79 $MyApp1::Controller::C1::REQ{delete}, 2,
80 'DELETE request for /c1/bar went to the right sub'
85 request( GET '/chain1/42/chain2/84/baz/foo' );
88 $MyApp1::Controller::C1::REQ{chain1}, 42,
89 'chain1 chain point captured the first arg'
93 $MyApp1::Controller::C1::REQ{chain2}, 84,
94 'chain2 chain point captured the second arg'
98 $MyApp1::Controller::C1::REQ{baz}, 'foo',
99 'baz route captured the third arg'
104 request( GET '/user/99' );
107 $MyApp1::Controller::C1::REQ{user}, 99,
108 'get /user/99 calls _set_user chain point'
112 $MyApp1::Controller::C1::REQ{user_end}, 99,
113 'get /user/99 calls get chained from _set_user'
118 request( GET '/thing/99' );
121 $MyApp1::Controller::C1::REQ{thing}, 99,
122 'get /thing/99 calls _set_thing chain point'
126 $MyApp1::Controller::C1::REQ{thing_end}, 99,
127 'get /thing/99 calls get chained from _set_thing'
132 request( GET '/normal' );
135 $MyApp1::Controller::C1::REQ{normal}, 1,
136 'GET request for /normal went to the right sub'
139 request( POST '/normal' );
142 $MyApp1::Controller::C1::REQ{normal}, 2,
143 'POST request for /normal went to the right sub'
151 $MyApp1::Controller::Root::REQ{root}, 1,
152 'GET request for / went to the right sub (routes work when namespace is empty string)'
155 request( GET '/foo.txt' );
158 $MyApp1::Controller::Root::REQ{'foo.txt'}, 1,
159 'GET request for /foo.txt went to the right sub (routes work when namespace is empty string)'