Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ResponseHeaderLocationSame.php

class ResponseHeaderLocationSame

Hierarchy

  • class \PHPUnit\Framework\Constraint\Constraint implements \Countable, \PHPUnit\Framework\SelfDescribing
    • class \Symfony\Component\HttpFoundation\Test\Constraint\ResponseHeaderLocationSame extends \PHPUnit\Framework\Constraint\Constraint

Expanded class hierarchy of ResponseHeaderLocationSame

File

vendor/symfony/http-foundation/Test/Constraint/ResponseHeaderLocationSame.php, line 18

Namespace

Symfony\Component\HttpFoundation\Test\Constraint
View source
final class ResponseHeaderLocationSame extends Constraint {
    public function __construct(Request $request, string $expectedValue) {
    }
    public function toString() : string {
        return \sprintf('has header "Location" matching "%s"', $this->expectedValue);
    }
    protected function matches($other) : bool {
        if (!$other instanceof Response) {
            return false;
        }
        $location = $other->headers
            ->get('Location');
        if (null === $location) {
            return false;
        }
        return $this->toFullUrl($this->expectedValue) === $this->toFullUrl($location);
    }
    protected function failureDescription($other) : string {
        return 'the Response ' . $this->toString();
    }
    private function toFullUrl(string $url) : string {
        if (null === parse_url($url, \PHP_URL_PATH)) {
            $url .= '/';
        }
        if (str_starts_with($url, '//')) {
            return \sprintf('%s:%s', $this->request
                ->getScheme(), $url);
        }
        if (str_starts_with($url, '/')) {
            return $this->request
                ->getSchemeAndHttpHost() . $url;
        }
        return $url;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Constraint::additionalFailureDescription protected function Return additional failure description where needed. 7
Constraint::count public function Counts the number of constraint elements. 3
Constraint::evaluate public function Evaluates the constraint for parameter $other. 7
Constraint::exporter protected function
Constraint::fail protected function Throws an exception for the given compared value and test description. 1
Constraint::failureDescriptionInContext protected function Returns the description of the failure when this constraint appears in
context of an $operator expression.
Constraint::reduce protected function Reduces the sub-expression starting at $this by skipping degenerate
sub-expression and returns first descendant constraint that starts
a non-reducible sub-expression.
2
Constraint::toStringInContext protected function Returns a custom string representation of the constraint object when it
appears in context of an $operator expression.
Constraint::valueToTypeStringFragment protected function @psalm-return non-empty-string
ResponseHeaderLocationSame::failureDescription protected function Returns the description of the failure. Overrides Constraint::failureDescription
ResponseHeaderLocationSame::matches protected function Evaluates the constraint for parameter $other. Returns true if the
constraint is met, false otherwise.
Overrides Constraint::matches
ResponseHeaderLocationSame::toFullUrl private function
ResponseHeaderLocationSame::toString public function Returns a string representation of the object. Overrides SelfDescribing::toString
ResponseHeaderLocationSame::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal