Repository: symfony/symfony
File: src/Symfony/Component/Routing/Tests/RequestContextTest.php (PHP)

Code before:
                'foo' => 'bar',
            ]
        );

        $this->assertEquals('foo', $requestContext->getBaseUrl());
        $this->assertEquals('POST', $requestContext->getMethod());
        $this->assertEquals('foo.bar', $requestContext->getHost());
        $this->assertEquals('https', $requestContext->getScheme());
        $this->assertSame(8080, $requestContext->getHttpPort());
        $this->assertSame(444, $requestContext->getHttpsPort());
        $this->assertEquals('/baz', $requestContext->getPathInfo());
        $this->assertEquals('bar=foobar', $requestContext->getQueryString());
        $this->assertEquals(['foo' => 'bar'], $requestContext->getParameters());
    }

    public function testConstructParametersBcLayer()
    {
        $requestContext = new class() extends RequestContext {
            public function __construct()
            {
                $this->setParameters(['foo' => 'bar']);
                parent::__construct();
            }
        };

        $this->assertEquals(['foo' => 'bar'], $requestContext->getParameters());
    }

    public function testFromUriWithBaseUrl()
    {
        $requestContext = RequestContext::fromUri('https://test.com:444/index.php');

        $this->assertSame('GET', $requestContext->getMethod());
        $this->assertSame('https', $requestContext->getScheme());
        $this->assertSame('test.com', $requestContext->getHost());
        $this->assertSame('/index.php', $requestContext->getBaseUrl());
        $this->assertSame('/', $requestContext->getPathInfo());
        $this->assertSame(80, $requestContext->getHttpPort());
        $this->assertSame(444, $requestContext->getHttpsPort());
    }

    public function testFromUriWithTrailingSlash()
    {
        $requestContext = RequestContext::fromUri('http://test.com:8080/');

        $this->assertSame('http', $requestContext->getScheme());
        $this->assertSame('test.com', $requestContext->getHost());
        $this->assertSame(8080, $requestContext->getHttpPort());
        $this->assertSame(443, $requestContext->getHttpsPort());
        $this->assertSame('', $requestContext->getBaseUrl());
        $this->assertSame('/', $requestContext->getPathInfo());

Review comment (suggestion):
```suggestion
        $this->assertSame(['foo' => 'bar'], $requestContext->getParameters());
```

Code after:
                'foo' => 'bar',
            ]
        );

        $this->assertEquals('foo', $requestContext->getBaseUrl());
        $this->assertEquals('POST', $requestContext->getMethod());
        $this->assertEquals('foo.bar', $requestContext->getHost());
        $this->assertEquals('https', $requestContext->getScheme());
        $this->assertSame(8080, $requestContext->getHttpPort());
        $this->assertSame(444, $requestContext->getHttpsPort());
        $this->assertEquals('/baz', $requestContext->getPathInfo());
        $this->assertEquals('bar=foobar', $requestContext->getQueryString());
        $this->assertSame(['foo' => 'bar'], $requestContext->getParameters());
    }

    public function testConstructParametersBcLayer()
    {
        $requestContext = new class() extends RequestContext {
            public function __construct()
            {
                $this->setParameters(['foo' => 'bar']);
                parent::__construct();
            }
        };

        $this->assertSame(['foo' => 'bar'], $requestContext->getParameters());
    }

    public function testFromUriWithBaseUrl()
    {
        $requestContext = RequestContext::fromUri('https://test.com:444/index.php');

        $this->assertSame('GET', $requestContext->getMethod());
        $this->assertSame('https', $requestContext->getScheme());
        $this->assertSame('test.com', $requestContext->getHost());
        $this->assertSame('/index.php', $requestContext->getBaseUrl());
        $this->assertSame('/', $requestContext->getPathInfo());
        $this->assertSame(80, $requestContext->getHttpPort());
        $this->assertSame(444, $requestContext->getHttpsPort());
    }

    public function testFromUriWithTrailingSlash()
    {
        $requestContext = RequestContext::fromUri('http://test.com:8080/');

        $this->assertSame('http', $requestContext->getScheme());
        $this->assertSame('test.com', $requestContext->getHost());
        $this->assertSame(8080, $requestContext->getHttpPort());
        $this->assertSame(443, $requestContext->getHttpsPort());
        $this->assertSame('', $requestContext->getBaseUrl());
        $this->assertSame('/', $requestContext->getPathInfo());