setUpFixtures(); $this->httpRequestHandler = HandlerStack::create(); $dice = DI::getDice(); // addRule() clones the current instance and returns a new one, so no concurrency problems :-) $newDice = $dice->addRule(ICanSendHttpRequests::class, [ 'instanceOf' => HttpClient::class, 'call' => [ ['createClient', [$this->httpRequestHandler], Dice::CHAIN_CALL], ], ]); DI::init($newDice); } protected function tearDownHandler(): void { $this->tearDownFixtures(); } }