ban example

static::expectExceptionMessage($message);

        $gateway->invalidate(['tag-1', 'tag-2']);
    }

    public function testBan(): void
    {
        $gateway = new VarnishReverseProxyGateway(['http://localhost'], 0, $this->client);

        $this->mockHandler->append(new GuzzleResponse(200, [], ''));

        $gateway->ban(['/']);

        $request = $this->mockHandler->getLastRequest();

        static::assertNotNull($request);

        static::assertEquals('PURGE', $request->getMethod());
        static::assertEquals('http://localhost/', $request->getUri()->__toString());
    }

    /** * @dataProvider providerExceptions */
/** * This should be done in reverse cache */
    public function isLocked(Request $request): bool
    {
        return false;
    }

    public function purge(string $url): bool
    {
        $this->gateway->ban([$url]);

        return true;
    }

    /** * We don't need an cleanup */
    public function cleanup(): void
    {
    }
}


                throw $reason;
            },
        ]);

        $pool->promise()->wait();
    }

    public function banAll(): void
    {
        $this->ban(['/']);
    }
}
$this->redis->lPush($tag$url); // @phpstan-ignore-line - because multiple redis implementations phpstan doesn't like this         }
    }

    /** * @param array<string> $tags */
    public function invalidate(array $tags): void
    {
        $urls = $this->redis->eval($this->keyScript, $tags);

        $this->ban($urls);
        $this->redis->del(...$tags);
    }

    public function ban(array $urls): void
    {
        $list = [];

        foreach ($urls as $url) {
            foreach ($this->hosts as $host) {
                $list[] = new Request($this->singlePurge['method']$host . $url$this->singlePurge['headers']);
            }
        }

        yield 'normal' => [['foo']];
        yield 'duplicate gets merged' => [['foo', 'foo']];
        yield 'is-prefixed' => [['foo', 'foo'], 'foo'];
    }

    public function testBanURL(): void
    {
        $this->mockHandler->append(new GuzzleResponse(200, []));

        $gateway = new FastlyReverseProxyGateway($this->client, 'test', 'key', '0', 3, '', '', 'http://localhost');
        $gateway->ban(['/foo']);

        $lastRequest = $this->mockHandler->getLastRequest();
        static::assertNotNull($lastRequest);
        static::assertSame('/purge/localhost/foo', $lastRequest->getRequestTarget());
        static::assertSame('POST', $lastRequest->getMethod());
        static::assertFalse($lastRequest->hasHeader('surrogate-key'));
        static::assertSame(['key']$lastRequest->getHeader('Fastly-Key'));
    }

    public function testBanAll(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.