Skip to content

Commit f0bfd94

Browse files
committed
Fixed test cases
1 parent 85af66b commit f0bfd94

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
},
6060
"extra": {
6161
"branch-alias": {
62-
"dev-main": "0.1-dev"
62+
"dev-main": "0.2-dev"
6363
},
6464
"hyperf": {
6565
"config": "KY\\WorkWxUser\\ConfigProvider"

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ parameters:
77
reportUnmatchedIgnoredErrors: false
88
ignoreErrors:
99
- '#Unsafe usage of new static#'
10+
- '#Hyperf\\Engine\\Http\\Server#'

src/WeChat/OAuth.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020

2121
class OAuth extends Service
2222
{
23-
public function localOAuth(): string
23+
public function localOAuth(string $localhost, int $port = 55274): string
2424
{
2525
$chan = new Channel(1);
2626
$server = new Server($this->logger);
27-
go(function () use ($server, $chan) {
27+
go(function () use ($server, $chan, $localhost, $port) {
2828
try {
29-
$server->bind('0.0.0.0', $port = 55274);
29+
$server->bind('0.0.0.0', $port);
3030

3131
$server->handle(static function (ServerRequestInterface $request) use ($chan) {
3232
$chan->push($request->getQueryParams()['code'] ?? '');
3333
});
3434

35-
$url = di()->get(WeChat::class)->authorize(urlencode('http://local-cmd-oauth.knowyourself.cc:' . $port . '/'), '');
35+
$url = di()->get(WeChat::class)->authorize(sprintf('http://%s:%d/', $localhost, $port), '');
3636

3737
echo 'Please click the url below and login' . PHP_EOL;
3838
echo $url . PHP_EOL;

tests/oauth_server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
$oauth = new OAuth($container);
2424

25-
var_dump($code = $oauth->localOAuth());
25+
var_dump($code = $oauth->localOAuth('localhost'));

0 commit comments

Comments
 (0)