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