Skip to content

Commit

Permalink
fixed #2743
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Sep 10, 2023
1 parent 5169192 commit 660864a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/Kernel/Support/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public static function get(mixed $array, string|int|null $key, mixed $default =
}

foreach (explode('.', (string) $key) as $segment) {
/** @phpstan-ignore-next-line */
if (static::exists($array, $segment)) {
/** @phpstan-ignore-next-line */
if (is_array($array) && static::exists($array, $segment)) {
$array = $array[$segment];
} else {
return $default;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenPlatform/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public function getOfficialAccount(
'token' => $this->config->get('token'),
'aes_key' => $this->config->get('aes_key'),
'logging' => $this->config->get('logging'),
'http' => $this->config->get('http'),
'http' => $this->config->get('http', []),
],
$config
)
Expand Down
29 changes: 29 additions & 0 deletions tests/OfficialAccount/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EasyWeChat\Kernel\Contracts\AccessToken as AccessTokenInterface;
use EasyWeChat\Kernel\Contracts\Server as ServerInterface;
use EasyWeChat\Kernel\Encryptor;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use EasyWeChat\OfficialAccount\AccessToken;
use EasyWeChat\OfficialAccount\Account;
use EasyWeChat\OfficialAccount\Account as AccountInterface;
Expand Down Expand Up @@ -99,6 +100,34 @@ public function test_get_and_set_access_token()
$this->assertSame($accessToken, $app->getAccessToken());
}

// https://github.com/w7corp/easywechat/issues/2743
public function test_get_client_without_http_config()
{
$app = new Application(
[
'app_id' => 'wx3cf0f39249000060',
'secret' => 'mock-secret',
'token' => 'mock-token',
'aes_key' => 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG',
]
);

$this->assertInstanceOf(AccessTokenAwareClient::class, $app->getClient());

$app = new Application(
[
'app_id' => 'wx3cf0f39249000060',
'secret' => 'mock-secret',
'token' => 'mock-token',
'aes_key' => 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG',
'http' => null,
]
);

// no exception
$this->assertInstanceOf(AccessTokenAwareClient::class, $app->getClient());
}

public function test_get_and_set_ticket()
{
$app = new Application(
Expand Down

1 comment on commit 660864a

@vercel
Copy link

@vercel vercel bot commented on 660864a Sep 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

easywechat – ./

easywechat-git-6x-overtrue.vercel.app
easywechat.vercel.app
easywechat-overtrue.vercel.app

Please sign in to comment.