截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ControllerTest.php 1.4KB

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