HttpFoundationRequestHandlerTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\Form\Tests\Extension\HttpFoundation;
  11. use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
  12. use Symfony\Component\Form\Tests\AbstractRequestHandlerTest;
  13. use Symfony\Component\HttpFoundation\File\UploadedFile;
  14. use Symfony\Component\HttpFoundation\Request;
  15. /**
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest
  19. {
  20. /**
  21. * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
  22. */
  23. public function testRequestShouldNotBeNull()
  24. {
  25. $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'));
  26. }
  27. /**
  28. * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
  29. */
  30. public function testRequestShouldBeInstanceOfRequest()
  31. {
  32. $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'), new \stdClass());
  33. }
  34. protected function setRequestData($method, $data, $files = array())
  35. {
  36. $this->request = Request::create('http://localhost', $method, $data, array(), $files);
  37. }
  38. protected function getRequestHandler()
  39. {
  40. return new HttpFoundationRequestHandler($this->serverParams);
  41. }
  42. protected function getMockFile($suffix = '')
  43. {
  44. return new UploadedFile(__DIR__.'/../../Fixtures/foo'.$suffix, 'foo'.$suffix);
  45. }
  46. protected function getInvalidFile()
  47. {
  48. return 'file:///etc/passwd';
  49. }
  50. }