You are here

public function HttpFoundationFactoryTest::testCreateRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php \Symfony\Bridge\PsrHttpMessage\Tests\Factory\HttpFoundationFactoryTest::testCreateRequest()

File

vendor/symfony/psr-http-message-bridge/Tests/Factory/HttpFoundationFactoryTest.php, line 35

Class

HttpFoundationFactoryTest
@author Kévin Dunglas <dunglas@gmail.com>

Namespace

Symfony\Bridge\PsrHttpMessage\Tests\Factory

Code

public function testCreateRequest() {
  $stdClass = new \stdClass();
  $serverRequest = new ServerRequest('1.1', array(
    'X-Dunglas-API-Platform' => '1.0',
    'X-data' => array(
      'a',
      'b',
    ),
  ), new Stream('The body'), '/about/kevin', 'GET', 'http://les-tilleuls.coop/about/kevin', array(
    'country' => 'France',
  ), array(
    'city' => 'Lille',
  ), array(
    'url' => 'http://les-tilleuls.coop',
  ), array(
    'doc1' => $this
      ->createUploadedFile('Doc 1', UPLOAD_ERR_OK, 'doc1.txt', 'text/plain'),
    'nested' => array(
      'docs' => array(
        $this
          ->createUploadedFile('Doc 2', UPLOAD_ERR_OK, 'doc2.txt', 'text/plain'),
        $this
          ->createUploadedFile('Doc 3', UPLOAD_ERR_OK, 'doc3.txt', 'text/plain'),
      ),
    ),
  ), array(
    'url' => 'http://dunglas.fr',
  ), array(
    'custom' => $stdClass,
  ));
  $symfonyRequest = $this->factory
    ->createRequest($serverRequest);
  $this
    ->assertEquals('http://les-tilleuls.coop', $symfonyRequest->query
    ->get('url'));
  $this
    ->assertEquals('doc1.txt', $symfonyRequest->files
    ->get('doc1')
    ->getClientOriginalName());
  $this
    ->assertEquals('doc2.txt', $symfonyRequest->files
    ->get('nested[docs][0]', null, true)
    ->getClientOriginalName());
  $this
    ->assertEquals('doc3.txt', $symfonyRequest->files
    ->get('nested[docs][1]', null, true)
    ->getClientOriginalName());
  $this
    ->assertEquals('http://dunglas.fr', $symfonyRequest->request
    ->get('url'));
  $this
    ->assertEquals($stdClass, $symfonyRequest->attributes
    ->get('custom'));
  $this
    ->assertEquals('Lille', $symfonyRequest->cookies
    ->get('city'));
  $this
    ->assertEquals('France', $symfonyRequest->server
    ->get('country'));
  $this
    ->assertEquals('The body', $symfonyRequest
    ->getContent());
  $this
    ->assertEquals('1.0', $symfonyRequest->headers
    ->get('X-Dunglas-API-Platform'));
  $this
    ->assertEquals(array(
    'a',
    'b',
  ), $symfonyRequest->headers
    ->get('X-data', null, false));
}