[6351] | 1 | <?php |
---|
| 2 | |
---|
| 3 | $steps->Given('/^the request URI of "([^"]*)"$/', function($world, $arg1) { |
---|
| 4 | $world->config['uri'] = $arg1; |
---|
| 5 | }); |
---|
| 6 | |
---|
| 7 | $steps->Given('/^the request method of "([^"]*)"$/', function($world, $arg1) { |
---|
| 8 | $world->config['method'] = $arg1; |
---|
| 9 | }); |
---|
| 10 | |
---|
| 11 | $steps->Given('/^the request data of "([^"]*)"$/', function($world, $arg1) { |
---|
| 12 | $world->config['data'] = $arg1; |
---|
| 13 | }); |
---|
| 14 | |
---|
| 15 | $steps->Given('/^the accept header of "([^"]*)"$/', function($world, $arg1) { |
---|
| 16 | $world->config['accept'] = $arg1; |
---|
| 17 | }); |
---|
| 18 | |
---|
| 19 | $steps->Given('/^the language accept header of "([^"]*)"$/', function($world, $arg1) { |
---|
| 20 | $world->config['acceptLang'] = $arg1; |
---|
| 21 | }); |
---|
| 22 | |
---|
| 23 | $steps->Given('/^an if match header of \'([^\']*)\'$/', function($world, $arg1) { |
---|
| 24 | $world->config['ifMatch'] = $arg1; |
---|
| 25 | }); |
---|
| 26 | |
---|
| 27 | $steps->Given('/^an if none match header of \'([^\']*)\'$/', function($world, $arg1) { |
---|
| 28 | $world->config['ifNoneMatch'] = $arg1; |
---|
| 29 | }); |
---|
| 30 | |
---|
| 31 | $steps->Given('/^a 404 resource classname of "([^"]*)"$/', function($world, $arg1) { |
---|
| 32 | $world->config['404'] = $arg1; |
---|
| 33 | }); |
---|
| 34 | |
---|
| 35 | $steps->Given('/^a mounting of "([^"]*)" to "([^"]*)"$/', function($world, $arg1, $arg2) { |
---|
| 36 | $world->config['mount'][$arg1] = $arg2; |
---|
| 37 | }); |
---|
| 38 | |
---|
| 39 | $steps->Given('/^the querystring is "([^"]*)"$/', function($world, $arg1) { |
---|
| 40 | $_SERVER['QUERY_STRING'] = $arg1; |
---|
| 41 | }); |
---|
| 42 | |
---|
| 43 | $steps->When('/^I create a request object$/', function($world) { |
---|
| 44 | $world->request = new Request($world->config); |
---|
| 45 | }); |
---|
| 46 | |
---|
| 47 | $steps->When('/^I load the resource$/', function($world) { |
---|
| 48 | $world->resource = $world->request->loadResource(); |
---|
| 49 | }); |
---|
| 50 | |
---|
| 51 | $steps->Then('/^I should see a request URI of "([^"]*)"$/', function($world, $arg1) { |
---|
| 52 | if ($world->request->uri != $arg1) throw new Exception; |
---|
| 53 | }); |
---|
| 54 | |
---|
| 55 | $steps->Then('/^I should see a request method of "([^"]*)"$/', function($world, $arg1) { |
---|
| 56 | if ($world->request->method != $arg1) throw new Exception; |
---|
| 57 | }); |
---|
| 58 | |
---|
| 59 | $steps->Then('/^I should see the request data "([^"]*)"$/', function($world, $arg1) { |
---|
| 60 | if ($world->request->data != $arg1) throw new Exception; |
---|
| 61 | }); |
---|
| 62 | |
---|
| 63 | $steps->Then('/^I should see a negotiated URI of "([^"]*)"$/', function($world, $arg1) { |
---|
| 64 | if ($world->request->negotiatedUris != explode(',', $arg1)) throw new Exception; |
---|
| 65 | }); |
---|
| 66 | |
---|
| 67 | $steps->Then('/^I should see a format negotiated URI of "([^"]*)"$/', function($world, $arg1) { |
---|
| 68 | if ($world->request->formatNegotiatedUris != explode(',', $arg1)) throw new Exception; |
---|
| 69 | }); |
---|
| 70 | |
---|
| 71 | $steps->Then('/^I should see a language negotiated URI of "([^"]*)"$/', function($world, $arg1) { |
---|
| 72 | if ($world->request->languageNegotiatedUris != explode(',', $arg1)) throw new Exception; |
---|
| 73 | }); |
---|
| 74 | |
---|
| 75 | $steps->Then('/^I should have a response of type "([^"]*)"$/', function($world, $arg1) { |
---|
| 76 | if (get_class($world->resource) != $arg1) throw new Exception; |
---|
| 77 | }); |
---|
| 78 | |
---|
| 79 | $steps->Then('/^I should see an if match header of "([^"]*)"$/', function($world, $arg1) { |
---|
| 80 | if ($world->request->ifMatch != explode(',', $arg1)) throw new Exception; |
---|
| 81 | }); |
---|
| 82 | |
---|
| 83 | $steps->Then('/^if match should match "([^"]*)"$/', function($world, $arg1) { |
---|
| 84 | if (!$world->request->ifMatch($arg1)) throw new Exception; |
---|
| 85 | }); |
---|
| 86 | |
---|
| 87 | $steps->Then('/^I should see an if none match header of "([^"]*)"$/', function($world, $arg1) { |
---|
| 88 | if ($world->request->ifNoneMatch != explode(',', $arg1)) throw new Exception; |
---|
| 89 | }); |
---|
| 90 | |
---|
| 91 | $steps->Then('/^if none match should match "([^"]*)"$/', function($world, $arg1) { |
---|
| 92 | if (!$world->request->ifNoneMatch($arg1)) throw new Exception; |
---|
| 93 | }); |
---|
| 94 | |
---|
| 95 | $steps->Then('/^if none match should not match "([^"]*)"$/', function($world, $arg1) { |
---|
| 96 | if ($world->request->ifNoneMatch($arg1)) throw new Exception; |
---|
| 97 | }); |
---|
| 98 | |
---|
| 99 | $steps->Then('/^I should see resource "([^"]*)" metadata of "([^"]*)"$/', function($world, $arg1, $arg2) { |
---|
| 100 | if ($world->request->resources[$world->request->uri][$arg1] != $arg2) throw new Exception; |
---|
| 101 | }); |
---|
| 102 | |
---|
| 103 | $steps->Then('/^I should see a querystring of "([^"]*)"$/', function($world, $arg1) { |
---|
| 104 | if ($world->request->data != '?'.$arg1) throw new Exception("$arg1 does not equal {$world->request->data}"); |
---|
| 105 | }); |
---|
| 106 | |
---|