ResponseIsSuccessful.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 ResponseIsSuccessful extends Constraint
  14. {
  15. public function toString(): string
  16. {
  17. return 'is successful';
  18. }
  19. /**
  20. * @param Response $response
  21. */
  22. protected function matches($response): bool
  23. {
  24. return $response->isSuccessful();
  25. }
  26. /**
  27. * @param Response $response
  28. */
  29. protected function failureDescription($response): string
  30. {
  31. return 'the Response '.$this->toString();
  32. }
  33. /**
  34. * @param Response $response
  35. */
  36. protected function additionalFailureDescription($response): string
  37. {
  38. return (string) $response;
  39. }
  40. }