Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • Symfony\Component\Yaml\Tests\A
  • Symfony\Component\Yaml\Tests\B
  • Symfony\Component\Yaml\Tests\DumperTest
  • Symfony\Component\Yaml\Tests\InlineTest
  • Symfony\Component\Yaml\Tests\ParseExceptionTest
  • Symfony\Component\Yaml\Tests\ParserTest
  • Symfony\Component\Yaml\Tests\YamlTest
  • Overview
  • Namespace
  • Function
  • Tree
  1: <?php
  2: 
  3: /*
  4:  * This file is part of the Symfony package.
  5:  *
  6:  * (c) Fabien Potencier <fabien@symfony.com>
  7:  *
  8:  * For the full copyright and license information, please view the LICENSE
  9:  * file that was distributed with this source code.
 10:  */
 11: 
 12: namespace Symfony\Component\HttpFoundation\Tests;
 13: 
 14: use Symfony\Component\HttpFoundation\Request;
 15: use Symfony\Component\HttpFoundation\StreamedResponse;
 16: 
 17: class StreamedResponseTest extends \PHPUnit_Framework_TestCase
 18: {
 19:     public function testConstructor()
 20:     {
 21:         $response = new StreamedResponse(function () { echo 'foo'; }, 404, array('Content-Type' => 'text/plain'));
 22: 
 23:         $this->assertEquals(404, $response->getStatusCode());
 24:         $this->assertEquals('text/plain', $response->headers->get('Content-Type'));
 25:     }
 26: 
 27:     public function testPrepareWith11Protocol()
 28:     {
 29:         $response = new StreamedResponse(function () { echo 'foo'; });
 30:         $request = Request::create('/');
 31:         $request->server->set('SERVER_PROTOCOL', 'HTTP/1.1');
 32: 
 33:         $response->prepare($request);
 34: 
 35:         $this->assertEquals('1.1', $response->getProtocolVersion());
 36:         $this->assertNotEquals('chunked', $response->headers->get('Transfer-Encoding'), 'Apache assumes responses with a Transfer-Encoding header set to chunked to already be encoded.');
 37:     }
 38: 
 39:     public function testPrepareWith10Protocol()
 40:     {
 41:         $response = new StreamedResponse(function () { echo 'foo'; });
 42:         $request = Request::create('/');
 43:         $request->server->set('SERVER_PROTOCOL', 'HTTP/1.0');
 44: 
 45:         $response->prepare($request);
 46: 
 47:         $this->assertEquals('1.0', $response->getProtocolVersion());
 48:         $this->assertNull($response->headers->get('Transfer-Encoding'));
 49:     }
 50: 
 51:     public function testPrepareWithHeadRequest()
 52:     {
 53:         $response = new StreamedResponse(function () { echo 'foo'; });
 54:         $request = Request::create('/', 'HEAD');
 55: 
 56:         $response->prepare($request);
 57:     }
 58: 
 59:     public function testPrepareWithCacheHeaders()
 60:     {
 61:         $response = new StreamedResponse(function () { echo 'foo'; }, 200, array('Cache-Control' => 'max-age=600, public'));
 62:         $request = Request::create('/', 'GET');
 63: 
 64:         $response->prepare($request);
 65:         $this->assertEquals('max-age=600, public', $response->headers->get('Cache-Control'));
 66:     }
 67: 
 68:     public function testSendContent()
 69:     {
 70:         $called = 0;
 71: 
 72:         $response = new StreamedResponse(function () use (&$called) { ++$called; });
 73: 
 74:         $response->sendContent();
 75:         $this->assertEquals(1, $called);
 76: 
 77:         $response->sendContent();
 78:         $this->assertEquals(1, $called);
 79:     }
 80: 
 81:     /**
 82:      * @expectedException \LogicException
 83:      */
 84:     public function testSendContentWithNonCallable()
 85:     {
 86:         $response = new StreamedResponse(null);
 87:         $response->sendContent();
 88:     }
 89: 
 90:     /**
 91:      * @expectedException \LogicException
 92:      */
 93:     public function testSetCallbackNonCallable()
 94:     {
 95:         $response = new StreamedResponse(null);
 96:         $response->setCallback(null);
 97:     }
 98: 
 99:     /**
100:      * @expectedException \LogicException
101:      */
102:     public function testSetContent()
103:     {
104:         $response = new StreamedResponse(function () { echo 'foo'; });
105:         $response->setContent('foo');
106:     }
107: 
108:     public function testGetContent()
109:     {
110:         $response = new StreamedResponse(function () { echo 'foo'; });
111:         $this->assertFalse($response->getContent());
112:     }
113: 
114:     public function testCreate()
115:     {
116:         $response = StreamedResponse::create(function () {}, 204);
117: 
118:         $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
119:         $this->assertEquals(204, $response->getStatusCode());
120:     }
121: }
122: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen