next = $this->createMock(RequestHandlerInterface::class); $this->middleware = new DropDefaultDomainFromRequestMiddleware('s.test'); } /** * @test * @dataProvider provideQueryParams */ public function domainIsDroppedWhenDefaultOneIsProvided(array $providedPayload, array $expectedPayload): void { $req = ServerRequestFactory::fromGlobals()->withQueryParams($providedPayload)->withParsedBody($providedPayload); $this->next->expects($this->once())->method('handle')->with($this->callback( function (ServerRequestInterface $request) use ($expectedPayload) { Assert::assertEquals($expectedPayload, $request->getQueryParams()); Assert::assertEquals($expectedPayload, $request->getParsedBody()); return true; }, ))->willReturn(new Response()); $this->middleware->process($req, $this->next); } public function provideQueryParams(): iterable { yield [[], []]; yield [['foo' => 'bar'], ['foo' => 'bar']]; yield [['foo' => 'bar', 'domain' => 's.test'], ['foo' => 'bar']]; yield [['foo' => 'bar', 'domain' => 'not_default'], ['foo' => 'bar', 'domain' => 'not_default']]; yield [['domain' => 's.test'], []]; } }