source: sandbox/2.4-expresso-api/prototype/library/tonic/features/request.feature @ 5888

Revision 5888, 9.9 KB checked in by cristiano, 12 years ago (diff)

Ticket #2598 - implementação base REST + oauth

  • Property svn:executable set to *
Line 
1Feature: HTTP request object
2  In order to handle a request
3  As a PHP developer
4  I want a PHP object that represents the state of the incoming HTTP request
5 
6  Scenario: Have access to the request URI
7    Given the request URI of "/something/otherthing"
8    When I create a request object
9    Then I should see a request URI of "/something/otherthing"
10   
11  Scenario: Have access to the HTTP request method
12    Given the request method of "GET"
13    When I create a request object
14    Then I should see a request method of "GET"
15   
16  Scenario: Receive the request querystring
17    Given the request URI of "/something/otherthing"
18    And the request method of "GET"
19    And the querystring is "?foo=bar"
20    When I create a request object
21    Then I should see a querystring of "foo=bar"
22   
23  Scenario: Have access to the HTTP request method
24    Given the request method of "post"
25    And the request data of "some data"
26    When I create a request object
27    Then I should see a request method of "POST"
28    And I should see the request data "some data"
29   
30  Scenario: Have access to the HTTP request data
31    Given the request method of "PUT"
32    And the request data of "some data"
33    When I create a request object
34    Then I should see a request method of "PUT"
35    And I should see the request data "some data"
36   
37  Scenario: Have bare request URI content negotiated correctly
38    Given the request URI of "/requesttest/one/two"
39    When I create a request object
40    Then I should see a request URI of "/requesttest/one/two"
41    And I should see a negotiated URI of "/requesttest/one/two"
42    And I should see a format negotiated URI of "/requesttest/one/two"
43    And I should see a language negotiated URI of "/requesttest/one/two"
44   
45  Scenario: Have extension request URI content negotiated correctly
46    Given the request URI of "/requesttest/one/two.html"
47    When I create a request object
48    Then I should see a request URI of "/requesttest/one/two"
49    And I should see a negotiated URI of "/requesttest/one/two.html,/requesttest/one/two"
50    And I should see a format negotiated URI of "/requesttest/one/two.html,/requesttest/one/two"
51    And I should see a language negotiated URI of "/requesttest/one/two.html,/requesttest/one/two"
52   
53  Scenario: Have bare request URI with accept header content negotiated correctly
54    Given the request URI of "/requesttest/one/two"
55    And the accept header of "image/png;q=0.5,text/html"
56    When I create a request object
57    Then I should see a request URI of "/requesttest/one/two"
58    And I should see a negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.png,/requesttest/one/two"
59    And I should see a format negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.png,/requesttest/one/two"
60    And I should see a language negotiated URI of "/requesttest/one/two"
61   
62  Scenario: Have extension request URI with accept header content negotiated correctly
63    Given the request URI of "/requesttest/one/two.html"
64    And the accept header of "image/png;q=0.5,text/html"
65    When I create a request object
66    Then I should see a request URI of "/requesttest/one/two"
67    And I should see a negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.png.html,/requesttest/one/two.png,/requesttest/one/two"
68    And I should see a format negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.png,/requesttest/one/two"
69    And I should see a language negotiated URI of "/requesttest/one/two.html,/requesttest/one/two"
70   
71  Scenario: Have bare request URI with language accept header content negotiated correctly
72    Given the request URI of "/requesttest/one/two"
73    And the language accept header of "fr;q=0.5,en"
74    When I create a request object
75    Then I should see a request URI of "/requesttest/one/two"
76    And I should see a negotiated URI of "/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
77    And I should see a format negotiated URI of "/requesttest/one/two"
78    And I should see a language negotiated URI of "/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
79   
80  Scenario: Have extension request URI with language accept header content negotiated correctly
81    Given the request URI of "/requesttest/one/two.html"
82    And the language accept header of "fr;q=0.5,en"
83    When I create a request object
84    Then I should see a request URI of "/requesttest/one/two"
85    And I should see a negotiated URI of "/requesttest/one/two.html.en,/requesttest/one/two.html.fr,/requesttest/one/two.html,/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
86    And I should see a format negotiated URI of "/requesttest/one/two.html,/requesttest/one/two"
87    And I should see a language negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
88   
89  Scenario: Have bare request URI with accept and language header content negotiated correctly
90    Given the request URI of "/requesttest/one/two"
91    And the accept header of "image/png;q=0.5,text/html"
92    And the language accept header of "fr;q=0.5,en"
93    When I create a request object
94    Then I should see a request URI of "/requesttest/one/two"
95    And I should see a negotiated URI of "/requesttest/one/two.html.en,/requesttest/one/two.html.fr,/requesttest/one/two.html,/requesttest/one/two.png.en,/requesttest/one/two.png.fr,/requesttest/one/two.png,/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
96    And I should see a format negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.png,/requesttest/one/two"
97    And I should see a language negotiated URI of "/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
98   
99  Scenario: Have extension request URI with accept and language header content negotiated correctly
100    Given the request URI of "/requesttest/one/two.html"
101    And the accept header of "image/png;q=0.5,text/html"
102    And the language accept header of "fr;q=0.5,en"
103    When I create a request object
104    Then I should see a request URI of "/requesttest/one/two"
105    And I should see a negotiated URI of "/requesttest/one/two.html.en,/requesttest/one/two.html.fr,/requesttest/one/two.html,/requesttest/one/two.png.html,/requesttest/one/two.png.en,/requesttest/one/two.png.fr,/requesttest/one/two.png,/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
106    And I should see a format negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.png,/requesttest/one/two"
107    And I should see a language negotiated URI of "/requesttest/one/two.html,/requesttest/one/two.en,/requesttest/one/two.fr,/requesttest/one/two"
108   
109  Scenario: Have if match header
110    Given an if match header of '123123'
111    When I create a request object
112    Then I should see an if match header of "123123"
113    And if match should match "123123"
114   
115  Scenario: Have if match header in quotes
116    Given an if match header of '"123123"'
117    When I create a request object
118    Then I should see an if match header of "123123"
119    And if match should match "123123"
120   
121  Scenario: Have multiple if match headers in quotes
122    Given an if match header of '"123123","456456"'
123    When I create a request object
124    Then I should see an if match header of "123123,456456"
125    And if match should match "123123"
126    And if match should match "456456"
127   
128  Scenario: Have star if match header
129    Given an if match header of '*'
130    When I create a request object
131    Then I should see an if match header of "*"
132    And if match should match "123123"
133    And if match should match "123456"
134   
135  Scenario: Have if none match header
136    Given an if none match header of '123123'
137    When I create a request object
138    Then I should see an if none match header of "123123"
139    And if none match should match "123123"
140   
141  Scenario: Have multiple if none match headers in quotes
142    Given an if none match header of '"123123","456456"'
143    When I create a request object
144    Then I should see an if none match header of "123123,456456"
145    And if none match should match "123123"
146    And if none match should match "456456"
147 
148  Scenario: Have star if none match header
149    Given an if none match header of '*'
150    When I create a request object
151    Then I should see an if none match header of "*"
152    And if none match should not match "123123"
153    And if none match should not match "123456"
154   
155  Scenario: Load a non-existent resource
156    Given the request URI of "/three"
157    When I create a request object
158    And I load the resource
159    Then I should have a response of type "NoResource"
160   
161  Scenario: Load a resource
162    Given the request URI of "/requesttest/one"
163    When I create a request object
164    And I load the resource
165    Then I should have a response of type "NewResource"
166   
167  Scenario: Load a child resource
168    Given the request URI of "/requesttest/one/two"
169    When I create a request object
170    And I load the resource
171    Then I should have a response of type "ChildResource"
172   
173  Scenario: Load a resource with a regex match URI
174    Given the request URI of "/requesttest/three/something/four"
175    When I create a request object
176    And I load the resource
177    Then I should have a response of type "NewResource"
178 
179  Scenario: Load a non-existent resource with a new 404 resource class
180    Given the request URI of "/three"
181    And a 404 resource classname of "NewNoResource"
182    When I create a request object
183    And I load the resource
184    Then I should have a response of type "NewNoResource"
185 
186  Scenario: Resource data loading
187    Given the request URI of "/requesttest/one/two"
188    When I create a request object
189    Then I should see resource "namespace" metadata of "Tonic/Tests"
190    And I should see resource "class" metadata of "ChildResource"
191    And I should see resource "priority" metadata of "0"
192   
193  Scenario: Mounting in a namespace to a URI
194    Given the request URI of "/foo/bar/requesttest/one"
195    And a mounting of "Tonic/Tests" to "/foo/bar"
196    When I create a request object
197    And I load the resource
198    Then I should have a response of type "NewResource"
Note: See TracBrowser for help on using the repository browser.