You are here

public function RequestContextTest::testFromRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Tests/RequestContextTest.php \Symfony\Component\Routing\Tests\RequestContextTest::testFromRequest()

File

vendor/symfony/routing/Tests/RequestContextTest.php, line 42

Class

RequestContextTest

Namespace

Symfony\Component\Routing\Tests

Code

public function testFromRequest() {
  $request = Request::create('https://test.com:444/foo?bar=baz');
  $requestContext = new RequestContext();
  $requestContext
    ->setHttpPort(123);
  $requestContext
    ->fromRequest($request);
  $this
    ->assertEquals('', $requestContext
    ->getBaseUrl());
  $this
    ->assertEquals('GET', $requestContext
    ->getMethod());
  $this
    ->assertEquals('test.com', $requestContext
    ->getHost());
  $this
    ->assertEquals('https', $requestContext
    ->getScheme());
  $this
    ->assertEquals('/foo', $requestContext
    ->getPathInfo());
  $this
    ->assertEquals('bar=baz', $requestContext
    ->getQueryString());
  $this
    ->assertSame(123, $requestContext
    ->getHttpPort());
  $this
    ->assertSame(444, $requestContext
    ->getHttpsPort());
  $request = Request::create('http://test.com:8080/foo?bar=baz');
  $requestContext = new RequestContext();
  $requestContext
    ->setHttpsPort(567);
  $requestContext
    ->fromRequest($request);
  $this
    ->assertSame(8080, $requestContext
    ->getHttpPort());
  $this
    ->assertSame(567, $requestContext
    ->getHttpsPort());
}