on( RequestMatcher::createMatcher('oauth.aliexpress.com') ->setPath('/token') ->setOptionalPostFields([ 'code' => 'oauthCode', 'state' => '{"accountId":5,"token":"login-5f86e5579dad92"}' ]), $this->responseJson(200, $jsonResponse) ); $tokenFetcher = TopClientBuilder::create() ->setContainer($this->getContainer($mock)) ->setAppData($this->getEnvAppData()) ->setAuthenticator($this->getEnvTokenAuthenticator()) ->build() ->getTokenFetcher(); $response = $tokenFetcher->fetchToken('oauthCode', '{"accountId":5,"token":"login-5f86e5579dad92"}'); self::assertEquals('accessToken', $response->accessToken); self::assertEquals('refreshToken', $response->refreshToken); } }