Add tests which should fail, but don't.
[catagits/Catalyst-Action-REST.git] / t / lib / Test / Catalyst / Action / REST / Controller / Root.pm
1 package Test::Catalyst::Action::REST::Controller::Root;
2 use Moose;
3 use namespace::autoclean;
4
5 BEGIN { extends qw/Catalyst::Controller::REST/ }
6
7 __PACKAGE__->config( namespace => '' );
8
9 sub begin {}  # Don't need serialization..
10
11 sub test : Local : ActionClass('REST') {
12     my ( $self, $c ) = @_;
13     $c->stash->{'entity'} = 'something';
14 }
15
16 sub test_GET {
17     my ( $self, $c ) = @_;
18
19     $c->stash->{'entity'} .= " GET";
20     $c->forward('ok');
21 }
22
23 sub test_POST {
24     my ( $self, $c ) = @_;
25
26     $c->stash->{'entity'} .= " POST";
27     $c->forward('ok');
28 }
29
30 sub test_PUT {
31     my ( $self, $c ) = @_;
32
33     $c->stash->{'entity'} .= " PUT";
34     $c->forward('ok');
35 }
36
37 sub test_DELETE {
38     my ( $self, $c ) = @_;
39
40     $c->stash->{'entity'} .= " DELETE";
41     $c->forward('ok');
42 }
43
44 sub test_OPTIONS {
45     my ( $self, $c ) = @_;
46
47     $c->stash->{'entity'} .= " OPTIONS";
48     $c->forward('ok');
49 }
50
51 sub notreally : Local : ActionClass('REST') {
52 }
53
54 sub notreally_GET {
55     my ( $self, $c ) = @_;
56
57     $c->stash->{'entity'} = "notreally GET";
58     $c->forward('ok');
59 }
60
61 sub not_implemented : Local : ActionClass('REST') {
62 }
63
64 sub not_implemented_GET {
65     my ( $self, $c ) = @_;
66
67     $c->stash->{'entity'} = "not_implemented GET";
68     $c->forward('ok');
69 }
70
71 sub not_implemented_not_implemented {
72     my ( $self, $c ) = @_;
73
74     $c->stash->{'entity'} = "Not Implemented Handler";
75     $c->forward('ok');
76 }
77
78 sub not_modified : Local : ActionClass('REST') { }
79
80 sub not_modified_GET {
81     my ( $self, $c ) = @_;
82     $c->res->status(304);
83     return 1;
84 }
85
86 sub ok : Private {
87     my ( $self, $c ) = @_;
88
89     $c->res->content_type('text/plain');
90     $c->res->body( $c->stash->{'entity'} );
91 }
92
93 sub end : Private {} # Don't need serialization..
94
95 1;
96