ControllerTest.php 1.6 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\Bridge\PsrHttpMessage\Tests\Functional;
  11. use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Kernel;
  12. use Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\App\Kernel44;
  13. use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  14. use Symfony\Component\HttpKernel\Kernel as SymfonyKernel;
  15. /**
  16. * @author Alexander M. Turek <me@derrabus.de>
  17. */
  18. final class ControllerTest extends WebTestCase
  19. {
  20. public function testServerRequestAction()
  21. {
  22. $client = self::createClient();
  23. $crawler = $client->request('GET', '/server-request');
  24. self::assertResponseStatusCodeSame(200);
  25. self::assertSame('GET', $crawler->text());
  26. }
  27. public function testRequestAction()
  28. {
  29. $client = self::createClient();
  30. $crawler = $client->request('POST', '/request', [], [], [], 'some content');
  31. self::assertResponseStatusCodeSame(403);
  32. self::assertSame('POST some content', $crawler->text());
  33. }
  34. public function testMessageAction()
  35. {
  36. $client = self::createClient();
  37. $crawler = $client->request('PUT', '/message', [], [], ['HTTP_X_MY_HEADER' => 'some content']);
  38. self::assertResponseStatusCodeSame(422);
  39. self::assertSame('some content', $crawler->text());
  40. }
  41. protected static function getKernelClass(): string
  42. {
  43. return SymfonyKernel::VERSION_ID >= 50200 ? Kernel::class : Kernel44::class;
  44. }
  45. }