Skip to content

Commit 233f761

Browse files
committed
imports optimized.
1 parent e4be8aa commit 233f761

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

src/SearchKit/SearchKit.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ public function __construct( array|string $config ) {
6363

6464
/** Unset properties irrelevant to the child class. */
6565
protected function post_init(): void {
66-
$urls = [Constants::SEARCH_KIT_BASE_URL, Constants::SEARCH_KIT_BASE_URL_EU];
67-
if (! in_array($this->base_url, $urls)) {
68-
throw new InvalidArgumentException('SearchKit permits these base_url values: '. implode(', ', $urls));
69-
}
7066
unset($this->oauth2_client_secret, $this->oauth2_api_scope, $this->oauth2_redirect_url);
7167
unset($this->token_expiry, $this->refresh_token, $this->id_token, $this->package_name, $this->product_id);
7268
unset($this->agc_client_id, $this->agc_client_secret);
7369
unset($this->developer_id, $this->project_id);
7470
unset($this->api_key, $this->api_signature);
71+
72+
$urls = [Constants::SEARCH_KIT_BASE_URL, Constants::SEARCH_KIT_BASE_URL_EU];
73+
if (! in_array($this->base_url, $urls)) {
74+
throw new InvalidArgumentException('SearchKit permits these base_url values: '. implode(', ', $urls));
75+
}
7576
}
7677

7778
/** Provide HTTP request headers as array. */
@@ -81,7 +82,7 @@ protected function auth_header(): array {
8182
"Content-Type" => "application/json; charset=utf-8",
8283
"Authorization" => "Bearer $this->access_token",
8384
"X-Kit-AppID" => $this->oauth2_client_id,
84-
"X-Kit-ClientIP" => $this->client_ip,
85+
// "X-Kit-ClientIP" => $this->client_ip,
8586
"X-Kit-RequestID" => $this->request_id
8687
];
8788
}

tests/BaseTestCase.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ abstract class BaseTestCase extends TestCase {
1616
protected static int $oauth2_client_id = 0; // OAuth2 client.
1717
protected static ?string $oauth2_client_secret = null; // OAuth2 client.
1818
protected static ?string $oauth2_token_path = '../.credentials/huawei_token.json';
19+
protected static ?string $user_access_token = null;
1920
protected static string $build_path;
2021

2122
protected static string $file_id = 'BhrdFPv6j8QzM60pdSadNXY_FZRnRp_AM';
2223

23-
protected static ?string $user_access_token = null;
2424
protected static int $agc_client_id = 0; // AGConnect API.
2525
protected static ?string $agc_client_secret = null; // AGConnect API.
2626

@@ -29,10 +29,7 @@ abstract class BaseTestCase extends TestCase {
2929
protected static ?string $package_name = null;
3030
protected static int $project_id = 0;
3131
protected static int $product_id = 0;
32-
protected static int $cp_id = 0;
3332

34-
/** AppGallery Connect Gateway URL */
35-
protected static ?string $agc_gateway = 'https://connect-drcn.dbankcloud.cn/';
3633
private const ENV_VAR_OAUTH2_CLIENT_ID = 'Variable HUAWEI_OAUTH2_CLIENT_ID is not set.';
3734
private const ENV_VAR_OAUTH2_CLIENT_SECRET = 'Variable HUAWEI_OAUTH2_CLIENT_SECRET is not set.';
3835
private const ENV_VAR_APP_LEVEL_CLIENT_ID = 'Variable HUAWEI_APP_LEVEL_CLIENT_ID is not set.'; // TODO

tests/SearchKitTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ class SearchKitTest extends BaseTestCase {
2121
/** This method is called before the first test of this test class is run. */
2222
public static function setUpBeforeClass(): void {
2323
parent::setUpBeforeClass();
24-
self::$oauth2_client_id = getenv('HUAWEI_APP_LEVEL_CLIENT_ID');
25-
self::$oauth2_client_secret = getenv('HUAWEI_APP_LEVEL_CLIENT_SECRET');
26-
self::$client = new SearchKit( array_merge(self::get_user_config(), [
24+
if ( is_string( getenv('HUAWEI_APP_LEVEL_CLIENT_ID' ) ) ) {
25+
self::$oauth2_client_id = getenv('HUAWEI_APP_LEVEL_CLIENT_ID');
26+
}
27+
if ( is_string( getenv('HUAWEI_APP_LEVEL_CLIENT_SECRET' ) ) ) {
28+
self::$oauth2_client_secret = getenv('HUAWEI_APP_LEVEL_CLIENT_SECRET');
29+
}
30+
self::$client = new SearchKit( array_merge( self::get_user_config(), [
2731
'oauth2_client_id' => self::$oauth2_client_id,
2832
'oauth2_client_secret' => self::$oauth2_client_secret,
2933
'debug_mode' => false

tests/WalletKitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php /** @noinspection PhpPropertyOnlyWrittenInspection */
22
namespace Tests;
33

4-
use HMS\WalletKit\WalletObject\WalletObject;
54
use HMS\WalletKit\WalletKit;
5+
use HMS\WalletKit\WalletObject\WalletObject;
66

77
/**
88
* HMS WalletKit Test: Skipped.

0 commit comments

Comments
 (0)