ResponseIsUnprocessable.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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\HttpFoundation\Test\Constraint;
  11. use PHPUnit\Framework\Constraint\Constraint;
  12. use Symfony\Component\HttpFoundation\Response;
  13. final class ResponseIsUnprocessable extends Constraint
  14. {
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function toString(): string
  19. {
  20. return 'is unprocessable';
  21. }
  22. /**
  23. * @param Response $other
  24. *
  25. * {@inheritdoc}
  26. */
  27. protected function matches($other): bool
  28. {
  29. return Response::HTTP_UNPROCESSABLE_ENTITY === $other->getStatusCode();
  30. }
  31. /**
  32. * @param Response $other
  33. *
  34. * {@inheritdoc}
  35. */
  36. protected function failureDescription($other): string
  37. {
  38. return 'the Response '.$this->toString();
  39. }
  40. /**
  41. * @param Response $other
  42. *
  43. * {@inheritdoc}
  44. */
  45. protected function additionalFailureDescription($other): string
  46. {
  47. return (string) $other;
  48. }
  49. }