diff --git a/src/OfficialAccount/Application.php b/src/OfficialAccount/Application.php index 457c71b56..7bb829e4f 100644 --- a/src/OfficialAccount/Application.php +++ b/src/OfficialAccount/Application.php @@ -103,7 +103,6 @@ public function getServer(): Server|ServerInterface { if (!$this->server) { $this->server = new Server( - account: $this->getAccount(), request: $this->getRequest(), encryptor: $this->getAccount()->getAesKey() ? $this->getEncryptor() : null ); diff --git a/src/OfficialAccount/Server.php b/src/OfficialAccount/Server.php index e64cbb4c5..7b75fb9a9 100644 --- a/src/OfficialAccount/Server.php +++ b/src/OfficialAccount/Server.php @@ -11,7 +11,6 @@ use EasyWeChat\Kernel\Traits\DecryptXmlMessage; use EasyWeChat\Kernel\Traits\InteractWithHandlers; use EasyWeChat\Kernel\Traits\RespondXmlMessage; -use EasyWeChat\OfficialAccount\Contracts\Account as AccountInterface; use Nyholm\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -28,7 +27,6 @@ class Server implements ServerInterface * @throws \Throwable */ public function __construct( - protected AccountInterface $account, ?ServerRequestInterface $request = null, protected ?Encryptor $encryptor = null, ) { diff --git a/src/OpenPlatform/Application.php b/src/OpenPlatform/Application.php index e7bd686cb..f8d1190d5 100644 --- a/src/OpenPlatform/Application.php +++ b/src/OpenPlatform/Application.php @@ -104,7 +104,6 @@ public function getServer(): Server|ServerInterface { if (!$this->server) { $this->server = new Server( - account: $this->getAccount(), encryptor: $this->getEncryptor(), request: $this->getRequest() ); @@ -240,7 +239,10 @@ public function getOfficialAccount(AuthorizerAccessToken $authorizerAccessToken, \array_merge( [ 'app_id' => $authorizerAccessToken->getAppId(), + 'token' => $this->config->get('token'), + 'aes_key' => $this->config->get('aes_key'), 'logging' => $this->config->get('logging'), + 'http' => $this->config->get('http'), ], $config ) @@ -264,7 +266,10 @@ public function getMiniApp(AuthorizerAccessToken $authorizerAccessToken, array $ \array_merge( [ 'app_id' => $authorizerAccessToken->getAppId(), + 'token' => $this->config->get('token'), + 'aes_key' => $this->config->get('aes_key'), 'logging' => $this->config->get('logging'), + 'http' => $this->config->get('http'), ], $config ) diff --git a/src/OpenPlatform/Server.php b/src/OpenPlatform/Server.php index b896b316e..d318e22c0 100644 --- a/src/OpenPlatform/Server.php +++ b/src/OpenPlatform/Server.php @@ -11,7 +11,6 @@ use EasyWeChat\Kernel\Traits\DecryptXmlMessage; use EasyWeChat\Kernel\Traits\InteractWithHandlers; use EasyWeChat\Kernel\Traits\RespondXmlMessage; -use EasyWeChat\OpenPlatform\Contracts\Account as AccountInterface; use Nyholm\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -29,7 +28,6 @@ class Server implements ServerInterface * @throws \Throwable */ public function __construct( - protected AccountInterface $account, protected Encryptor $encryptor, ?ServerRequestInterface $request = null, ) { diff --git a/src/OpenWork/Application.php b/src/OpenWork/Application.php index 319f8b6c2..7bf99114e 100644 --- a/src/OpenWork/Application.php +++ b/src/OpenWork/Application.php @@ -108,7 +108,6 @@ public function getServer(): Server|ServerInterface { if (!$this->server) { $this->server = new Server( - account: $this->getAccount(), encryptor: $this->getSuiteEncryptor(), providerEncryptor: $this->getEncryptor(), request: $this->getRequest(), diff --git a/src/OpenWork/Server.php b/src/OpenWork/Server.php index 548d3d5df..d9bbc13a4 100644 --- a/src/OpenWork/Server.php +++ b/src/OpenWork/Server.php @@ -10,7 +10,6 @@ use EasyWeChat\Kernel\Traits\DecryptXmlMessage; use EasyWeChat\Kernel\Traits\InteractWithHandlers; use EasyWeChat\Kernel\Traits\RespondXmlMessage; -use EasyWeChat\OpenWork\Contracts\Account as AccountInterface; use EasyWeChat\Kernel\Contracts\Server as ServerInterface; use Nyholm\Psr7\Response; use Psr\Http\Message\ResponseInterface; @@ -29,7 +28,6 @@ class Server implements ServerInterface * @throws \Throwable */ public function __construct( - protected AccountInterface $account, protected Encryptor $encryptor, protected Encryptor $providerEncryptor, ?ServerRequestInterface $request = null, diff --git a/src/Work/Application.php b/src/Work/Application.php index 28828b243..89f297365 100644 --- a/src/Work/Application.php +++ b/src/Work/Application.php @@ -81,7 +81,6 @@ public function getServer(): Server|ServerInterface { if (!$this->server) { $this->server = new Server( - account: $this->getAccount(), request: $this->getRequest(), encryptor: $this->getEncryptor() ); diff --git a/src/Work/Server.php b/src/Work/Server.php index cb74fae1f..53903a851 100644 --- a/src/Work/Server.php +++ b/src/Work/Server.php @@ -11,7 +11,6 @@ use EasyWeChat\Kernel\Traits\DecryptXmlMessage; use EasyWeChat\Kernel\Traits\InteractWithHandlers; use EasyWeChat\Kernel\Traits\RespondXmlMessage; -use EasyWeChat\Work\Contracts\Account as AccountInterface; use Nyholm\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -28,7 +27,6 @@ class Server implements ServerInterface * @throws \Throwable */ public function __construct( - protected AccountInterface $account, protected Encryptor $encryptor, ?ServerRequestInterface $request = null, ) { diff --git a/tests/OfficialAccount/ApplicationTest.php b/tests/OfficialAccount/ApplicationTest.php index 76a6c9151..2a1565b61 100644 --- a/tests/OfficialAccount/ApplicationTest.php +++ b/tests/OfficialAccount/ApplicationTest.php @@ -75,7 +75,7 @@ public function test_get_and_set_server() $this->assertSame($app->getServer(), $app->getServer()); // set - $server = new Server(\Mockery::mock(Account::class), \Mockery::mock(ServerRequestInterface::class)); + $server = new Server(\Mockery::mock(ServerRequestInterface::class)); $app->setServer($server); $this->assertSame($server, $app->getServer()); } diff --git a/tests/OfficialAccount/ServerTest.php b/tests/OfficialAccount/ServerTest.php index f9259cfcf..fa3fd6004 100644 --- a/tests/OfficialAccount/ServerTest.php +++ b/tests/OfficialAccount/ServerTest.php @@ -5,7 +5,6 @@ namespace EasyWeChat\Tests\OfficialAccount; use EasyWeChat\Kernel\Support\Xml; -use EasyWeChat\OfficialAccount\Account; use EasyWeChat\OfficialAccount\Server; use EasyWeChat\Tests\TestCase; use Nyholm\Psr7\ServerRequest; @@ -15,7 +14,7 @@ class ServerTest extends TestCase public function test_it_will_handle_validation_request() { $request = (new ServerRequest('GET', 'http://easywechat.com/?echostr=abcdefghijklmn'))->withQueryParams(['echostr' => 'abcdefghijklmn']); - $server = new Server(\Mockery::mock(Account::class), $request); + $server = new Server($request); $response = $server->serve(); @@ -33,7 +32,7 @@ public function test_it_will_response_success_without_handlers() 1234567890123456 '; $request = (new ServerRequest('POST', 'http://easywechat.com/server', [], $body)); - $server = new Server(\Mockery::mock(Account::class), $request); + $server = new Server($request); $response = $server->serve(); @@ -51,7 +50,7 @@ public function test_it_will_respond_from_message_handlers() 1234567890123456 '; $request = (new ServerRequest('POST', 'http://easywechat.com/server', [], $body)); - $server = new Server(\Mockery::mock(Account::class), $request); + $server = new Server($request); $response = $server ->addMessageListener( @@ -86,7 +85,7 @@ public function test_it_will_respond_from_event_handlers() '; $request = (new ServerRequest('POST', 'http://easywechat.com/server', [], $body)); - $server = new Server(\Mockery::mock(Account::class), $request); + $server = new Server($request); $response = $server ->addMessageListener( diff --git a/tests/OpenPlatform/ApplicationTest.php b/tests/OpenPlatform/ApplicationTest.php index eae2d9dcd..acf9213f9 100644 --- a/tests/OpenPlatform/ApplicationTest.php +++ b/tests/OpenPlatform/ApplicationTest.php @@ -83,7 +83,6 @@ public function test_get_and_set_server() // set $server = new Server( - account: \Mockery::mock(Account::class), encryptor: \Mockery::mock(Encryptor::class), request: \Mockery::mock(ServerRequestInterface::class) ); diff --git a/tests/OpenPlatform/ServerTest.php b/tests/OpenPlatform/ServerTest.php index 84040f915..03198712c 100644 --- a/tests/OpenPlatform/ServerTest.php +++ b/tests/OpenPlatform/ServerTest.php @@ -3,7 +3,6 @@ namespace EasyWeChat\Tests\OpenPlatform; use EasyWeChat\Kernel\Encryptor; -use EasyWeChat\OpenPlatform\Account; use EasyWeChat\OpenPlatform\Server; use EasyWeChat\Tests\TestCase; @@ -24,7 +23,7 @@ public function test_it_will_handle_authorized_event() $encryptor = new Encryptor('wx5823bf96d3bd56c7', 'QDG6eK', 'jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C'); $request = $this->createEncryptedXmlMessageRequest($body, $encryptor); - $server = new Server(account: \Mockery::mock(Account::class), encryptor: $encryptor, request: $request); + $server = new Server(encryptor: $encryptor, request: $request); $handleResult = null; $response = $server->handleAuthorized(function ($message) use (&$handleResult) { @@ -47,7 +46,7 @@ public function test_it_will_handle_unauthorized_event() $encryptor = new Encryptor('wx5823bf96d3bd56c7', 'QDG6eK', 'jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C'); $request = $this->createEncryptedXmlMessageRequest($body, $encryptor); - $server = new Server(account: \Mockery::mock(Account::class), encryptor: $encryptor, request: $request); + $server = new Server(encryptor: $encryptor, request: $request); $handleResult = null; $response = $server->handleUnauthorized(function ($message) use (&$handleResult) { @@ -73,7 +72,7 @@ public function test_it_will_handle_authorize_updated_event() $encryptor = new Encryptor('wx5823bf96d3bd56c7', 'QDG6eK', 'jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C'); $request = $this->createEncryptedXmlMessageRequest($body, $encryptor); - $server = new Server(account: \Mockery::mock(Account::class), encryptor: $encryptor, request: $request); + $server = new Server(encryptor: $encryptor, request: $request); $handleResult = null; $response = $server->handleAuthorizeUpdated(function ($message) use (&$handleResult) { @@ -97,7 +96,6 @@ public function test_it_will_handle_verify_ticket_refresh_event() $request = $this->createEncryptedXmlMessageRequest($body, $encryptor); $server = new Server( - account: \Mockery::mock(Account::class), encryptor: $encryptor, request: $request ); diff --git a/tests/Work/ApplicationTest.php b/tests/Work/ApplicationTest.php index c99810e5c..6609bf9a5 100644 --- a/tests/Work/ApplicationTest.php +++ b/tests/Work/ApplicationTest.php @@ -102,7 +102,6 @@ public function test_get_and_set_server() // set $server = new Server( - account: \Mockery::mock(Account::class), encryptor: $app->getEncryptor(), request: \Mockery::mock(ServerRequestInterface::class) );