text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Pay;
use EasyWeChat\Kernel\Contracts\Config as ConfigInterface;
use EasyWeChat\Kernel\Contracts\Server as ServerInterface;
use EasyWeChat\Kernel\Support\PrivateKey;
use EasyWeChat\Kernel\Support\PublicKey;
use EasyWeChat\Kernel\Traits\InteractWithConf... | fim | w7corp/easywechat | php |
<|fim_suffix|>
$this->defaultOptions = array_merge(self::OPTIONS_DEFAULTS, $this->defaultOptions);
if (! empty($defaultOptions)) {
$defaultOptions = RequestUtil::formatDefaultOptions($defaultOptions);
[, $this->defaultOptions] = self::prepareRequest(null, null, $defaultOptions,... | fim | w7corp/easywechat | php |
<|fim_suffix|> * @var array<string>
*/
protected array $requiredKeys = [
'mch_id',
'secret_key',
'private_key',
'certificate',
];
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Pay;
class Config extends \EasyWeChat\Kerne<|fim_middle|>l\Config
{
... | fim | w7corp/easywechat | php |
<|fim_suffix|> getHttpClient(): HttpClientInterface;
public function getClient(): HttpClientInterface;
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Pay\Contracts;
use EasyWeChat\Kernel\Contracts\Config;
use Symfony\Contracts\HttpClient\HttpClientInterface;
inter<|fim_middle|>face Applica... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
decl<|fim_suffix|>ng;
public function getCertificate(): PublicKey;
public function getPlatformCert(string $serial): ?PublicKey;
/**
* @return array<string,PublicKey>
*/
public function getPlatformCerts(): array;
}
<|fim_middle|>are(strict_types=1);
namespace EasyWeChat... | fim | w7corp/easywechat | php |
<|fim_suffix|>\HttpClient\Response;
use Psr\Http\Message\ResponseInterface;
interface ResponseValidator
{
public function validate(ResponseInterface|Response $response): void;
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Pay\<|fim_middle|>Contracts;
use EasyWeChat\Kernel<|endoftext|> | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace Easy<|fim_suffix|> void;
}
<|fim_middle|>WeChat\Pay\Contracts;
use Psr\Http\Message\MessageInterface;
interface Validator
{
public function validate(MessageInterface $message):<|endoftext|> | fim | w7corp/easywechat | php |
<|fim_suffix|>ception extends RuntimeException
{
}
<|fim_prefix|><?php
namespace EasyWeChat\Pay\Exceptions;
use EasyWeChat\Kernel\Exceptions\Runti<|fim_middle|>meException;
class EncryptionFailureEx<|endoftext|> | fim | w7corp/easywechat | php |
<|fim_suffix|>}
<|fim_prefix|><?php
namespace EasyWeChat\Pay\Exceptions;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
class InvalidSi<|fim_middle|>gnatureException extends RuntimeException
{
<|endoftext|> | fim | w7corp/easywechat | php |
<|fim_suffix|>{
throw new InvalidConfigException('Missing V2 API key.');
}
$message = urldecode(http_build_query($attributes));
if (! empty($params['sign_type']) && $params['sign_type'] === 'HMAC-SHA256') {
$sign = hash_hmac('sha256', $message, $attributes['key']);
... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Pay;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Support\PrivateKey;
use EasyWeChat\Kernel\Support\PublicKey;
use EasyWeChat\Pay\Contracts\Merchant as MerchantInterface;
use function array_is_list;
use function in... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Pay;
use RuntimeException;
use function is_array;
use function is_string;
use function json_decode;
/**
* @property string $trade_state
*/
class Message extends \EasyWeChat\Kernel\Message
{
/**
* @return array<string, mixed>
*/
public function getOriginalAttributes(): ... | fim | w7corp/easywechat | php |
<|fim_suffix|>**
* @throws BadResponseException
*/
public function validate(PsrResponse|HttpClientResponse $response): void
{
if ($response instanceof HttpClientResponse) {
$response = $response->toPsrResponse();
}
if ($response->getStatusCode() !== 200) {
... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Pay;
use Closure;
use EasyWeChat\Kernel\Contracts\Server as ServerInterface;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use EasyWeChat\Kernel\ServerResponse;
use EasyWeChat\Kernel\Support\AesEcb;
use EasyWeChat... | fim | w7corp/easywechat | php |
<|fim_suffix|>options['query'] ?? []))));
$body = '';
$query = $uri->getQuery();
$timestamp = time();
$nonce = Str::random();
$path = '/'.ltrim($uri->getPath().(empty($query) ? '' : '?'.$query), '/');
if (! empty($options['body']) && (is_scalar($options['body']) || $opt... | fim | w7corp/easywechat | php |
<|fim_suffix|> {
}
public function forProduct(string|int $productId, string $appId): string
{
$params = [
'appid' => $appId,
'mch_id' => $this->merchant->getMerchantId(),
'time_stamp' => time(),
'nonce_str' => Str::random(),
'product_id' =... | fim | w7corp/easywechat | php |
<|fim_suffix|>rtoupper($signature);
}
}
<|fim_prefix|><?php
namespace EasyWeChat\Pay;
use const OPENSSL_PKCS1_OAEP_PADDING;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use EasyWeChat\Kernel\Support\Str;
use EasyWeChat\Pay\Contracts\Merchant as MerchantInterface;
use EasyWeChat\Pay\Exceptions\Encrypt... | fim | w7corp/easywechat | php |
<|fim_suffix|> "{$timestamp}\n{$nonce}\n{$body}\n";
if (\time() - \intval($timestamp) > self::MAX_ALLOWED_CLOCK_OFFSET) {
throw new InvalidSignatureException('Clock Offset Exceeded');
}
$publicKey = $this->merchant->getPlatformCert($serial);
if (! $publicKey) {
... | fim | w7corp/easywechat | php |
<|fim_suffix|> }
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work;
use const JSON_UNESCAPED_UNICODE;
use EasyWeChat\Kernel\Contracts\RefreshableAccessToken;
use EasyWeChat\Kernel\Exceptions\HttpException;
use JetBrains\PhpStorm\ArrayShape;
use Psr\SimpleCache\CacheInterface<|fim_middle|>;
us... | fim | w7corp/easywechat | php |
<|fim_suffix|>function getAesKey(): string
{
return $this->aesKey;
}
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work;
use EasyWeChat\Work\Contracts\Account as AccountInterface;
class Account implements AccountInterface
{
public function __construct(
protected str... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work;
use EasyWeChat\Kernel\Contracts\AccessToken as AccessTokenInterface;
use EasyWeChat\Kernel\Contracts\Server as ServerInterface;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use EasyWeChat\Kernel\HttpClient\Response;
use EasyWeChat\Ke... | fim | w7corp/easywechat | php |
<?php
declare(strict_types=1);
namespace EasyWeChat\Work;
class Config extends \EasyWeChat\Kernel\Config
{
/**
* @var array<string>
*/
protected array $requiredKeys = [
'corp_id',
'secret',
'token',
'aes_key',
];
}
<|endoftext|> | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work\Contracts;
interface Account
{
public function getCorpId(): string;
public function getSecret(): string;
public function get<|fim_suffix|>string;
public function getAesKey(): string;
}
<|fim_middle|>Token(): <|endoftext|> | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work\Contracts;
use EasyWeChat\Kernel\Contracts\AccessToken;
use EasyWeChat\Kernel\Contracts\Config;
use EasyWeChat\Kernel\Contracts\Server;
use EasyWeChat\Kernel\Encryptor;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use Psr\Http\Message... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Work;
use JetBrain<|fim_suffix|>nstruct($corpId, $token, $aesKey, null);
}
}
<|fim_middle|>s\PhpStorm\Pure;
class Encryptor extends \EasyWeChat\Kernel\Encryptor
{
#[Pure]
public function __construct(string $corpId, string $token, string $aesKey)
{
pare... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work;
use EasyWeChat\Kernel\Exceptions\HttpException;
use JetBrains\PhpStorm\ArrayShape;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;
use Symfony\Component\HttpClien... | fim | w7corp/easywechat | php |
<|fim_suffix|>property string $Event
* @property string $InfoType
* @property string $MsgType
* @property string $ChangeType
*/
class Message extends \EasyWeChat\Kernel\Message
{
//
}
<|fim_prefix|><?php
declare(s<|fim_middle|>trict_types=1);
namespace EasyWeChat\Work;
/**
* @<|endoftext|> | fim | w7corp/easywechat | php |
<|fim_suffix|>tMessage(
$message,
$this->encryptor,
...$params
);
}
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Work;
use Closure;
use EasyWeChat\Kernel\Contracts\Server as ServerInterface;
use EasyWeChat\Kernel\Encryptor;
use EasyWeChat\Kernel\... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Work;
use EasyWeChat\Kernel\Support\Str;
use function time;
class Utils
{
public function __construct(protected Application $app)
{
}
/**
* @param array<string> $jsApiList
* @param array<string> $openTagList
* @return array<string, mixed>
*/
pu... | fim | w7corp/easywechat | php |
<|fim_suffix|>}
public function test_decrypt_with_error_signature()
{
$this->expectExceptionMessage('Invalid Signature.');
$encrypted = "<xml>\n <ToUserName><![CDATA[asdasdasd]]></ToUserName>\n <Encrypt><![CDATA[rTNFcsut4LfGuAFKEUVVpwcaCOTJzOd9twZdIW910jb3k+iicx2uvhttIZ3Qg9Qgty3BEF2xbOrz6... | fim | w7corp/easywechat | php |
<?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Kernel\HttpClient;
use EasyWeChat\Kernel\Contracts\AccessToken;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use EasyWeChat\Tests\TestCase;
class AccessTokenAwareClientTest extends TestCase
{
public function test_full_uri_call()
{
... | fim | w7corp/easywechat | php |
<|fim_suffix|>ndReturns('mock-access-token', false);
});
$strategy->withAccessToken($refreshAbleAccessToken)
->decideUsing(function () {
return true;
});
$context = $this->getContext(2, 'GET', 'http://easywechat.com', 200);
// first time should ... | fim | w7corp/easywechat | php |
<|fim_suffix|>questOptions()['headers']['Content-Type']);
$this->assertSame('application/xml', $response->getRequestOptions()['headers']['Accept']);
// with type
$response = $client->postXml('http://easywechat.com', ['xml' => ['foo' => 'bar']]);
$this->assertSame('POST', $response->get... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel\HttpClient;
use EasyWeChat\Kernel\HttpClient\RequestUtil;
use EasyWeChat\Kernel\Support\UserAgent;
use EasyWeChat\Tests\TestCase;
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
class RequestUtilTest extends TestCase
{
public function test_merge_... | fim | w7corp/easywechat | php |
<|fim_suffix|>e(['body' => ['app_id' => 'wx123456', 'secret' => 'helloworld']], $client->mergeThenResetPrepends([], 'PATCH'));
// test As
$client->withAppIdAs('test')->withSecret();
$this->assertSame(['query' => ['test' => 'wx123456', 'secret' => 'helloworld']], $client->mergeThenResetPrepends(... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel\HttpClient;
use EasyWeChat\Kernel\Exceptions\BadResponseException;
use EasyWeChat\Kernel\HttpClient\Response;
use EasyWeChat\Tests\TestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;
use Symfony\Contra... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Tests\Kernel\HttpClient;
use EasyWeChat\Kernel\HttpClient\RetryableClient;
use EasyWeChat\Tests\TestCase;
use Symfony\Component\HttpClient\DecoratorTrait;
use Symfony\Component\HttpClient\Exception\ServerException;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpC... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel;
use EasyWeChat\Pay\Message;
use EasyWeChat\Tests\TestCase;
class MessageTest extends TestCase
{
public function test_message()
{
$message = new Message(['one' => 1]);
<|fim_suffix|> Message(['one' => 1]);
$this->assertSame(json_encode($me... | fim | w7corp/easywechat | php |
<|fim_suffix|>ts);
}
}
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel;
use EasyWeChat\Kernel\ServerResponse;
use Nyholm\Psr7\Response;
use PHPUnit\Framework\TestCase;
class ServerResponseTest extends TestCase
{
<|fim_middle|>public function test_to_string()
{
$response = ServerResponse::ma... | fim | w7corp/easywechat | php |
<|fim_suffix|>4PC7E/r7Z6xNrXd2UIeorGj5Ef7b1pJAYB6Y5anaHqZ9J6nKEBvB4DnNLIVWSgARns/8wR2SiRS7MNACwTyrGvt9ts8p12PKFdlqYTopNHR1Vf7XjfhQlVsAJdNiKdYmYVoKlaRv85IfVunYzO0IKXsyl7JCUjCpoG20f0a04COwfneQAGGwd5oa+T8yO5hzuyDb/XcxxmK01EpqOyuxINew==';
// encrypt
$this->assertSame($ciphertext, AesCbc::encrypt($plaintext... | fim | w7corp/easywechat | php |
<|fim_suffix|>hat\Tests\TestCase;
class AesEcbTest extends TestCase
{
public function test_it_can_encrypt_and_decrypt()
{
$key = md5('1234567890abcdef1234567890abcdef');
$plaintext = '<root><out_refund_no><![CDATA[123]]></out_refund_no><out_trade_no><![CDATA[abc]]></out_trade_no><refund_account... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Kernel\Support;
use EasyWeChat\Kernel\Support\AesGcm;
use EasyWeChat\Tests\TestCase;
class AesGcmTest extends TestCase
{
public function test_it_can_encrypt_and_decrypt()
{
// 感谢大佬 @TheNorthMemory 提供的测试数据
$key = '5YI2YwE... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Kernel\Support;
use EasyWeChat\Kernel\Exceptions\BadRequestException;
use EasyWeChat\Kernel\Support\MessageParser;
use EasyWeChat\Tests\TestCase;
class MessageParserTest extends TestCase
{
public function test_it_can_parse_json_content()
... | fim | w7corp/easywechat | php |
<|fim_suffix|>ateKey($path, 'overtrue');
$this->assertSame($contents, $key->getKey());
$this->assertSame('overtrue', $key->getPassphrase());
}
}
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel\Support;
u<|fim_middle|>se EasyWeChat\Kernel\Support\PrivateKey;
use EasyWeChat\Tests\TestCase;
c... | fim | w7corp/easywechat | php |
<|fim_suffix|>'';
$cert = new PublicKey($contents);
$this->assertSame($contents, \strval($cert));
}
public function test_create_from_path()
{
$path = __DIR__.'/../../fixtures/cert.pem';
$contents = file_get_contents($path) ?: '';
$cert = new PublicKey($path);
... | fim | w7corp/easywechat | php |
<|fim_suffix|>rsions::getVersion('w7corp/easywechat'),
php_uname('s').'/'.php_uname('r'),
\curl_version()['version']
),
UserAgent::create(['custom-part', 'custom-part2'])
);
}
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\... | fim | w7corp/easywechat | php |
<|fim_suffix|> signature: $encrypted['signature'],
timestamp: $encrypted['timestamp'],
nonce: $encrypted['nonce']
);
$this->assertSame([
'ToUserName' => 'wx5823bf96d3bd56c7',
'Encrypt' => $encrypted['ciphertext'],
'AgentID' => '218',
... | fim | w7corp/easywechat | php |
<|fim_suffix|>t9EL4EhzJWrQUax5wLVMNS0+rUPA3k22Ncx4XXZS9o0MBH27Bo6BpNelZpS+/uh9KsNlY6bHCmJU9p8g7m3fVKn28H3KDYA5Pl/T8Z1ptDAVe0lXdQ2YoyyH2uyPIGHBZZIs2pDBS8R07+qN+E7Q==]]></Encrypt>
<AgentID><![CDATA[218]]></AgentID>
</xml>';
$message = DummyMessage::createFromRequest(new ServerReque... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel\Traits;
use EasyWeChat\Kernel\Traits\InteractWithCache;
use EasyWeChat\Tests\T<|fim_suffix|>ace::class, $app->getCache());
$this->assertSame($app->getCache(), $app->getCache());
// set
$cache = \Mockery::mock(Psr16Cache::class);
$a... | fim | w7corp/easywechat | php |
<|fim_suffix|>c function createClient(): AccessTokenAwareClient
{
return new AccessTokenAwareClient;
}
}
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel\Traits;
use EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient;
use EasyWeChat\Kernel\Traits\InteractWithClient;
use EasyWeChat\Tests\TestCase... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Tests\Kernel\Traits;
use EasyWeChat\Kernel\Contracts\Config as ConfigInterface;
use EasyWeChat\Kernel\Traits\InteractWithConfig;
use EasyWeChat\Tests\TestCase;
class InteractWithConfigTest extends TestCase
{
public function test_get_and_set_config()
{
$app = new DummyClassF... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Kernel\Traits;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Traits\InteractWithHandlers;
use EasyWeChat\Tests\TestCase;
class InteractWithHandlersTest extends TestCase
{
/**
* @throws InvalidArgument... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Tests\Kernel\Traits;
use EasyWeChat\Kernel\Traits\InteractWithHttpClient;
use EasyWeChat\Tests\TestCase;
use Symfony\Component\HttpClient\CurlHttpClient;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class InteractWithHttpClientTest extends TestCase
{
public function test_get_a... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Kernel\Traits;
use EasyWeChat\Kernel\Traits\InteractWithServerRequest;
use EasyWeChat\Tests\TestCase;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\HttpFoundation\Request;
class InteractWithServerRequestTest extends TestCase
{
public function te... | fim | w7corp/easywechat | php |
<|fim_suffix|>on::class);
$this->expectExceptionMessage('Invalid Response type "object".');
$this->transformToReply(new \stdClass, \Mockery::mock(Message::class));
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid Response type "boolean".');... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\<|fim_suffix|>ken', $accessToken->getKey());
}
}
<|fim_middle|>MiniApp;
use EasyWeChat\MiniApp\AccessToken;
use EasyWeChat\Tests\TestCase;
class AccessTokenTest extends TestCase
{
public function test_it_will_use_mini_app_cache_prefix()
{
$accessToke... | fim | w7corp/easywechat | php |
<|fim_suffix|>0123456789ABCDEFG',
]
);
$this->assertInstanceOf(Encryptor::class, $app->getEncryptor());
$this->assertSame($app->getEncryptor(), $app->getEncryptor());
// set
$encryptor = new Encryptor(appId: 'wx3cf0f39249000060', token: 'mock-token', aesKey: 'abcdef... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\MiniApp;
use EasyWeChat\Kernel\Exceptions\DecryptException;
use EasyWeChat\MiniApp\Decryptor;
use EasyWeChat\Tests\TestCase;
class DecryptorTest extends TestCase
{
public function test_it_can_decrypt_message()
{
$encryptedData = 'CiyLU1Aw2KjvrjMdj8YKliAj... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\MiniApp;
use EasyWeChat\Kernel\Exceptions\HttpException;
use EasyWeChat\MiniApp\Application;
use EasyWeChat\MiniApp\Utils;
use EasyWeChat\Tests\TestCase;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\OfficialAccount;
use EasyWeChat\OfficialAccount\AccessToken;
use EasyWeChat\Tests\TestCase;
use Psr\SimpleCache\CacheInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
us<|fim_suffix|>this->assertSame($result['access_token'], $acce... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\OfficialAccount;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use EasyWeChat\OfficialAccount\Account;
use EasyWeChat\OfficialAccount\Application;
use EasyWeChat\OfficialAccount\Contracts\Account as AccountInterface;
use EasyWeChat\Tests\Te... | fim | w7corp/easywechat | php |
<|fim_suffix|>_server()
{
$app = new Application(
[
'app_id' => 'wx3cf0f39249000060',
'secret' => 'mock-secret',
'token' => 'mock-token',
'aes_key' => 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG',
]
);
... | fim | w7corp/easywechat | php |
<|fim_suffix|> 'token' => 'mock-token',
]
);
$this->assertInstanceOf(ConfigInterface::class, $app->getConfig());
}
/**
* @throws InvalidArgumentException
* @throws RuntimeException
*/
public function test_set_config_to_application()
{
$co... | fim | w7corp/easywechat | php |
<|fim_suffix|>://www.easywechat.com/', $nonce, $timestamp);
$data = [
'url' => 'https://www.easywechat.com/',
'nonceStr' => 'mock-nonce',
'timestamp' => 1601234567,
'appId' => 'mock-appid',
'signature' => '22772d2fb393ab9f7f6a5a54168a566fbf1ab767',
... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\OfficialAccount;
use EasyWeChat\Kernel\Encryptor;
use EasyWeChat\Kernel\Support\Xml;
use EasyWeChat\OfficialAccount\Server;
use EasyWeChat\Tests\TestCase;
use Nyholm\Psr7\ServerRequest;
class ServerTest extends TestCase
{
public function te... | fim | w7corp/easywechat | php |
<|fim_suffix|>f7f6a5a54168a566fbf1ab767',
];
$ticket = \Mockery::mock(JsApiTicket::class);
$ticket->shouldReceive('configSignature')->andReturn($signatue);
$app = \Mockery::mock(Application::class);
$app->allows()->getTicket()->andReturn($ticket);
$utils = new Utils($a... | fim | w7corp/easywechat | php |
<|fim_suffix|>> 'mock-aes-key',
];
$account = new Account(
appId: $config['app_id'],
secret: $config['secret'],
token: $config['token'],
aesKey: $config['aes_key']
);
$this->assertSame($config['app_id'], $account->getAppId());
}
... | fim | w7corp/easywechat | php |
<|fim_suffix|> 'authorization_code' => 'mock-auth-code',
]),
$mockResponse->getRequestOptions()['body']
);
}
public function test_get_authorization_exception()
{
$app = new Application([
'app_id' => 'wx3cf0f39249000060',
'secret' => 'mock-se... | fim | w7corp/easywechat | php |
<|fim_suffix|>fresh_token' => 'mock-refresh-token',
],
]);
$this->assertSame('mock-refresh-token', $authorization->getRefreshToken());
}
}
<|fim_prefix|><?php
namespace EasyWeChat\Tests\OpenPlatform;
use EasyWeChat\OpenPlatform\Authorization;
use EasyWeChat\OpenPlatform\AuthorizerAcce... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\OpenPlatform;
use EasyWeChat\OpenPlatform\AuthorizerAccessToken;
use<|fim_suffix|>ew AuthorizerAccessToken('mock-app-id', 'mock-access-token');
$this->assertSame('mock-app-id', $token->getAppId());
$this->assertSame('mock-access-token', $token->getToken(... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Tests\OpenPlatform;
use EasyWeChat\OpenPlatform\ComponentAccessToken;
use EasyWeChat\OpenPlatform\Contracts\VerifyTicket;
use EasyWeChat\Tests\TestCase;
use Psr\SimpleCache\CacheInterface;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockRespons... | fim | w7corp/easywechat | php |
<?php
namespace EasyWeChat\Tests\OpenPlatform;
use EasyWeChat\Kernel\Encryptor;
use EasyWeChat\OpenPlatform\Server;
use EasyWeChat\Tests\TestCase;
class ServerTest extends TestCase
{
public function test_it_will_handle_authorized_event()
{
$body = '<xml>
<AppId>第三方平台appid</AppId>
... | fim | w7corp/easywechat | php |
<|fim_suffix|>=> 101111111,
'secret_key' => 'mock-secret-key',
'private_key' => 'mock-private-key',
'certificate' => '/path/to/certificate.cert',
'certificate_serial_no' => 'MOCK-CERTIFICATE-SERIAL-NO',
]
);
$this->assertInstan... | fim | w7corp/easywechat | php |
<|fim_suffix|>t::mock('{"retcode":-1,"access_token":"mock-token"}', 200, ['Content-Type' => 'application/json']);
$client->shouldReceive('createSignature')->never();
$client->shouldReceive('isV3Request')->andReturn(false);
$client->shouldReceive('attachLegacySignature')->with([
'foo'... | fim | w7corp/easywechat | php |
<|fim_suffix|>cKey, $merchant->getCertificate());
}
}
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Pay;
use EasyWeChat\Kernel\Support\PrivateKey;
use EasyWeChat\Kernel\Support\PublicKey;
use EasyWeChat\Pay\Merchant;
use EasyWeChat\Tests\TestCase;
class MerchantTest extends TestCase
{
... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Pay;
use EasyWeChat\Kernel\Support\AesEcb;
use EasyWeChat\Kernel\Support\AesGcm;
use EasyWeChat\Kernel\Support<|fim_suffix|>ntent-Type' => 'text/xml',
],
Xml::build([
'return_code' => 'SUCCESS',
... | fim | w7corp/easywechat | php |
<|fim_suffix|> secretKey: 'v3SecretKey',
v2SecretKey: 'v2SecretKey',
platformCerts: [
'PUB_KEY_ID_MOCK' => '-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlReZ1YnfAohRIfUqIeyP
aO0PlkMw1RLPdZbEZmldbGrIrOh/0XqSzNZ+mtB6H0eB7TSaoGFtdp/AWy3tb67m
1T62OrEh... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests;
use EasyWeChat\Kernel\Encryptor;
use EasyWeChat\Kernel\Support\Xml;
use Nyholm\Psr7\ServerRequest;
use PHPUnit\Framework\TestCase as BaseTestCase;
class TestCase extends BaseTestCase
{
/**
* Tear down the test case.
*/
protec... | fim | w7corp/easywechat | php |
<|fim_suffix|>config['corp_id'], $config['secret'], $key, $cache);
$this->assertSame($result['access_token'], $accessToken->getToken());
}
public function test_set_key()
{
$config = [
'corp_id' => 'wx3cf0f39249000060',
'secret' => 'mock-secret',
];
... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Work;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\Account;
use EasyWeChat\Work\Application;
use EasyWeChat\Work\Contracts\Account as AccountInterface;
class AccountTest extends TestCase
... | fim | w7corp/easywechat | php |
<|fim_suffix|>t());
// set
$client = new AccessTokenAwareClient;
$app->setHttpClient($client);
$this->assertSame($client, $app->getHttpClient());
}
public function test_get_and_set_access_token()
{
$app = new Application(
[
'corp_id' => '... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Work;
use EasyWeChat\Kernel\Contracts\Config as ConfigInterface;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\Application;
use Ea... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Work;
use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\JsApiTicket;
use Psr\SimpleCache\CacheInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
class JsApiTicketTest extends TestCase
{
public functi... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
declare(strict_types=1);
namespace EasyWeChat\Tests\Work;
use EasyWeChat\Kernel\Support\Xml;
use EasyWeChat\Kernel\Traits\DecryptMessage;
use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\Application;
use Nyholm\Psr7\ServerRequest;
class ServerTest extends TestCase
{
use DecryptMessage;
... | fim | w7corp/easywechat | php |
<|fim_prefix|><?php
namespace EasyWeChat\Tests\Work;
use EasyWeChat\Tests\TestCase;
use EasyWeChat\Work\Application;
use EasyWeChat\Work\JsApiTicket;
use EasyWeChat\Work\Utils;
class UtilsTest extends TestCase
{
public function test_build_js_sdk_config()
{
$data = [
'jsApiList' => ['api1'... | fim | w7corp/easywechat | php |
<|fim_suffix|>DIR__.'/fixtures');
$_SERVER['HTTP_HOST'] = 'localhost';
include __DIR__.'/../vendor/autoload.php';
<|fim_prefix|><?php
declare(strict_types=1);
/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <i@<|fim_middle|>overtrue.me>
*
* This source file is subject to the MIT license that is... | fim | w7corp/easywechat | php |
<|fim_suffix|>.ENDC}")
sys.exit(1)
<|fim_prefix|>#!/us<|fim_middle|>r/bin/env python3
import subprocess
import sys
import shlex
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BO... | fim | wagoodman/dive | python |
<|fim_suffix|>nd(
clio.VersionCommand(id),
clio.ConfigCommand(app, nil),
command.Build(app),
)
return app, rootCmd
}
<|fim_prefix|>package cli
import (
"github.com/anchore/clio"
"github.com/spf13/cobra"
"github.com/wagoodman/dive/cmd/dive/cli/internal/command"
"github.com/wagoodman/dive/cmd/dive/cli/inter... | fim | wagoodman/dive | go |
<|fim_suffix|>like "docker-desktop://dashboard/build/desktop-linux/desktop-linux/ujdmhgkwo0sqqpopsnum3xakd"
combined = regexp.MustCompile("docker-desktop://[^ ]+").ReplaceAllString(combined, "docker-desktop://<redacted>")
snaps.MatchSnapshot(t, combined)
})
}
<|fim_prefix|>package cli
import (
"github.com/stret... | fim | wagoodman/dive | go |
<|fim_prefix|>package cli
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func Test_CI_DefaultCIConfig(t *testing.T) {
// this lets the test harness to unset any DIVE_CONFIG env var
t.Setenv("DIVE_CONFIG", "-")
rootCmd := getTestCommand(t, repoPath(t, ".data/test... | fim | wagoodman/dive | go |
<|fim_suffix|>E_CONFIG", "./testdata/image-multi-layer-dockerfile/dive-pass.yaml")
rootCmd := getTestCommand(t, "config --load")
all := Capture().All().Run(t, func() {
require.NoError(t, rootCmd.Execute())
})
snaps.MatchSnapshot(t, all)
}
<|fim_prefix|>packag<|fim_middle|>e cli
import (
"github.com/stretchr/t... | fim | wagoodman/dive | go |
<|fim_prefix|>package cli
import (
<|fim_suffix|>:= filepath.Join(dest, "output.json")
rootCmd := getTestCommand(t, "busybox:1.37.0@sha256:ad9fa4d07136a83e69a54ef00102f579d04eba431932de3b0f098cc5d5948f9f --json "+file)
combined := Capture().WithStdout().WithStderr().Run(t, func() {
require.NoError(t, rootCmd.E... | fim | wagoodman/dive | go |
<|fim_prefix|>package cli
import (
"fmt"
"github.com/stretchr/testify/a<|fim_suffix|>ithStderr().Run(t, func() {
require.ErrorContains(t, rootCmd.Execute(), "cannot load image: Error response from daemon: invalid reference format")
})
assert.Contains(t, combined, "Loading image")
snaps.MatchSnapshot(t, co... | fim | wagoodman/dive | go |
<|fim_prefix|>package cli
import (
"bytes"
"flag"
"github.com/anchore/clio"
"github.com/charmbracelet/lipgloss"
snapsPkg "github.com/gkampitakis/go-snaps/snaps"
"github.com/google/shlex"
"github.com/muesli/termenv"
"github.com/spf13/cobra"
"github.com/stretchr/testify/require"
"go.uber.org/atomic"
"io"
"os... | fim | wagoodman/dive | go |
<|fim_prefix|>package adapter
import (
"context"
"fmt"
"github.com/dustin/go-humanize"
"github.com/wagoodman/dive/dive/image"
"github.com/wagoodman/dive/internal/bus"
"github.com/wagoodman/dive/internal/bus/event/payload"
"github.com/wagoodman/dive/internal/log"
)
type Analyzer interface {
Analyze(ctx context... | fim | wagoodman/dive | go |
<|fim_suffix|>f("failed evaluation"))
}
bus.Report(eval.Report)
return eval
}
<|fim_prefix|>package adapter
import (
"context"
"fmt"
"github.com/wagoodman/dive/cmd/dive/cli/internal/command/ci"
"github.com/wagoodman/dive/dive/image"
"github.com/wagoodman/dive/internal/bus"
"github.com/wagoodman/dive/internal/... | fim | wagoodman/dive | go |
<|fim_suffix|>f("cannot open export file: %w", err)
}
defer file.Close()
_, err = file.Write(bytes)
if err != nil {
return fmt.Errorf("cannot write to export file: %w", err)
}
return nil
}
<|fim_prefix|>package adapter
import (
"context"
"fmt"
"github.com/spf13/afero"
"github.com/wagoodman/dive/cmd/dive/c... | fim | wagoodman/dive | go |
<|fim_suffix|>d()
}
return img, err
}
func (i imageActionObserver) Fetch(ctx context.Context, id string) (*image.Image, error) {
log.WithFields("image", id).Info("fetching")
log.Debugf("└── resolver: %s", i.Resolver.Name())
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mon := bus.StartTask(payload.Gen... | fim | wagoodman/dive | go |
<|fim_prefix|>package command
import (
"fmt"
"github.com/anchore/clio"
"github.com/spf13/cobra"
"github.com/wagoodman/dive/cmd/dive/cli/internal/command/adapter"
"github.com/wagoodman/dive/cmd/dive/cli/internal/options"
"github.com/wagoodman/dive/dive"
)
type buildO<|fim_suffix|>termine image provider for build... | fim | wagoodman/dive | go |
<|fim_prefix|>package ci
import (
"fmt"
"github.com/charmbracelet/lipgloss"
"golang.org/x/net/context"
"sort"
"strconv"
"strings"
"github.com/dustin/go-humanize"
"github.com/wagoodman/dive/dive/image"
)
type Evaluation struct {
Report string
Pass bool
}
type Evaluator struct {
Rules []Rule
... | fim | wagoodman/dive | go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.