Exemple #1
0
 public function matchRoutines(Request $request, &$params = array())
 {
     foreach ($this->routines as $routine) {
         if ($routine instanceof ProxyableWhen && !$request->routineCall('when', $request->method, $routine, $params)) {
             return false;
         }
     }
     return true;
 }
 /** Checks if this route matches a request */
 public function match(Request $request, &$params = array())
 {
     if ($request->method !== $this->method && $this->method !== 'ANY' || 0 === stripos($request->method, '__')) {
         return false;
     }
     foreach ($this->routines as $routine) {
         if ($routine instanceof ProxyableWhen && !$request->routineCall('when', $request->method, $routine, $params)) {
             return false;
         }
     }
     $matchUri = preg_replace('#(\\.\\w+)*$#', '', $request->uri);
     if (!preg_match($this->regexForMatch, $matchUri, $params)) {
         return false;
     }
     if (count($params) > 1 && false !== stripos(end($params), '/')) {
         $lastParam = array_pop($params);
         $params = array_merge($params, explode('/', $lastParam));
     }
     return true;
 }
Exemple #3
0
 /**
  * @covers       Respect\Rest\Request::response
  * @dataProvider providerForParamSyncedRoutines
  */
 public function testParamSyncedRoutinesShouldAllReferenceTheSameValuesByTheirNames($checkers, array $params)
 {
     $request = new Request('GET', '/version');
     $request->params = $params;
     $route = $this->getMockForRoute('GET', '/version', 'MySoftwareName', 'GET', $params);
     foreach ($checkers as $checker) {
         $route->appendRoutine($this->getMockForProxyableRoutine($route, 'By', $checker));
     }
     $request->route = $route;
     $response = $request->response();
     $this->assertEquals('MySoftwareName', $response);
 }