next = $this->prophesize(RequestHandlerInterface::class); $this->middleware = new DropDefaultDomainFromQueryMiddleware('doma.in'); } /** * @test * @dataProvider provideQueryParams */ public function domainIsDroppedWhenDefaultOneIsProvided(array $providedQuery, array $expectedQuery): void { $req = ServerRequestFactory::fromGlobals()->withQueryParams($providedQuery); $handle = $this->next->handle(Argument::that(function (ServerRequestInterface $request) use ($expectedQuery) { Assert::assertEquals($expectedQuery, $request->getQueryParams()); return $request; }))->willReturn(new Response()); $this->middleware->process($req, $this->next->reveal()); $handle->shouldHaveBeenCalledOnce(); } public function provideQueryParams(): iterable { yield [[], []]; yield [['foo' => 'bar'], ['foo' => 'bar']]; yield [['foo' => 'bar', 'domain' => 'doma.in'], ['foo' => 'bar']]; yield [['foo' => 'bar', 'domain' => 'not_default'], ['foo' => 'bar', 'domain' => 'not_default']]; yield [['domain' => 'doma.in'], []]; } }