]> git.mxchange.org Git - friendica.git/blobdiff - tests/DiceHttpMockHandlerTrait.php
Merge pull request #13128 from annando/owa
[friendica.git] / tests / DiceHttpMockHandlerTrait.php
index 969b76b5b005f94d181aed174546756b2564226c..56250817d64a5bf6d64facfee277c6b0014d6f9a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -23,8 +23,8 @@ namespace Friendica\Test;
 
 use Dice\Dice;
 use Friendica\DI;
-use Friendica\Factory\HTTPClientFactory;
-use Friendica\Network\IHTTPClient;
+use Friendica\Network\HTTPClient\Factory\HttpClient;
+use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
 use GuzzleHttp\HandlerStack;
 
 /**
@@ -32,6 +32,8 @@ use GuzzleHttp\HandlerStack;
  */
 trait DiceHttpMockHandlerTrait
 {
+       use FixtureTestTrait;
+
        /**
         * Handler for mocking requests anywhere for testing purpose
         *
@@ -41,16 +43,14 @@ trait DiceHttpMockHandlerTrait
 
        protected function setupHttpMockHandler(): void
        {
-               if (!empty($this->httpRequestHandler) && $this->httpRequestHandler instanceof HandlerStack) {
-                       return;
-               }
+               $this->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(IHTTPClient::class, [
-                       'instanceOf' => HTTPClientFactory::class,
+               $newDice = $dice->addRule(ICanSendHttpRequests::class, [
+                       'instanceOf' => HttpClient::class,
                        'call'       => [
                                ['createClient', [$this->httpRequestHandler], Dice::CHAIN_CALL],
                        ],
@@ -59,10 +59,8 @@ trait DiceHttpMockHandlerTrait
                DI::init($newDice);
        }
 
-       protected function tearDown(): void
+       protected function tearDownHandler(): void
        {
-               \Mockery::close();
-
-               parent::tearDown();
+               $this->tearDownFixtures();
        }
 }