SchemeRequestMatcher example


    /** * @dataProvider getData */
    public function test(string $requestScheme, array|string $matcherScheme, bool $isMatch)
    {
        $httpRequest = Request::create('');
        $httpsRequest = Request::create('', 'get', [][][]['HTTPS' => 'on']);

        if ($isMatch) {
            if ('https' === $requestScheme) {
                $matcher = new SchemeRequestMatcher($matcherScheme);
                $this->assertFalse($matcher->matches($httpRequest));
                $this->assertTrue($matcher->matches($httpsRequest));
            } else {
                $matcher = new SchemeRequestMatcher($matcherScheme);
                $this->assertFalse($matcher->matches($httpsRequest));
                $this->assertTrue($matcher->matches($httpRequest));
            }
        } else {
            $matcher = new SchemeRequestMatcher($matcherScheme);
            $this->assertFalse($matcher->matches($httpRequest));
            $this->assertFalse($matcher->matches($httpsRequest));
        }
Home | Imprint | This part of the site doesn't use cookies.