RequestTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Component\BrowserKit\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\BrowserKit\Request;
  13. class RequestTest extends TestCase
  14. {
  15. public function testGetUri()
  16. {
  17. $request = new Request('http://www.example.com/', 'get');
  18. $this->assertEquals('http://www.example.com/', $request->getUri(), '->getUri() returns the URI of the request');
  19. }
  20. public function testGetMethod()
  21. {
  22. $request = new Request('http://www.example.com/', 'get');
  23. $this->assertEquals('get', $request->getMethod(), '->getMethod() returns the method of the request');
  24. }
  25. public function testGetParameters()
  26. {
  27. $request = new Request('http://www.example.com/', 'get', ['foo' => 'bar']);
  28. $this->assertEquals(['foo' => 'bar'], $request->getParameters(), '->getParameters() returns the parameters of the request');
  29. }
  30. public function testGetFiles()
  31. {
  32. $request = new Request('http://www.example.com/', 'get', [], ['foo' => 'bar']);
  33. $this->assertEquals(['foo' => 'bar'], $request->getFiles(), '->getFiles() returns the uploaded files of the request');
  34. }
  35. public function testGetCookies()
  36. {
  37. $request = new Request('http://www.example.com/', 'get', [], [], ['foo' => 'bar']);
  38. $this->assertEquals(['foo' => 'bar'], $request->getCookies(), '->getCookies() returns the cookies of the request');
  39. }
  40. public function testGetServer()
  41. {
  42. $request = new Request('http://www.example.com/', 'get', [], [], [], ['foo' => 'bar']);
  43. $this->assertEquals(['foo' => 'bar'], $request->getServer(), '->getServer() returns the server parameters of the request');
  44. }
  45. }