Scalr\Tests\Api\Rest\Routing\RouteTest::testMatches PHP Method

testMatches() public method

public testMatches ( )
    public function testMatches()
    {
        $route = $this->getRouteFixture();
        $this->assertFalse($route->matches('/api'));
        $this->assertFalse($route->matches('/api/foo'));
        $this->assertFalse($route->matches('/api/path/:id'));
        $this->assertTrue($route->matches('/api/path/123'));
        $this->assertCount(1, $route->getParams());
        $this->assertArrayHas(123, 'id', $route->getParams());
        $this->assertTrue($route->matches('/api/path/167'));
        $this->assertCount(1, $route->getParams());
        $this->assertArrayHas(167, 'id', $route->getParams());
        $this->assertFalse($route->matches('/api/path/892/23'));
        $this->assertCount(0, $route->getParams());
        $route2 = new Route('/api/path/(:namepath)+', function () {
        }, ['namepath' => '[a-z/-]+']);
        $route2->setMethods([Request::METHOD_GET]);
        $pathName = 'news/recent/open-stack-journey';
        $this->assertTrue($route2->matches('/api/path/' . $pathName));
        $this->assertArrayHas($pathName, 'namepath', $route2->getParams());
        $pathName = '_0news/recent';
        $this->assertFalse($route2->matches('/api/path/' . $pathName));
    }