You are here

public function RequestTest::testHostValidity in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/http-foundation/Tests/RequestTest.php \Symfony\Component\HttpFoundation\Tests\RequestTest::testHostValidity()

@dataProvider getHostValidities

File

vendor/symfony/http-foundation/Tests/RequestTest.php, line 1838

Class

RequestTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testHostValidity($host, $isValid, $expectedHost = null, $expectedPort = null) {
  $request = Request::create('/');
  $request->headers
    ->set('host', $host);
  if ($isValid) {
    $this
      ->assertSame($expectedHost ?: $host, $request
      ->getHost());
    if ($expectedPort) {
      $this
        ->assertSame($expectedPort, $request
        ->getPort());
    }
  }
  else {
    $this
      ->setExpectedException('UnexpectedValueException', 'Invalid Host');
    $request
      ->getHost();
  }
}