Commit | Line | Data |
c4057ce2 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More 0.88; |
5 | |
6 | use lib 't/lib'; |
69d9fc4e |
7 | use Catalyst::Test 'MyApp1'; |
8 | use HTTP::Request::Common qw( GET PUT POST DELETE ); |
c4057ce2 |
9 | |
77d62699 |
10 | { |
11 | request( |
12 | GET '/foo', |
13 | [ |
14 | Accept => 'application/json', |
15 | ] |
16 | ); |
17 | |
18 | is( |
19 | $MyApp1::Controller::C1::REQ{get}, 1, |
20 | 'GET request for /foo went to the right sub' |
21 | ); |
22 | |
23 | request( |
24 | GET '/foo', |
25 | [ |
26 | Accept => '*/*', |
27 | ] |
28 | ); |
29 | |
30 | is( |
31 | $MyApp1::Controller::C1::REQ{get_html}, 1, |
32 | 'GET request for /foo that looks like a browser went to the right sub' |
33 | ); |
34 | |
35 | request( POST '/foo' ); |
36 | |
37 | is( |
38 | $MyApp1::Controller::C1::REQ{post}, 1, |
39 | 'POST request for /foo went to the right sub' |
40 | ); |
41 | |
42 | request( PUT '/foo' ); |
43 | |
44 | is( |
45 | $MyApp1::Controller::C1::REQ{put}, 1, |
46 | 'PUT request for /foo went to the right sub' |
47 | ); |
48 | |
49 | request( DELETE '/foo' ); |
50 | |
51 | is( |
52 | $MyApp1::Controller::C1::REQ{delete}, 1, |
53 | 'DELETE request for /foo went to the right sub' |
54 | ); |
55 | } |
56 | |
57 | { |
58 | get('c1/bar'); |
59 | |
60 | is( |
61 | $MyApp1::Controller::C1::REQ{get}, 2, |
62 | 'GET request for c1/bar went to the right sub' |
63 | ); |
64 | |
65 | request( |
66 | GET 'c1/bar', |
67 | [ |
68 | Accept => '*/*', |
69 | ] |
70 | ); |
71 | |
72 | is( |
73 | $MyApp1::Controller::C1::REQ{get_html}, 2, |
74 | 'GET request for c1/bar that looks like a browser went to the right sub' |
75 | ); |
76 | |
77 | request( POST 'c1/bar' ); |
78 | |
79 | is( |
80 | $MyApp1::Controller::C1::REQ{post}, 2, |
81 | 'POST request for c1/bar went to the right sub' |
82 | ); |
83 | |
84 | request( PUT 'c1/bar' ); |
85 | |
86 | is( |
87 | $MyApp1::Controller::C1::REQ{put}, 2, |
88 | 'PUT request for c1/bar went to the right sub' |
89 | ); |
90 | |
91 | request( DELETE 'c1/bar' ); |
92 | |
93 | is( |
94 | $MyApp1::Controller::C1::REQ{delete}, 2, |
95 | 'DELETE request for c1/bar went to the right sub' |
96 | ); |
97 | } |
98 | |
99 | { |
100 | get('/normal'); |
101 | |
102 | is( |
103 | $MyApp1::Controller::C1::REQ{normal}, 1, |
104 | 'GET request for /norma went to the right sub' |
105 | ); |
106 | |
107 | request( POST '/normal' ); |
108 | |
109 | is( |
110 | $MyApp1::Controller::C1::REQ{normal}, 2, |
111 | 'POST request for /norma went to the right sub' |
112 | ); |
113 | } |
c4057ce2 |
114 | |
115 | done_testing(); |