Skip to content

Commit

Permalink
Fix OpenPlatform component custom parameters. (overtrue#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
her-cat authored Mar 3, 2020
1 parent a18f195 commit 1e21413
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Providers/WeChatProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function buildAuthUrlFromBase($url, $state)
protected function getCodeFields($state = null)
{
if ($this->component) {
$this->with(['component_appid' => $this->component->getAppId()]);
$this->with(array_merge($this->parameters, ['component_appid' => $this->component->getAppId()]));
}

return array_merge([
Expand Down
12 changes: 12 additions & 0 deletions tests/WechatProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public function testOpenPlatformComponent()

$this->assertSame('https://api.weixin.qq.com/sns/oauth2/component/access_token', $provider->tokenUrl());
}

public function testOpenPlatformComponentWithCustomParameters()
{
$provider = new WeChatProvider(Request::create('foo'), 'client_id', null, 'redirect-url');
$provider->component(new WeChatComponent());
$provider->with(['foo' => 'bar']);

$fields = $provider->codeFields('wechat-state');

$this->assertArrayHasKey('foo', $fields);
$this->assertSame('bar', $fields['foo']);
}
}

trait ProviderTrait
Expand Down

0 comments on commit 1e21413

Please sign in to comment.