当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::matches方法代码示例

本文整理汇总了PHP中Route::matches方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::matches方法的具体用法?PHP Route::matches怎么用?PHP Route::matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Route的用法示例。


在下文中一共展示了Route::matches方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRequiredParametersAreNeeded

 /**
  * This tests that routes with required parameters will not match uris without them present
  * 
  * @test
  * @covers Route
  */
 function testRequiredParametersAreNeeded()
 {
     $route = new Route('admin(/<controller>(/<action>(/<id>)))');
     $this->assertFalse($route->matches(''));
     $matches = $route->matches('admin');
     $this->assertType('array', $matches);
     $matches = $route->matches('admin/users/add');
     $this->assertType('array', $matches);
     $this->assertSame(2, count($matches));
     $this->assertArrayHasKey('controller', $matches);
     $this->assertArrayHasKey('action', $matches);
 }
开发者ID:pcraciunoiu,项目名称:unittest,代码行数:18,代码来源:RouteTest.php

示例2: matches

 public function matches($data)
 {
     if (parent::matches($data)) {
         if ($data->request->method() === $this->method) {
             return true;
         } else {
             $data->available_methods[] = $this->method;
         }
     }
     return false;
 }
开发者ID:bdusell,项目名称:jitsu-app,代码行数:11,代码来源:Endpoint.php

示例3: getParametersName

 private static function getParametersName()
 {
     $arr = [];
     preg_match_all('#{[\\w]+?}#', self::$route, $matches);
     if (count($matches) == 0) {
         return self::$matches = [];
     }
     foreach ($matches[0] as $match) {
         $arr[] = str_replace(' ', '', trim(trim($match, '{'), '}'));
     }
     return self::$matches = $arr;
 }
开发者ID:phumaster,项目名称:fw,代码行数:12,代码来源:Route.php

示例4: test_required_parameters_are_needed

 /**
  * This tests that routes with required parameters will not match uris without them present
  *
  * @dataProvider provider_required_parameters_are_needed
  *
  * @test
  * @covers Route::matches
  */
 public function test_required_parameters_are_needed($uri, $matches_route1, $matches_route2)
 {
     $route = new Route($uri);
     // Mock a request class that will return empty uri
     $request = $this->get_request_mock('');
     $this->assertFalse($route->matches($request));
     // Mock a request class that will return route1
     $request = $this->get_request_mock($matches_route1);
     $matches = $route->matches($request);
     $this->assertInternalType('array', $matches);
     // Mock a request class that will return route2 uri
     $request = $this->get_request_mock($matches_route2);
     $matches = $route->matches($request);
     $this->assertInternalType('array', $matches);
     // $this->assertSame(5, count($matches));
     $this->assertArrayHasKey('controller', $matches);
     $this->assertArrayHasKey('action', $matches);
 }
开发者ID:robert-kampas,项目名称:games-collection-manager,代码行数:26,代码来源:RouteTest.php

示例5: addStaticRoute

 /**
  *
  */
 private function addStaticRoute($routeData, Route $route)
 {
     $handler = $route->getHandler();
     $routeStr = $routeData[0];
     foreach ($route->getMethod() as $method) {
         if (isset($this->staticRoutes[$method][$routeStr])) {
             throw new Exception("Cannot register two routes matching \"{$routeStr}\" for method \"{$method}\"");
         }
         if (isset($this->dynamicRoutes[$method])) {
             foreach ($this->dynamicRoutes[$method] as $route) {
                 if ($route->matches($routeStr)) {
                     throw new Exception("Static route \"{$routeStr}\" is shadowed by previously defined variable route \"{$route->getPath()}\" for method \"{$method}\"");
                 }
             }
         }
         $this->staticRoutes[$method][$routeStr] = $handler;
     }
 }
开发者ID:wispira,项目名称:framework,代码行数:21,代码来源:Router.php

