ResponseTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Components\BrowserKit;
  11. use Symfony\Components\BrowserKit\Response;
  12. class ResponseTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testGetUri()
  15. {
  16. $response = new Response('foo');
  17. $this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response');
  18. }
  19. public function testGetStatus()
  20. {
  21. $response = new Response('foo', 304);
  22. $this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response');
  23. }
  24. public function testGetHeaders()
  25. {
  26. $response = new Response('foo', 304, array('foo' => 'bar'));
  27. $this->assertEquals(array('foo' => 'bar'), $response->getHeaders(), '->getHeaders() returns the headers of the response');
  28. }
  29. public function testGetHeader()
  30. {
  31. $response = new Response('foo', 304, array('Content-Type' => 'text/html'));
  32. $this->assertEquals('text/html', $response->getHeader('Content-Type'), '->getHeader() returns a header of the response');
  33. $this->assertEquals('text/html', $response->getHeader('content-type'), '->getHeader() returns a header of the response');
  34. $this->assertEquals('text/html', $response->getHeader('content_type'), '->getHeader() returns a header of the response');
  35. $this->assertNull($response->getHeader('foo'), '->getHeader() returns null if the header is not defined');
  36. }
  37. public function testGetCookies()
  38. {
  39. $response = new Response('foo', 304, array(), array('foo' => 'bar'));
  40. $this->assertEquals(array('foo' => 'bar'), $response->getCookies(), '->getCookies() returns the cookies of the response');
  41. }
  42. }