From c782debf0c8b51fa5c1080807ae10100bc10cf31 Mon Sep 17 00:00:00 2001
From: Project Update Bot <git@users.noreply.drupalcode.org>
Date: Fri, 27 Jan 2023 11:06:57 -0800
Subject: [PATCH] Issue #3287166 (mostly) by Project Update Bot: Automated
 Drupal 10 compatibility fixes

---
 eloqua_api_redux.info.yml              |  2 +-
 src/Service/EloquaApiClient.php        |  4 +--
 tests/src/Unit/EloquaApiClientTest.php | 49 +++++++-------------------
 3 files changed, 15 insertions(+), 40 deletions(-)

diff --git a/eloqua_api_redux.info.yml b/eloqua_api_redux.info.yml
index 7e9d440..d1f9834 100644
--- a/eloqua_api_redux.info.yml
+++ b/eloqua_api_redux.info.yml
@@ -3,5 +3,5 @@ description: Integrate Drupal 8 modules with Eloqua REST API.
 type: module
 package: Eloqua
 core: 8.x
-core_version_requirement: ^8 || ^9
+core_version_requirement: ^8.9 || ^9 || ^10
 configure: eloqua_api_redux.settings
diff --git a/src/Service/EloquaApiClient.php b/src/Service/EloquaApiClient.php
index 96b20f4..0afc2dc 100644
--- a/src/Service/EloquaApiClient.php
+++ b/src/Service/EloquaApiClient.php
@@ -327,7 +327,7 @@ class EloquaApiClient {
     // Save the token.
     $cacheItem = [
       'value' => $value,
-      'expire' => REQUEST_TIME + $this->eloquaApiCacheAge($key),
+      'expire' => \Drupal::time()->getRequestTime() + $this->eloquaApiCacheAge($key),
     ];
 
     $this->configTokens
@@ -349,7 +349,7 @@ class EloquaApiClient {
     if ($cache = $this->configTokens->get($type)) {
       $response = unserialize($cache, ['allowed_classes' => FALSE]);
 
-      $now = REQUEST_TIME;
+      $now = \Drupal::time()->getRequestTime();
       $expire = $response['expire'];
 
       // Manually validate if the token is still fresh.
diff --git a/tests/src/Unit/EloquaApiClientTest.php b/tests/src/Unit/EloquaApiClientTest.php
index fe4a6ed..794941b 100644
--- a/tests/src/Unit/EloquaApiClientTest.php
+++ b/tests/src/Unit/EloquaApiClientTest.php
@@ -76,21 +76,14 @@ class EloquaApiClientTest extends UnitTestCase {
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
+  protected function setUp(): void {
     parent::setUp();
 
-    $this->httpClientFactory = $this->getMockBuilder('Drupal\Core\Http\ClientFactory')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $this->httpClientFactory = $this->createMock('Drupal\Core\Http\ClientFactory');
 
-    $this->config = $this->getMockBuilder('Drupal\Core\Config\Config\Drupal\Core\Config\ImmutableConfig')
-      ->disableOriginalConstructor()
-      ->setMethods(['get'])
-      ->getMock();
+    $this->config = $this->createMock('Drupal\Core\Config\ImmutableConfig');
 
-    $this->configFactory = $this->getMockBuilder('Drupal\Core\Config\ConfigFactory')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactory');
 
     $this->configFactory->expects($this->any())
       ->method('get')
@@ -102,29 +95,17 @@ class EloquaApiClientTest extends UnitTestCase {
       ->with('eloqua_api_redux.tokens')
       ->will($this->returnValue($this->configTokens));
 
-    $this->loggerFactory = $this->getMockBuilder('Drupal\Core\Logger\LoggerChannelFactoryInterface')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $this->loggerFactory = $this->createMock('Drupal\Core\Logger\LoggerChannelFactoryInterface');
 
-    $this->cacheBackend = $this->getMockBuilder('Drupal\Core\Cache\CacheBackendInterface')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $this->cacheBackend = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
 
-    $this->moduleHandler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
 
     // Set container and required dependencies.
     $container = new ContainerBuilder();
-    $pathValidator = $this->getMockBuilder('Drupal\Core\Path\PathValidatorInterface')
-      ->disableOriginalConstructor()
-      ->getMock();
-    $unroutedUrlAssembler = $this->getMockBuilder('Drupal\Core\Utility\UnroutedUrlAssemblerInterface')
-      ->disableOriginalConstructor()
-      ->getMock();
-    $authFallbackService = $this->getMockBuilder('Drupal\eloqua_api_redux\Service\EloquaAuthFallbackInterface')
-      ->disableOriginalConstructor()
-      ->getMock();
+    $pathValidator = $this->createMock('Drupal\Core\Path\PathValidatorInterface');
+    $unroutedUrlAssembler = $this->createMock('Drupal\Core\Utility\UnroutedUrlAssemblerInterface');
+    $authFallbackService = $this->createMock('Drupal\eloqua_api_redux\Service\EloquaAuthFallbackInterface');
     $container->set('path.validator', $pathValidator);
     $container->set('unrouted_url_assembler', $unroutedUrlAssembler);
     $container->set('eloqua_api_redux.auth_fallback_default', $authFallbackService);
@@ -221,15 +202,9 @@ class EloquaApiClientTest extends UnitTestCase {
       $this->getMockResponseContents(self::ACCESS_TOKEN_RESPONSE)
     );
 
-    $httpClientFactory = $this->getMockBuilder('Drupal\Core\Http\ClientFactory')
-      ->disableOriginalConstructor()
-      ->setMethods(['fromOptions'])
-      ->getMock();
+    $httpClientFactory = $this->createMock('Drupal\Core\Http\ClientFactory');
 
-    $guzzleClient = $this->getMockBuilder('GuzzleHttp\Client')
-      ->disableOriginalConstructor()
-      ->setMethods(['request'])
-      ->getMock();
+    $guzzleClient = $this->createMock('GuzzleHttp\Client');
 
     $guzzleClient->expects($this->any())
       ->method('request')
-- 
GitLab