示例6: test_required_parameters_are_needed

 /**
  * This tests that routes with required parameters will not match uris without them present
  *
  * @dataProvider provider_required_parameters_are_needed
  *
  * @test
  * @covers Route::matches
  */
 public function test_required_parameters_are_needed($uri, $matches_route1, $matches_route2)
 {
     $route = new Route($uri);
     $this->assertFalse($route->matches(''));
     $matches = $route->matches($matches_route1);
     $this->assertInternalType('array', $matches);
     $matches = $route->matches($matches_route2);
     $this->assertInternalType('array', $matches);
     // $this->assertSame(5, count($matches));
     $this->assertArrayHasKey('controller', $matches);
     $this->assertArrayHasKey('action', $matches);
 }
开发者ID:laiello,项目名称:ko3,代码行数:20,代码来源:RouteTest.php

示例7: testRouteMatchesResourceWithUnreservedMarks

 public function testRouteMatchesResourceWithUnreservedMarks()
 {
     $marks = "-_.!~*'()";
     $resource = 'marks/' . $marks;
     $route = new Route('/marks/:marks', function () {
     });
     $result = $route->matches($resource);
     $this->assertTrue($result);
     $this->assertEquals($route->params(), array('marks' => $marks));
 }
开发者ID:Jud,项目名称:Slim,代码行数:10,代码来源:RouteTest.php

示例8: test_required_parameters_are_needed

 /**
  * This tests that routes with required parameters will not match uris without them present
  *
  * @dataProvider provider_required_parameters_are_needed
  *
  * @test
  * @covers Route::matches
  */
 public function test_required_parameters_are_needed($uri, $matches_route1, $matches_route2)
 {
     $route = new Route($uri);
     // Mock a request class that will return empty uri
     $request = $this->getMock('Request', array('uri'), array(''));
     $request->expects($this->any())->method('uri')->will($this->returnValue(''));
     $this->assertFalse($route->matches($request));
     // Mock a request class that will return route1
     $request = $this->getMock('Request', array('uri'), array($matches_route1));
     $request->expects($this->any())->method('uri')->will($this->returnValue($matches_route1));
     $matches = $route->matches($request);
     $this->assertInternalType('array', $matches);
     // Mock a request class that will return route2 uri
     $request = $this->getMock('Request', array('uri'), array($matches_route2));
     $request->expects($this->any())->method('uri')->will($this->returnValue($matches_route2));
     $matches = $route->matches($request);
     $this->assertInternalType('array', $matches);
     // $this->assertSame(5, count($matches));
     $this->assertArrayHasKey('controller', $matches);
     $this->assertArrayHasKey('action', $matches);
 }
开发者ID:ortodesign,项目名称:cms,代码行数:29,代码来源:routetest.php

示例9: testRouteDoesNotMatchResourceWithConditions

 /**
  * Route does not match URI with conditions
  */
 public function testRouteDoesNotMatchResourceWithConditions()
 {
     $resource = 'hello/Josh/and/John';
     $route = new Route('/hello/:first/and/:second', function () {
     });
     $route->conditions(array('first' => '[a-z]{3,}'));
     $result = $route->matches($resource);
     $this->assertFalse($result);
     $this->assertEquals($route->params(), array());
 }
开发者ID:kolanos,项目名称:Slim,代码行数:13,代码来源:RouteTest.php

示例10: testMatchesWithoutHttpMethodShouldReturnFalseForNonMatchingPaths

 public function testMatchesWithoutHttpMethodShouldReturnFalseForNonMatchingPaths()
 {
     $route = new Route('GET', '/test', function () {
     });
     $request = Request::create(false, 'localhost', '/unknown-route', null, 'POST');
     $this->assertFalse($route->matches($request));
     $this->assertFalse($route->matchesWithoutHttpMethod($request));
 }
开发者ID:holger,项目名称:yoshi,代码行数:8,代码来源:RouteTest.php


注:本文中的Route::matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。