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