RequestHelperTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\Bundle\FrameworkBundle\Tests\Templating\Helper;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\RequestStack;
  15. class RequestHelperTest extends TestCase
  16. {
  17. protected $requestStack;
  18. protected function setUp()
  19. {
  20. $this->requestStack = new RequestStack();
  21. $request = new Request();
  22. $request->initialize(array('foobar' => 'bar'));
  23. $this->requestStack->push($request);
  24. }
  25. public function testGetParameter()
  26. {
  27. $helper = new RequestHelper($this->requestStack);
  28. $this->assertEquals('bar', $helper->getParameter('foobar'));
  29. $this->assertEquals('foo', $helper->getParameter('bar', 'foo'));
  30. $this->assertNull($helper->getParameter('foo'));
  31. }
  32. public function testGetLocale()
  33. {
  34. $helper = new RequestHelper($this->requestStack);
  35. $this->assertEquals('en', $helper->getLocale());
  36. }
  37. public function testGetName()
  38. {
  39. $helper = new RequestHelper($this->requestStack);
  40. $this->assertEquals('request', $helper->getName());
  41. }
  42. }