From 1fb48bb1e604abfada44059b459fb3f571f90daf Mon Sep 17 00:00:00 2001 From: overtrue Date: Fri, 9 Jun 2017 13:47:40 +0800 Subject: [PATCH] Trait InteractsWithCache. #670 --- .gitignore | 1 + .php_cs | 29 +- composer.json | 4 +- src/Application.php | 318 ------------------ src/Applications/MiniProgram/MiniProgram.php | 32 +- .../OfficialAccount/Application.php | 70 ++++ .../OfficialAccount/Broadcast/Client.php | 2 +- .../OfficialAccount/Card/Client.php | 2 +- .../OfficialAccount/Comment/Client.php | 2 +- .../OfficialAccount/Core/ServiceProvider.php | 4 +- .../CustomerService/Client.php | 2 +- .../CustomerService/SessionClient.php | 2 +- .../OfficialAccount/Device/Client.php | 2 +- .../OfficialAccount/Js/Client.php | 2 +- .../OfficialAccount/Material/Client.php | 2 +- .../Material/TemporaryClient.php | 2 +- .../OfficialAccount/Menu/Client.php | 2 +- .../Message/AbstractMessage.php | 4 +- .../OfficialAccount/OfficialAccount.php | 67 ---- .../OfficialAccount/POI/Client.php | 2 +- .../OfficialAccount/Payment/Client.php | 2 +- .../OfficialAccount/Payment/Merchant.php | 4 +- .../OfficialAccount/Payment/Order.php | 4 +- .../OfficialAccount/QRCode/Client.php | 2 +- .../OfficialAccount/Reply/Client.php | 2 +- .../OfficialAccount/Semantic/Client.php | 2 +- .../OfficialAccount/Stats/Client.php | 2 +- .../OfficialAccount/Store/Client.php | 2 +- .../TemplateMessage/Client.php | 4 +- .../OfficialAccount/Url/Client.php | 2 +- .../OfficialAccount/User/GroupClient.php | 2 +- .../OfficialAccount/User/TagClient.php | 2 +- .../OfficialAccount/User/UserClient.php | 2 +- .../{OpenPlatform.php => Application.php} | 17 +- .../OpenPlatform/Server/Guard.php | 4 +- .../OpenPlatform/ServiceProvider.php | 8 +- src/Applications/WeWork/Application.php | 30 ++ .../WeWork/Core/ServiceProvider.php | 4 +- src/Applications/WeWork/WeWork.php | 24 -- src/Factory.php | 83 +++++ src/Support/Arr.php | 11 - .../{Attribute.php => HasAttributes.php} | 101 +++--- src/Support/InteractsWithCache.php | 52 +++ src/Support/Str.php | 15 +- src/Support/Traits/PrefixedContainer.php | 99 ------ src/Support/Url.php | 10 +- src/Support/XML.php | 10 - .../Applications/WeWork/Agent/ClientTest.php | 6 +- .../WeWork/Attendance/ClientTest.php | 2 +- .../WeWork/Department/ClientTest.php | 12 +- tests/Foundation/ApplicationTest.php | 44 +-- tests/Foundation/Core/AbstractAPITest.php | 6 +- .../Core/AccessTokenAtrributesTest.php | 30 +- tests/Foundation/Core/HttpTest.php | 60 ++-- tests/MiniProgram/EncryptorTest.php | 4 +- .../MiniProgramServerGuardTest.php | 10 +- tests/MiniProgram/Stats/StatsTest.php | 36 +- .../OfficialAccount/Broadcast/ClientTest.php | 50 +-- .../Broadcast/MessageBuilderTest.php | 22 +- .../Broadcast/TransformerTest.php | 16 +- tests/OfficialAccount/Card/ClientTest.php | 110 +++--- tests/OfficialAccount/Comment/ClientTest.php | 16 +- .../Core/CoreAccessTokenTest.php | 27 +- .../CustomerService/ClientTest.php | 14 +- .../CustomerService/MessageBuilderTest.php | 20 +- .../CustomerService/SessionTest.php | 8 +- .../CustomerService/TransformerTest.php | 30 +- .../Encryption/EncryptionEncryptorTest.php | 14 +- .../Fundamental/ClientTest.php | 4 +- tests/OfficialAccount/Js/ClientTest.php | 30 +- tests/OfficialAccount/Material/ClientTest.php | 28 +- .../Material/TemporaryClientTest.php | 18 +- tests/OfficialAccount/Menu/ClientTest.php | 10 +- .../Message/MessageAbstractMessageTest.php | 8 +- .../Message/MessageArticleTest.php | 6 +- .../Message/MessageImageTest.php | 4 +- .../Message/MessageMaterialTest.php | 4 +- .../Message/MessageVideoTest.php | 8 +- .../Message/MessageVoiceTest.php | 4 +- tests/OfficialAccount/POI/ClientTest.php | 12 +- .../Payment/CashCouponClientTest.php | 24 +- .../Payment/LuckyMoneyClientTest.php | 42 +-- .../Payment/LuckyMoneyTest.php | 6 +- tests/OfficialAccount/Payment/NotifyTest.php | 2 +- .../Payment/PaymentClientTest.php | 106 +++--- tests/OfficialAccount/Payment/PaymentTest.php | 38 +-- tests/OfficialAccount/QRCode/ClientTest.php | 30 +- tests/OfficialAccount/Semantic/ClientTest.php | 8 +- .../Server/ServerGuardTest.php | 26 +- .../Server/ServerTransformerTest.php | 26 +- .../ShakeAround/DeviceTest.php | 20 +- .../OfficialAccount/ShakeAround/GroupTest.php | 14 +- .../ShakeAround/MaterialTest.php | 4 +- .../OfficialAccount/ShakeAround/PageTest.php | 14 +- .../ShakeAround/RelationTest.php | 10 +- .../ShakeAround/ShakeAroundTest.php | 8 +- .../OfficialAccount/ShakeAround/StatsTest.php | 8 +- tests/OfficialAccount/Stats/ClientTest.php | 88 ++--- .../TemplateMessage/ClientTest.php | 66 ++-- tests/OfficialAccount/Url/ClientTest.php | 4 +- tests/OfficialAccount/User/UserClientTest.php | 22 +- .../User/UserGroupClientTest.php | 12 +- tests/OpenPlatform/Api/ApiTest.php | 2 +- tests/OpenPlatform/Api/BaseApiTest.php | 10 +- .../OpenPlatform/Api/PreAuthorizationTest.php | 6 +- .../AuthorizerAccessTokenTest.php | 12 +- .../ComponentVerifyTicketTest.php | 2 +- tests/OpenPlatform/GuardTest.php | 4 +- tests/OpenPlatform/OpenPlatformTest.php | 8 +- tests/OpenPlatform/VerifyTicketTest.php | 6 +- .../Support/Traits/PrefixedContainerTest.php | 4 +- 111 files changed, 1023 insertions(+), 1333 deletions(-) delete mode 100644 src/Application.php create mode 100644 src/Applications/OfficialAccount/Application.php delete mode 100644 src/Applications/OfficialAccount/OfficialAccount.php rename src/Applications/OpenPlatform/{OpenPlatform.php => Application.php} (85%) create mode 100644 src/Applications/WeWork/Application.php delete mode 100644 src/Applications/WeWork/WeWork.php create mode 100644 src/Factory.php rename src/Support/{Attribute.php => HasAttributes.php} (71%) create mode 100644 src/Support/InteractsWithCache.php delete mode 100644 src/Support/Traits/PrefixedContainer.php diff --git a/.gitignore b/.gitignore index 11d4f46f0..d5b2f671a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ sftp-config.json /coverage /.split /composer.lock +.php_cs.cache \ No newline at end of file diff --git a/.php_cs b/.php_cs index 6deaff24b..9c22a912d 100755 --- a/.php_cs +++ b/.php_cs @@ -9,20 +9,21 @@ This source file is subject to the MIT license that is bundled with this source code in the file LICENSE. EOF; -Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header); - -return Symfony\CS\Config\Config::create() - // use default SYMFONY_LEVEL and extra fixers: - ->fixers(array( - 'header_comment', - 'short_array_syntax', - 'ordered_use', - 'php_unit_construct', - 'strict', - 'strict_param', +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules(array( + '@Symfony' => true, + 'header_comment' => array('header' => $header), + 'array_syntax' => array('syntax' => 'short'), + 'ordered_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'php_unit_construct' => true, + 'php_unit_strict' => true, )) - ->finder( - Symfony\CS\Finder\DefaultFinder::create() - ->in(__DIR__.'/src') + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->in(__DIR__) ) ; \ No newline at end of file diff --git a/composer.json b/composer.json index 7ce616997..05aa3a336 100644 --- a/composer.json +++ b/composer.json @@ -20,10 +20,10 @@ "pimple/pimple": "~3.0", "monolog/monolog": "^1.22", "overtrue/socialite": ">=1.0.25", - "doctrine/cache": "~1.6", "guzzlehttp/guzzle": "~6.2.1", "symfony/http-foundation": "~2.6|~2.7|~2.8|~3.0", - "symfony/psr-http-message-bridge": "~0.3|^1.0" + "symfony/psr-http-message-bridge": "~0.3|^1.0", + "symfony/cache": "^3.3" }, "require-dev": { "phpunit/phpunit": "~6.0", diff --git a/src/Application.php b/src/Application.php deleted file mode 100644 index b24f1df4f..000000000 --- a/src/Application.php +++ /dev/null @@ -1,318 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Application.php. - * - * Part of Overtrue\WeChat. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @author overtrue - * @copyright 2015 - * - * @see https://github.com/overtrue - * @see http://overtrue.me - */ - -namespace EasyWeChat; - -use Doctrine\Common\Cache\Cache as CacheInterface; -use Doctrine\Common\Cache\FilesystemCache; -use EasyWeChat\Applications\Base\Core\Http; -use EasyWeChat\Config\Repository as Config; -use EasyWeChat\Exceptions\FaultException; -use EasyWeChat\Support\Log; -use Monolog\Handler\HandlerInterface; -use Monolog\Handler\NullHandler; -use Monolog\Handler\StreamHandler; -use Monolog\Logger; -use Pimple\Container; -use Symfony\Component\HttpFoundation\Request; - -/** - * @method static \EasyWeChat\Applications\WeWork\WeWork wework(array $config) - * @method static \EasyWeChat\Applications\MiniProgram\MiniProgram miniProgram(array $config) - * @method static \EasyWeChat\Applications\OpenPlatform\OpenPlatform openPlatform(array $config) - * @method static \EasyWeChat\Applications\OfficialAccount\OfficialAccount officialAccount(array $config) - */ -class Application extends Container -{ - /** - * Service Providers. - * - * @var array - */ - protected $providers = [ - /* - * OfficialAccount Service Providers... - */ - \EasyWeChat\Applications\OfficialAccount\Core\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Server\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\User\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Js\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\OAuth\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Menu\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\TemplateMessage\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Material\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\CustomerService\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Url\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\QRCode\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Semantic\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Stats\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Payment\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\POI\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Reply\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Broadcast\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Card\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Device\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\ShakeAround\ServiceProvider::class, - \EasyWeChat\Applications\OfficialAccount\Comment\ServiceProvider::class, - - /* - * OpenPlatform Service Providers... - */ - \EasyWeChat\Applications\OpenPlatform\ServiceProvider::class, - \EasyWeChat\Applications\OpenPlatform\Core\ServiceProvider::class, - \EasyWeChat\Applications\OpenPlatform\Server\ServiceProvider::class, - - /* - * MiniProgram Service Providers... - */ - \EasyWeChat\Applications\MiniProgram\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\Sns\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\Stats\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\QRCode\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\Server\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\Material\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\CustomerService\ServiceProvider::class, - \EasyWeChat\Applications\MiniProgram\TemplateMessage\ServiceProvider::class, - - /* - * WeWork Service Providers... - */ - \EasyWeChat\Applications\WeWork\Core\ServiceProvider::class, - \EasyWeChat\Applications\WeWork\Department\ServiceProvider::class, - \EasyWeChat\Applications\WeWork\Attendance\ServiceProvider::class, - \EasyWeChat\Applications\WeWork\Agent\ServiceProvider::class, - ]; - - /** - * Application constructor. - * - * @param array $config - */ - public function __construct($config) - { - parent::__construct(); - - $this['config'] = function () use ($config) { - return new Config($config); - }; - - if ($this['config']['debug']) { - error_reporting(E_ALL); - } - - $this->registerProviders(); - $this->registerBase(); - $this->initializeLogger(); - - Http::setDefaultOptions($this['config']->get('guzzle', ['timeout' => 5.0])); - - $this->logConfiguration($config); - } - - /** - * Log configuration. - * - * @param array $config - */ - public function logConfiguration($config) - { - $config = new Config($config); - - $keys = ['app_id', 'secret', 'open_platform.app_id', 'open_platform.secret', 'mini_program.app_id', 'mini_program.secret']; - foreach ($keys as $key) { - !$config->has($key) || $config[$key] = '***'.substr($config[$key], -5); - } - - Log::debug('Current config:', $config->toArray()); - } - - /** - * Add a provider. - * - * @param string $provider - * - * @return Application - */ - public function addProvider($provider) - { - array_push($this->providers, $provider); - - return $this; - } - - /** - * Set providers. - * - * @param array $providers - */ - public function setProviders(array $providers) - { - $this->providers = []; - - foreach ($providers as $provider) { - $this->addProvider($provider); - } - } - - /** - * Return all providers. - * - * @return array - */ - public function getProviders() - { - return $this->providers; - } - - /** - * Magic get access. - * - * @param string $id - * - * @return mixed - */ - public function __get($id) - { - return $this->offsetGet($id); - } - - /** - * Magic set access. - * - * @param string $id - * @param mixed $value - */ - public function __set($id, $value) - { - $this->offsetSet($id, $value); - } - - /** - * Register providers. - */ - private function registerProviders() - { - foreach ($this->providers as $provider) { - $this->register(new $provider()); - } - } - - /** - * Register basic providers. - */ - private function registerBase() - { - $this['request'] = function () { - return Request::createFromGlobals(); - }; - - if (!empty($this['config']['cache']) && $this['config']['cache'] instanceof CacheInterface) { - $this['cache'] = $this['config']['cache']; - } else { - $this['cache'] = function () { - return new FilesystemCache(sys_get_temp_dir()); - }; - } - } - - /** - * Initialize logger. - */ - private function initializeLogger() - { - if (Log::hasLogger()) { - return; - } - - $logger = new Logger('easywechat'); - - if (!$this['config']['debug'] || defined('PHPUNIT_RUNNING')) { - $logger->pushHandler(new NullHandler()); - } elseif ($this['config']['log.handler'] instanceof HandlerInterface) { - $logger->pushHandler($this['config']['log.handler']); - } elseif ($logFile = $this['config']['log.file']) { - $logger->pushHandler(new StreamHandler( - $logFile, - $this['config']->get('log.level', Logger::WARNING), - true, - $this['config']->get('log.permission', null)) - ); - } - - Log::setLogger($logger); - } - - /** - * Get the instance from the container. - * - * @param string $name - * @param array $arguments - * - * @return mixed - */ - public static function make($name, array $arguments) - { - return (new self($arguments))->offsetGet( - self::applicationInstanceKey($name) - ); - } - - /** - * Get the application instance key. - * - * @param string $name - * - * @return mixed - * - * @throws \EasyWeChat\Exceptions\FaultException - */ - protected static function applicationInstanceKey($name) - { - $applications = [ - 'weWork' => 'we_work.instance', - 'miniProgram' => 'mini_program.instance', - 'openPlatform' => 'open_platform.instance', - 'officialAccount' => 'official_account.instance', - ]; - - return $applications[$name] ?? (function () use ($name) { - throw new FaultException("No application named '{$name}'"); - })(); - } - - /** - * Dynamically pass methods to the application. - * - * @param string $name - * @param array $arguments - * - * @return mixed - */ - public static function __callStatic($name, $arguments) - { - return self::make($name, ...$arguments); - } -} diff --git a/src/Applications/MiniProgram/MiniProgram.php b/src/Applications/MiniProgram/MiniProgram.php index 3c788db95..6dfcfb68f 100644 --- a/src/Applications/MiniProgram/MiniProgram.php +++ b/src/Applications/MiniProgram/MiniProgram.php @@ -9,28 +9,15 @@ * with this source code in the file LICENSE. */ -/** - * MiniProgram.php. - * - * Part of Overtrue\WeChat. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @author mingyoung - * @copyright 2016 - * - * @see https://github.com/overtrue - * @see http://overtrue.me - */ - namespace EasyWeChat\Applications\MiniProgram; -use EasyWeChat\Support\Traits\PrefixedContainer; +use EasyWeChat\Support\ServiceContainer; /** * Class MiniProgram. * + * @author mingyoung + * * @property \EasyWeChat\Applications\MiniProgram\Sns\Sns $sns * @property \EasyWeChat\Applications\MiniProgram\Stats\Stats $stats * @property \EasyWeChat\Applications\MiniProgram\Server\Guard $server @@ -39,7 +26,16 @@ * @property \EasyWeChat\Applications\MiniProgram\Material\Temporary $material_temporary * @property \EasyWeChat\Applications\MiniProgram\CustomerService\CustomerService $customer_service */ -class MiniProgram +class MiniProgram extends ServiceContainer { - use PrefixedContainer; + protected $providers = [ + \EasyWeChat\Applications\MiniProgram\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\Sns\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\Stats\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\QRCode\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\Server\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\Material\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\CustomerService\ServiceProvider::class, + \EasyWeChat\Applications\MiniProgram\TemplateMessage\ServiceProvider::class, + ]; } diff --git a/src/Applications/OfficialAccount/Application.php b/src/Applications/OfficialAccount/Application.php new file mode 100644 index 000000000..ceb74b439 --- /dev/null +++ b/src/Applications/OfficialAccount/Application.php @@ -0,0 +1,70 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\Applications\OfficialAccount; + +use EasyWeChat\Applications\OfficialAccount; +use EasyWeChat\Support\ServiceContainer; + +/* + * @property \EasyWeChat\Applications\Application\Core\AccessToken $access_token + * @property \EasyWeChat\Applications\Application\Server\Guard $server + * @property \EasyWeChat\Applications\Application\User\User $user + * @property \EasyWeChat\Applications\Application\User\Tag $user_tag + * @property \EasyWeChat\Applications\Application\User\Group $user_group + * @property \EasyWeChat\Applications\Application\Js\Js $js + * @property \Overtrue\Socialite\Providers\WeChatProvider $oauth + * @property \EasyWeChat\Applications\Application\Menu\Menu $menu + * @property \EasyWeChat\Applications\Application\TemplateMessage\TemplateMessage $template_message + * @property \EasyWeChat\Applications\Application\Material\Material $material + * @property \EasyWeChat\Applications\Application\Material\Temporary $material_temporary + * @property \EasyWeChat\Applications\Application\CustomerService\CustomerService $customer_service + * @property \EasyWeChat\Applications\Application\Url\Url $url + * @property \EasyWeChat\Applications\Application\QRCode\QRCode $qrcode + * @property \EasyWeChat\Applications\Application\Semantic\Semantic $semantic + * @property \EasyWeChat\Applications\Application\Stats\Stats $stats + * @property \EasyWeChat\Applications\Application\Payment\Merchant $merchant + * @property \EasyWeChat\Applications\Application\Payment\Payment $payment + * @property \EasyWeChat\Applications\Application\Payment\LuckyMoney\LuckyMoney $lucky_money + * @property \EasyWeChat\Applications\Application\Payment\MerchantPay\MerchantPay $merchant_pay + * @property \EasyWeChat\Applications\Application\Payment\CashCoupon\CashCoupon $cash_coupon + * @property \EasyWeChat\Applications\Application\Reply\Reply $reply + * @property \EasyWeChat\Applications\Application\Broadcast\Broadcast $broadcast + * @property \EasyWeChat\Applications\Application\Card\Card $card + * @property \EasyWeChat\Applications\Application\Device\Device $device + * @property \EasyWeChat\Applications\Application\ShakeAround\ShakeAround $shakearound + */ +class Application extends ServiceContainer +{ + protected $providers = [ + OfficialAccount\Core\ServiceProvider::class, + OfficialAccount\Server\ServiceProvider::class, + OfficialAccount\User\ServiceProvider::class, + OfficialAccount\Js\ServiceProvider::class, + OfficialAccount\OAuth\ServiceProvider::class, + OfficialAccount\Menu\ServiceProvider::class, + OfficialAccount\TemplateMessage\ServiceProvider::class, + OfficialAccount\Material\ServiceProvider::class, + OfficialAccount\CustomerService\ServiceProvider::class, + OfficialAccount\Url\ServiceProvider::class, + OfficialAccount\QRCode\ServiceProvider::class, + OfficialAccount\Semantic\ServiceProvider::class, + OfficialAccount\Stats\ServiceProvider::class, + OfficialAccount\Payment\ServiceProvider::class, + OfficialAccount\POI\ServiceProvider::class, + OfficialAccount\Reply\ServiceProvider::class, + OfficialAccount\Broadcast\ServiceProvider::class, + OfficialAccount\Card\ServiceProvider::class, + OfficialAccount\Device\ServiceProvider::class, + OfficialAccount\ShakeAround\ServiceProvider::class, + OfficialAccount\Comment\ServiceProvider::class, + ]; +} diff --git a/src/Applications/OfficialAccount/Broadcast/Client.php b/src/Applications/OfficialAccount/Broadcast/Client.php index f1d6f8933..bb591634d 100644 --- a/src/Applications/OfficialAccount/Broadcast/Client.php +++ b/src/Applications/OfficialAccount/Broadcast/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Broadcast Client. + * Application Broadcast Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Card/Client.php b/src/Applications/OfficialAccount/Card/Client.php index 7727d513b..12c101a8c 100644 --- a/src/Applications/OfficialAccount/Card/Client.php +++ b/src/Applications/OfficialAccount/Card/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Card Client. + * Application Card Client. * * @author overtrue * @copyright 2016 overtrue diff --git a/src/Applications/OfficialAccount/Comment/Client.php b/src/Applications/OfficialAccount/Comment/Client.php index 671d505ca..28069e574 100644 --- a/src/Applications/OfficialAccount/Comment/Client.php +++ b/src/Applications/OfficialAccount/Comment/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Comment Client. + * Application Comment Client. * * Part of Overtrue\WeChat. * diff --git a/src/Applications/OfficialAccount/Core/ServiceProvider.php b/src/Applications/OfficialAccount/Core/ServiceProvider.php index 29360b3fa..45f71623f 100644 --- a/src/Applications/OfficialAccount/Core/ServiceProvider.php +++ b/src/Applications/OfficialAccount/Core/ServiceProvider.php @@ -26,7 +26,7 @@ namespace EasyWeChat\Applications\OfficialAccount\Core; -use EasyWeChat\Applications\OfficialAccount\OfficialAccount; +use EasyWeChat\Applications\OfficialAccount\Application; use Pimple\Container; use Pimple\ServiceProviderInterface; @@ -38,7 +38,7 @@ class ServiceProvider implements ServiceProviderInterface public function register(Container $container) { $container['official_account.instance'] = function ($container) { - return new OfficialAccount($container); + return new Application($container); }; $container['official_account.access_token'] = function ($container) { diff --git a/src/Applications/OfficialAccount/CustomerService/Client.php b/src/Applications/OfficialAccount/CustomerService/Client.php index 800c0ad7a..e78616686 100644 --- a/src/Applications/OfficialAccount/CustomerService/Client.php +++ b/src/Applications/OfficialAccount/CustomerService/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount CustomerService Client. + * Application CustomerService Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/CustomerService/SessionClient.php b/src/Applications/OfficialAccount/CustomerService/SessionClient.php index ad14fb282..91cb4173d 100644 --- a/src/Applications/OfficialAccount/CustomerService/SessionClient.php +++ b/src/Applications/OfficialAccount/CustomerService/SessionClient.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount CustomerService Session Client. + * Application CustomerService Session Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Device/Client.php b/src/Applications/OfficialAccount/Device/Client.php index 576156f9e..04cacc901 100644 --- a/src/Applications/OfficialAccount/Device/Client.php +++ b/src/Applications/OfficialAccount/Device/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Device Client. + * Application Device Client. * * @author soone <66812590@qq.com> * @copyright 2016 soone <66812590@qq.com> diff --git a/src/Applications/OfficialAccount/Js/Client.php b/src/Applications/OfficialAccount/Js/Client.php index ea244b03b..eba7e5caa 100644 --- a/src/Applications/OfficialAccount/Js/Client.php +++ b/src/Applications/OfficialAccount/Js/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Js Client. + * Application Js Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Material/Client.php b/src/Applications/OfficialAccount/Material/Client.php index fd491d0e4..52fd9edcc 100644 --- a/src/Applications/OfficialAccount/Material/Client.php +++ b/src/Applications/OfficialAccount/Material/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Material Client. + * Application Material Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Material/TemporaryClient.php b/src/Applications/OfficialAccount/Material/TemporaryClient.php index b2f59d8f7..4c9ddcad8 100644 --- a/src/Applications/OfficialAccount/Material/TemporaryClient.php +++ b/src/Applications/OfficialAccount/Material/TemporaryClient.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Temporary Material Client. + * Application Temporary Material Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Menu/Client.php b/src/Applications/OfficialAccount/Menu/Client.php index 9785d1119..512a1dff0 100644 --- a/src/Applications/OfficialAccount/Menu/Client.php +++ b/src/Applications/OfficialAccount/Menu/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Menu Client. + * Application Menu Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Message/AbstractMessage.php b/src/Applications/OfficialAccount/Message/AbstractMessage.php index 524018b78..c6362945d 100644 --- a/src/Applications/OfficialAccount/Message/AbstractMessage.php +++ b/src/Applications/OfficialAccount/Message/AbstractMessage.php @@ -21,12 +21,12 @@ namespace EasyWeChat\Applications\OfficialAccount\Message; -use EasyWeChat\Support\Attribute; +use EasyWeChat\Support\HasAttributes; /** * Class AbstractMessage. */ -abstract class AbstractMessage extends Attribute +abstract class AbstractMessage extends HasAttributes { /** * Message type. diff --git a/src/Applications/OfficialAccount/OfficialAccount.php b/src/Applications/OfficialAccount/OfficialAccount.php deleted file mode 100644 index dfaa690ac..000000000 --- a/src/Applications/OfficialAccount/OfficialAccount.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace EasyWeChat\Applications\OfficialAccount; - -use BadMethodCallException; -use EasyWeChat\Support\Traits\PrefixedContainer; - -/* - * @property \EasyWeChat\Applications\OfficialAccount\Core\AccessToken $access_token - * @property \EasyWeChat\Applications\OfficialAccount\Server\Guard $server - * @property \EasyWeChat\Applications\OfficialAccount\User\User $user - * @property \EasyWeChat\Applications\OfficialAccount\User\Tag $user_tag - * @property \EasyWeChat\Applications\OfficialAccount\User\Group $user_group - * @property \EasyWeChat\Applications\OfficialAccount\Js\Js $js - * @property \Overtrue\Socialite\Providers\WeChatProvider $oauth - * @property \EasyWeChat\Applications\OfficialAccount\Menu\Menu $menu - * @property \EasyWeChat\Applications\OfficialAccount\TemplateMessage\TemplateMessage $template_message - * @property \EasyWeChat\Applications\OfficialAccount\Material\Material $material - * @property \EasyWeChat\Applications\OfficialAccount\Material\Temporary $material_temporary - * @property \EasyWeChat\Applications\OfficialAccount\CustomerService\CustomerService $customer_service - * @property \EasyWeChat\Applications\OfficialAccount\Url\Url $url - * @property \EasyWeChat\Applications\OfficialAccount\QRCode\QRCode $qrcode - * @property \EasyWeChat\Applications\OfficialAccount\Semantic\Semantic $semantic - * @property \EasyWeChat\Applications\OfficialAccount\Stats\Stats $stats - * @property \EasyWeChat\Applications\OfficialAccount\Payment\Merchant $merchant - * @property \EasyWeChat\Applications\OfficialAccount\Payment\Payment $payment - * @property \EasyWeChat\Applications\OfficialAccount\Payment\LuckyMoney\LuckyMoney $lucky_money - * @property \EasyWeChat\Applications\OfficialAccount\Payment\MerchantPay\MerchantPay $merchant_pay - * @property \EasyWeChat\Applications\OfficialAccount\Payment\CashCoupon\CashCoupon $cash_coupon - * @property \EasyWeChat\Applications\OfficialAccount\Reply\Reply $reply - * @property \EasyWeChat\Applications\OfficialAccount\Broadcast\Broadcast $broadcast - * @property \EasyWeChat\Applications\OfficialAccount\Card\Card $card - * @property \EasyWeChat\Applications\OfficialAccount\Device\Device $device - * @property \EasyWeChat\Applications\OfficialAccount\ShakeAround\ShakeAround $shakearound - */ -class OfficialAccount -{ - use PrefixedContainer; - - /** - * Magic call. - * - * @param string $method - * @param array $args - * - * @return mixed - * - * @throws \BadMethodCallException - */ - public function __call($method, $args) - { - if (is_callable([$calling = $this->fetch('fundamental_api'), $method])) { - return call_user_func_array([$calling, $method], $args); - } - - throw new BadMethodCallException("Method {$method} does not exist."); - } -} diff --git a/src/Applications/OfficialAccount/POI/Client.php b/src/Applications/OfficialAccount/POI/Client.php index caf2d063b..7f230c047 100644 --- a/src/Applications/OfficialAccount/POI/Client.php +++ b/src/Applications/OfficialAccount/POI/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount POI Client. + * Application POI Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Payment/Client.php b/src/Applications/OfficialAccount/Payment/Client.php index 013ceaf3c..8578bacc9 100644 --- a/src/Applications/OfficialAccount/Payment/Client.php +++ b/src/Applications/OfficialAccount/Payment/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Payment Client. + * Application Payment Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Payment/Merchant.php b/src/Applications/OfficialAccount/Payment/Merchant.php index 2028c243a..5afec803c 100644 --- a/src/Applications/OfficialAccount/Payment/Merchant.php +++ b/src/Applications/OfficialAccount/Payment/Merchant.php @@ -21,7 +21,7 @@ namespace EasyWeChat\Applications\OfficialAccount\Payment; -use EasyWeChat\Support\Attribute; +use EasyWeChat\Support\HasAttributes; /** * Class Merchant. @@ -36,7 +36,7 @@ * @property string $fee_type * @property string $device_info */ -class Merchant extends Attribute +class Merchant extends HasAttributes { /** * @var array diff --git a/src/Applications/OfficialAccount/Payment/Order.php b/src/Applications/OfficialAccount/Payment/Order.php index d5051d935..823405660 100644 --- a/src/Applications/OfficialAccount/Payment/Order.php +++ b/src/Applications/OfficialAccount/Payment/Order.php @@ -21,7 +21,7 @@ namespace EasyWeChat\Applications\OfficialAccount\Payment; -use EasyWeChat\Support\Attribute; +use EasyWeChat\Support\HasAttributes; /** * Class Order. @@ -44,7 +44,7 @@ * @property string $sub_openid * @property string $auth_code */ -class Order extends Attribute +class Order extends HasAttributes { const JSAPI = 'JSAPI'; const NATIVE = 'NATIVE'; diff --git a/src/Applications/OfficialAccount/QRCode/Client.php b/src/Applications/OfficialAccount/QRCode/Client.php index 0fad8cbe8..b5ba0575b 100644 --- a/src/Applications/OfficialAccount/QRCode/Client.php +++ b/src/Applications/OfficialAccount/QRCode/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount QRCode Client. + * Application QRCode Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Reply/Client.php b/src/Applications/OfficialAccount/Reply/Client.php index 7d5ecfebf..833625e7c 100644 --- a/src/Applications/OfficialAccount/Reply/Client.php +++ b/src/Applications/OfficialAccount/Reply/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Reply Client. + * Application Reply Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Semantic/Client.php b/src/Applications/OfficialAccount/Semantic/Client.php index 481b21022..aa5e7b111 100644 --- a/src/Applications/OfficialAccount/Semantic/Client.php +++ b/src/Applications/OfficialAccount/Semantic/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Semantic Client. + * Application Semantic Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Stats/Client.php b/src/Applications/OfficialAccount/Stats/Client.php index 283705c8a..7359bb1eb 100644 --- a/src/Applications/OfficialAccount/Stats/Client.php +++ b/src/Applications/OfficialAccount/Stats/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Stats Client. + * Application Stats Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/Store/Client.php b/src/Applications/OfficialAccount/Store/Client.php index 63018ecaf..6925d650c 100644 --- a/src/Applications/OfficialAccount/Store/Client.php +++ b/src/Applications/OfficialAccount/Store/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Store Client. + * Application Store Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/TemplateMessage/Client.php b/src/Applications/OfficialAccount/TemplateMessage/Client.php index fea6e1760..67f3bdec9 100644 --- a/src/Applications/OfficialAccount/TemplateMessage/Client.php +++ b/src/Applications/OfficialAccount/TemplateMessage/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount TemplateMessage Client. + * Application TemplateMessage Client. * * @author overtrue * @copyright 2015 overtrue @@ -174,7 +174,7 @@ public function send($data = []) foreach ($params as $key => $value) { if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) { - throw new InvalidArgumentException("Attribute '$key' can not be empty!"); + throw new InvalidArgumentException("HasAttributes '$key' can not be empty!"); } $params[$key] = empty($value) ? $this->message[$key] : $value; diff --git a/src/Applications/OfficialAccount/Url/Client.php b/src/Applications/OfficialAccount/Url/Client.php index e8fd00411..991253365 100644 --- a/src/Applications/OfficialAccount/Url/Client.php +++ b/src/Applications/OfficialAccount/Url/Client.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount Url Client. + * Application Url Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/User/GroupClient.php b/src/Applications/OfficialAccount/User/GroupClient.php index 2f563258b..eeb5cca0b 100644 --- a/src/Applications/OfficialAccount/User/GroupClient.php +++ b/src/Applications/OfficialAccount/User/GroupClient.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount UserGroup Client. + * Application UserGroup Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/User/TagClient.php b/src/Applications/OfficialAccount/User/TagClient.php index a9745d295..5ef2301a9 100644 --- a/src/Applications/OfficialAccount/User/TagClient.php +++ b/src/Applications/OfficialAccount/User/TagClient.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount UserTag Client. + * Application UserTag Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OfficialAccount/User/UserClient.php b/src/Applications/OfficialAccount/User/UserClient.php index 034def60d..1ba3ca21a 100644 --- a/src/Applications/OfficialAccount/User/UserClient.php +++ b/src/Applications/OfficialAccount/User/UserClient.php @@ -10,7 +10,7 @@ */ /** - * OfficialAccount User Client. + * Application User Client. * * @author overtrue * @copyright 2015 overtrue diff --git a/src/Applications/OpenPlatform/OpenPlatform.php b/src/Applications/OpenPlatform/Application.php similarity index 85% rename from src/Applications/OpenPlatform/OpenPlatform.php rename to src/Applications/OpenPlatform/Application.php index 2f8c9624e..53e5864f7 100644 --- a/src/Applications/OpenPlatform/OpenPlatform.php +++ b/src/Applications/OpenPlatform/Application.php @@ -10,7 +10,7 @@ */ /** - * OpenPlatform.php. + * Application.php. * * Part of Overtrue\WeChat. * @@ -26,10 +26,11 @@ namespace EasyWeChat\Applications\OpenPlatform; -use EasyWeChat\Support\Traits\PrefixedContainer; +use EasyWeChat\Applications\OpenPlatform; +use EasyWeChat\Support\ServiceContainer; /** - * Class OpenPlatform. + * Class Application. * * @property \EasyWeChat\Applications\OpenPlatform\Api\BaseApi $api * @property \EasyWeChat\Applications\OpenPlatform\Api\PreAuthorization $pre_auth @@ -41,9 +42,13 @@ * @method \EasyWeChat\Support\Collection getAuthorizerOption($authorizerAppId, $optionName) * @method \EasyWeChat\Support\Collection setAuthorizerOption($authorizerAppId, $optionName, $optionValue) */ -class OpenPlatform +class Application extends ServiceContainer { - use PrefixedContainer; + protected $providers = [ + OpenPlatform\ServiceProvider::class, + OpenPlatform\Core\ServiceProvider::class, + OpenPlatform\Server\ServiceProvider::class, + ]; /** * Create an instance of the EasyWeChat for the given authorizer. @@ -51,7 +56,7 @@ class OpenPlatform * @param string $appId Authorizer AppId * @param string $refreshToken Authorizer refresh-token * - * @return \EasyWeChat\Application + * @return \EasyWeChat\Factory */ public function createAuthorizerApplication(string $appId, string $refreshToken) { diff --git a/src/Applications/OpenPlatform/Server/Guard.php b/src/Applications/OpenPlatform/Server/Guard.php index 10c930e89..34c2a6603 100644 --- a/src/Applications/OpenPlatform/Server/Guard.php +++ b/src/Applications/OpenPlatform/Server/Guard.php @@ -92,7 +92,7 @@ public function serve() return parent::serve(); } - Log::debug('OpenPlatform Request received:', [ + Log::debug('Application Request received:', [ 'Method' => $this->request->getMethod(), 'URI' => $this->request->getRequestUri(), 'Query' => $this->request->getQueryString(), @@ -120,7 +120,7 @@ public function serve() */ protected function handleEventMessage(array $message) { - Log::debug('OpenPlatform Event Message detail:', $message); + Log::debug('Application Event Message detail:', $message); $message = new Collection($message); diff --git a/src/Applications/OpenPlatform/ServiceProvider.php b/src/Applications/OpenPlatform/ServiceProvider.php index fe10c5438..4acbba871 100644 --- a/src/Applications/OpenPlatform/ServiceProvider.php +++ b/src/Applications/OpenPlatform/ServiceProvider.php @@ -27,9 +27,9 @@ namespace EasyWeChat\Applications\OpenPlatform; -use EasyWeChat\Application; use EasyWeChat\Applications\OpenPlatform\Api\BaseApi; use EasyWeChat\Applications\OpenPlatform\Api\PreAuthorization; +use EasyWeChat\Factory; use Overtrue\Socialite\SocialiteManager as Socialite; use Pimple\Container; use Pimple\ServiceProviderInterface; @@ -45,7 +45,7 @@ class ServiceProvider implements ServiceProviderInterface public function register(Container $container) { $container['open_platform.instance'] = function ($container) { - return new OpenPlatform($container); + return new Application($container); }; $container['open_platform.pre_auth'] = function ($container) { @@ -63,10 +63,10 @@ public function register(Container $container) }; $container['open_platform.app'] = function ($container) { - return new Application($container['config']->toArray()); + return new Factory($container['config']->toArray()); }; - // OAuth for OpenPlatform. + // OAuth for Application. $container['open_platform.oauth'] = function ($container) { $callback = $this->prepareCallbackUrl($container); $scopes = $container['config']->get('open_platform.oauth.scopes', []); diff --git a/src/Applications/WeWork/Application.php b/src/Applications/WeWork/Application.php new file mode 100644 index 000000000..b7c93672d --- /dev/null +++ b/src/Applications/WeWork/Application.php @@ -0,0 +1,30 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat\Applications\WeWork; + +use EasyWeChat\Applications\WeWork; +use EasyWeChat\Support\ServiceContainer; + +/** + * Application. + * + * @author mingyoung + */ +class Application extends ServiceContainer +{ + protected $providers = [ + WeWork\Core\ServiceProvider::class, + WeWork\Department\ServiceProvider::class, + WeWork\Attendance\ServiceProvider::class, + WeWork\Agent\ServiceProvider::class, + ]; +} diff --git a/src/Applications/WeWork/Core/ServiceProvider.php b/src/Applications/WeWork/Core/ServiceProvider.php index 2ba4c6ba1..253f8eec7 100644 --- a/src/Applications/WeWork/Core/ServiceProvider.php +++ b/src/Applications/WeWork/Core/ServiceProvider.php @@ -11,7 +11,7 @@ namespace EasyWeChat\Applications\WeWork\Core; -use EasyWeChat\Applications\WeWork\WeWork; +use EasyWeChat\Applications\WeWork\Application; use Pimple\Container; use Pimple\ServiceProviderInterface; @@ -23,7 +23,7 @@ class ServiceProvider implements ServiceProviderInterface public function register(Container $container) { $container['we_work.instance'] = function ($container) { - return new WeWork($container); + return new Application($container); }; $container['we_work.access_token'] = function ($container) { diff --git a/src/Applications/WeWork/WeWork.php b/src/Applications/WeWork/WeWork.php deleted file mode 100644 index f84ffda64..000000000 --- a/src/Applications/WeWork/WeWork.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace EasyWeChat\Applications\WeWork; - -use EasyWeChat\Support\Traits\PrefixedContainer; - -/** - * WeWork. - * - * @author mingyoung - */ -class WeWork -{ - use PrefixedContainer; -} diff --git a/src/Factory.php b/src/Factory.php new file mode 100644 index 000000000..57e5abd42 --- /dev/null +++ b/src/Factory.php @@ -0,0 +1,83 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChat; + +use EasyWeChat\Config\Repository as Config; +use EasyWeChat\Support\Log; +use Monolog\Handler\HandlerInterface; +use Monolog\Handler\NullHandler; +use Monolog\Handler\StreamHandler; +use Monolog\Logger; + +/** + * @method static \EasyWeChat\Applications\WeWork\Application weWork(array $config) + * @method static \EasyWeChat\Applications\MiniProgram\MiniProgram miniProgram(array $config) + * @method static \EasyWeChat\Applications\OpenPlatform\Application openPlatform(array $config) + * @method static \EasyWeChat\Applications\OfficialAccount\Application officialAccount(array $config) + */ +class Factory extends Container +{ + /** + * @param string $application + * @param array|\EasyWeChat\Config\Repository $config + * + * @return \EasyWeChat\Support\ServiceContainer + */ + public static function make($application, $config) + { + if (!($config instanceof Config)) { + $config = new Config($config); + } + + return new $application($config); + } + + /** + * Dynamically pass methods to the application. + * + * @param string $name + * @param array $arguments + * + * @return mixed + */ + public static function __callStatic($name, $arguments) + { + return self::make($name, ...$arguments); + } + + /** + * Initialize logger. + */ + private function initializeLogger() + { + if (Log::hasLogger()) { + return; + } + + $logger = new Logger('easywechat'); + + if (!$this['config']['debug'] || defined('PHPUNIT_RUNNING')) { + $logger->pushHandler(new NullHandler()); + } elseif ($this['config']['log.handler'] instanceof HandlerInterface) { + $logger->pushHandler($this['config']['log.handler']); + } elseif ($logFile = $this['config']['log.file']) { + $logger->pushHandler(new StreamHandler( + $logFile, + $this['config']->get('log.level', Logger::WARNING), + true, + $this['config']->get('log.permission', null)) + ); + } + + Log::setLogger($logger); + } +} diff --git a/src/Support/Arr.php b/src/Support/Arr.php index 0f74aeed4..338076b33 100644 --- a/src/Support/Arr.php +++ b/src/Support/Arr.php @@ -9,17 +9,6 @@ * with this source code in the file LICENSE. */ -/** - * Arr.php. - * - * @author overtrue - * @copyright 2015 overtrue - * - * @see https://github.com/overtrue - * @see http://overtrue.me - * @see https://github.com/laravel/framework/blob/4.2/src/Illuminate/Support/Arr.php - */ - namespace EasyWeChat\Support; use Closure; diff --git a/src/Support/Attribute.php b/src/Support/HasAttributes.php similarity index 71% rename from src/Support/Attribute.php rename to src/Support/HasAttributes.php index 5f5831580..b65296bb8 100644 --- a/src/Support/Attribute.php +++ b/src/Support/HasAttributes.php @@ -9,46 +9,35 @@ * with this source code in the file LICENSE. */ -/** - * Attributes.php. - * - * @author overtrue - * @copyright 2015 overtrue - * - * @see https://github.com/overtrue - * @see http://overtrue.me - */ - namespace EasyWeChat\Support; -use EasyWeChat\Core\Exceptions\InvalidArgumentException; +use EasyWeChat\Exceptions\InvalidArgumentException; /** - * Class Attributes. + * Trait Attributes. */ -abstract class Attribute extends Collection +trait HasAttributes { /** - * Attributes alias. - * - * @var array + * @var \EasyWeChat\Support\Collection */ - protected $aliases = []; + protected $attributes; /** - * Auto snake attribute name. - * - * @var bool + * @var array */ - protected $snakeable = true; + protected $aliases = []; /** - * Required attributes. - * * @var array */ protected $requirements = []; + /** + * @var bool + */ + protected $snakeable = true; + /** * Constructor. * @@ -56,7 +45,7 @@ abstract class Attribute extends Collection */ public function __construct(array $attributes = []) { - parent::__construct($attributes); + $this->attributes = new Collection($attributes); } /** @@ -65,11 +54,11 @@ public function __construct(array $attributes = []) * @param string $attribute * @param string $value * - * @return Attribute + * @return HasAttributes */ public function setAttribute($attribute, $value) { - $this->set($attribute, $value); + $this->attributes->set($attribute, $value); return $this; } @@ -84,7 +73,7 @@ public function setAttribute($attribute, $value) */ public function getAttribute($attribute, $default) { - return $this->get($attribute, $default); + return $this->attributes->get($attribute, $default); } /** @@ -93,9 +82,9 @@ public function getAttribute($attribute, $default) * @param string $attribute * @param mixed $value * - * @return Attribute + * @return HasAttributes * - * @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Exceptions\InvalidArgumentException */ public function with($attribute, $value) { @@ -105,13 +94,13 @@ public function with($attribute, $value) throw new InvalidArgumentException("Invalid attribute '{$attribute}'."); } - $this->set($attribute, $value); + $this->setAttribute($attribute, $value); return $this; } /** - * Attribute validation. + * HasAttributes validation. * * @param string $attribute * @param mixed $value @@ -128,10 +117,14 @@ protected function validate($attribute, $value) * * @param string $attribute * @param mixed $value + * + * @return $this */ public function set($attribute, $value = null) { - parent::set($this->getRealKey($attribute), $value); + $this->setAttribute($this->getRealKey($attribute), $value); + + return $this; } /** @@ -144,7 +137,19 @@ public function set($attribute, $value = null) */ public function get($attribute, $default = null) { - return parent::get($this->getRealKey($attribute), $default); + return $this->getAttribute($this->getRealKey($attribute), $default); + } + + /** + * Return all items. + * + * @return array + */ + public function all() + { + $this->checkRequiredAttributes(); + + return $this->attributes->all(); } /** @@ -153,15 +158,15 @@ public function get($attribute, $default = null) * @param string $method * @param array $args * - * @return Attribute + * @return $this */ public function __call($method, $args) { if (stripos($method, 'with') === 0) { - $method = substr($method, 4); + return $this->with(substr($method, 4), array_shift($args)); } - return $this->with($method, array_shift($args)); + return call_user_func_array([$this->attributes, $method], $args); } /** @@ -170,7 +175,7 @@ public function __call($method, $args) * @param string $property * @param mixed $value * - * @return Attribute + * @return $this */ public function __set($property, $value) { @@ -186,7 +191,7 @@ public function __set($property, $value) */ public function __isset($key) { - return parent::__isset($this->getRealKey($key)); + return isset($this->attributes[$this->getRealKey($key)]); } /** @@ -208,28 +213,14 @@ protected function getRealKey($key) /** * Check required attributes. * - * @throws InvalidArgumentException + * @throws \EasyWeChat\Exceptions\InvalidArgumentException */ protected function checkRequiredAttributes() { foreach ($this->requirements as $attribute) { - if (!isset($this->$attribute)) { - throw new InvalidArgumentException(" '{$attribute}' cannot be empty."); + if (!isset($this->attributes, $attribute)) { + throw new InvalidArgumentException("'{$attribute}' cannot be empty."); } } } - - /** - * Return all items. - * - * @return array - * - * @throws InvalidArgumentException - */ - public function all() - { - $this->checkRequiredAttributes(); - - return parent::all(); - } } diff --git a/src/Support/InteractsWithCache.php b/src/Support/InteractsWithCache.php new file mode 100644 index 000000000..f69962434 --- /dev/null +++ b/src/Support/InteractsWithCache.php @@ -0,0 +1,52 @@ + + */ +trait InteractsWithCache +{ + /** + * @var \Psr\SimpleCache\CacheInterface + */ + protected $cache; + + /** + * Get cache instance. + * + * @return \Psr\SimpleCache\CacheInterface + */ + public function getCache() + { + return $this->cache ?? $this->cache = $this->createDefaultCache(); + } + + /** + * Set cache instance. + * + * @param \Psr\SimpleCache\CacheInterface $cache + * + * @return $this + */ + public function setCache(CacheInterface $cache) + { + $this->cache = $cache; + + return $this; + } + + /** + * @return \Symfony\Component\Cache\Simple\FilesystemCache + */ + protected function createDefaultCache() + { + return new FilesystemCache(); + } +} \ No newline at end of file diff --git a/src/Support/Str.php b/src/Support/Str.php index d5bad6202..0f9530f41 100644 --- a/src/Support/Str.php +++ b/src/Support/Str.php @@ -9,20 +9,13 @@ * with this source code in the file LICENSE. */ -/** - * Str.php. - * - * @author overtrue - * @copyright 2015 overtrue - * - * @see https://github.com/overtrue - * @see http://overtrue.me - */ - namespace EasyWeChat\Support; -use EasyWeChat\Core\Exceptions\RuntimeException; +use EasyWeChat\Exceptions\RuntimeException; +/** + * Class Str. + */ class Str { /** diff --git a/src/Support/Traits/PrefixedContainer.php b/src/Support/Traits/PrefixedContainer.php deleted file mode 100644 index 3ba412bfa..000000000 --- a/src/Support/Traits/PrefixedContainer.php +++ /dev/null @@ -1,99 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/** - * Trait PrefixedContainer.php. - * - * Part of Overtrue\WeChat. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - * - * @author mingyoung - * @copyright 2017 - * - * @see https://github.com/overtrue - * @see http://overtrue.me - */ - -namespace EasyWeChat\Support\Traits; - -use EasyWeChat\Support\Str; -use Pimple\Container; - -/** - * Trait PrefixedContainer. - */ -trait PrefixedContainer -{ - /** - * Container. - * - * @var \Pimple\Container - */ - protected $container; - - /** - * ContainerAccess constructor. - * - * @param \Pimple\Container $container - */ - public function __construct(Container $container) - { - $this->container = $container; - } - - /** - * Fetches from pimple container. - * - * @param string $key - * @param callable|null $callable - * - * @return mixed - */ - public function fetch($key, callable $callable = null) - { - $instance = $this->$key; - - if (!is_null($callable)) { - $callable($instance); - } - - return $instance; - } - - /** - * Gets a parameter or an object from pimple container. - * - * Get the `class basename` of the current class. - * Convert `class basename` to snake-case and concatenation with dot notation. - * - * E.g. Class 'EasyWechat', $key foo -> 'easy_wechat.foo' - * - * @param string $key The unique identifier for the parameter or object - * - * @return mixed The value of the parameter or an object - * - * @throws \InvalidArgumentException If the identifier is not defined - */ - public function __get($key) - { - if ($this->container->offsetExists($key)) { - return $this->container->offsetGet($key); - } - - $className = basename(str_replace('\\', '/', static::class)); - - $name = Str::snake($className).'.'.$key; - - return $this->container->offsetGet($name); - } -} diff --git a/src/Support/Url.php b/src/Support/Url.php index b3c2fec0f..e40330271 100644 --- a/src/Support/Url.php +++ b/src/Support/Url.php @@ -33,13 +33,11 @@ class Url */ public static function current() { - if (defined('PHPUNIT_RUNNING')) { - return 'http://localhost'; - } + $protocol = 'http://'; - $protocol = (!empty($_SERVER['HTTPS']) - && $_SERVER['HTTPS'] !== 'off' - || (int) $_SERVER['SERVER_PORT'] === 443) ? 'https://' : 'http://'; + if (!empty($_SERVER['HTTPS']) || ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? 'http') === 'https') { + $protocol = 'https://'; + } return $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; } diff --git a/src/Support/XML.php b/src/Support/XML.php index b57f04435..126c3ea23 100644 --- a/src/Support/XML.php +++ b/src/Support/XML.php @@ -9,16 +9,6 @@ * with this source code in the file LICENSE. */ -/** - * XML.php. - * - * @author overtrue - * @copyright 2015 overtrue - * - * @see https://github.com/overtrue - * @see http://overtrue.me - */ - namespace EasyWeChat\Support; use SimpleXMLElement; diff --git a/tests/Applications/WeWork/Agent/ClientTest.php b/tests/Applications/WeWork/Agent/ClientTest.php index ff5839c6a..cf20bed42 100644 --- a/tests/Applications/WeWork/Agent/ClientTest.php +++ b/tests/Applications/WeWork/Agent/ClientTest.php @@ -23,7 +23,7 @@ public function testGet() { $result = $this->getClient()->get(1); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/agent/get', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/agent/get', $result[1][0]); $this->assertSame(['agentid' => 1], $result[1][1]); } @@ -43,7 +43,7 @@ public function testSet() 'home_url' => 'http://www.qq.com', ]); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/agent/set', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/agent/set', $result[1][0]); $this->assertSame($expected, $result[1][1]); } @@ -54,7 +54,7 @@ public function testLists() { $result = $this->getClient()->lists(); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/agent/list', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/agent/list', $result[1][0]); } /** diff --git a/tests/Applications/WeWork/Attendance/ClientTest.php b/tests/Applications/WeWork/Attendance/ClientTest.php index 7850ba538..067181c71 100644 --- a/tests/Applications/WeWork/Attendance/ClientTest.php +++ b/tests/Applications/WeWork/Attendance/ClientTest.php @@ -23,7 +23,7 @@ public function testGetCheckinData() { $result = $this->getClient()->getCheckinData(12, 34, ['zhangsan', 'lisi']); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata', $result[1][0]); $this->assertSame([ 'opencheckindatatype' => 3, 'starttime' => 12, diff --git a/tests/Applications/WeWork/Department/ClientTest.php b/tests/Applications/WeWork/Department/ClientTest.php index b8ac95b3b..e7adbd4c5 100644 --- a/tests/Applications/WeWork/Department/ClientTest.php +++ b/tests/Applications/WeWork/Department/ClientTest.php @@ -29,7 +29,7 @@ public function testCreate() ]; $result = $this->getClient()->create($data); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/department/create', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/department/create', $result[1][0]); $this->assertSame($data, $result[1][1]); } @@ -46,7 +46,7 @@ public function testUpdate() ]; $result = $this->getClient()->update($data); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/department/update', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/department/update', $result[1][0]); $this->assertSame($data, $result[1][1]); } @@ -57,8 +57,8 @@ public function testDelete() { $result = $this->getClient()->delete(1); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/department/delete', $result[1][0]); - $this->assertEquals(1, $result[1][1]['id']); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/department/delete', $result[1][0]); + $this->assertSame(1, $result[1][1]['id']); } /** @@ -68,12 +68,12 @@ public function testLists() { $result = $this->getClient()->lists(); - $this->assertEquals('https://qyapi.weixin.qq.com/cgi-bin/department/list', $result[1][0]); + $this->assertSame('https://qyapi.weixin.qq.com/cgi-bin/department/list', $result[1][0]); $this->assertNull($result[1][1]['id']); $result = $this->getClient()->lists(1); - $this->assertEquals(1, $result[1][1]['id']); + $this->assertSame(1, $result[1][1]['id']); } /** diff --git a/tests/Foundation/ApplicationTest.php b/tests/Foundation/ApplicationTest.php index de9f612d3..64533c0f4 100644 --- a/tests/Foundation/ApplicationTest.php +++ b/tests/Foundation/ApplicationTest.php @@ -11,9 +11,9 @@ namespace EasyWeChat\Tests\Foundation; -use EasyWeChat\Application; use EasyWeChat\Applications\Base\Core\Http; use EasyWeChat\Config\Repository as Config; +use EasyWeChat\Factory; use EasyWeChat\Tests\TestCase; use Pimple\Container; use Pimple\ServiceProviderInterface; @@ -26,7 +26,7 @@ class ApplicationTest extends TestCase */ public function testConstructor() { - $app = new Application(['foo' => 'bar']); + $app = new Factory(['foo' => 'bar']); $this->assertInstanceOf(Config::class, $app['config']); @@ -39,7 +39,7 @@ public function testConstructor() $container['cache'] = $app->raw('cache'); foreach ($container->keys() as $providerName) { - $this->assertEquals($container->raw($providerName), $app->raw($providerName)); + $this->assertSame($container->raw($providerName), $app->raw($providerName)); } unset($container); @@ -48,14 +48,14 @@ public function testConstructor() public function testHttpDefaultOptions() { - $app = new Application([]); + $app = new Factory([]); - $this->assertEquals(['timeout' => 5.0], Http::getDefaultOptions()); + $this->assertSame(['timeout' => 5.0], Http::getDefaultOptions()); $config = ['guzzle' => ['timeout' => 6]]; - $app = new Application($config); + $app = new Factory($config); - $this->assertEquals($config['guzzle'], Http::getDefaultOptions()); + $this->assertSame($config['guzzle'], Http::getDefaultOptions()); } /** @@ -63,12 +63,12 @@ public function testHttpDefaultOptions() */ public function testMagicMethod() { - $app = new Application(['foo' => 'bar']); + $app = new Factory(['foo' => 'bar']); $app->foo = 'bar'; // getter setter - $this->assertEquals('bar', $app->foo); + $this->assertSame('bar', $app->foo); } /** @@ -76,7 +76,7 @@ public function testMagicMethod() */ public function testProviders() { - $app = new Application(['foo' => 'bar']); + $app = new Factory(['foo' => 'bar']); $providers = $app->getProviders(); @@ -96,7 +96,7 @@ public function testSetCustomAccessToken() 'secret' => 'bar', ]; - $app = new Application($config); + $app = new Factory($config); $this->assertInstanceOf('EasyWeChat\Applications\OfficialAccount\Core\AccessToken', $app['official_account.access_token']); @@ -108,11 +108,11 @@ public function testSetCustomAccessToken() public function testStaticCall() { $weworkInstances = [ - Application::weWork(['client_id' => 'corpid@123', 'client_secret' => 'corpsecret@123', 'debug' => true]), - Application::make('weWork', ['debug' => true, 'client_id' => 'corpid@123', 'client_secret' => 'corpsecret@123']), + Factory::weWork(['client_id' => 'corpid@123', 'client_secret' => 'corpsecret@123', 'debug' => true]), + Factory::make('weWork', ['debug' => true, 'client_id' => 'corpid@123', 'client_secret' => 'corpsecret@123']), ]; foreach ($weworkInstances as $instance) { - $this->assertInstanceOf('EasyWeChat\Applications\WeWork\WeWork', $instance); + $this->assertInstanceOf('EasyWeChat\Applications\WeWork\Application', $instance); $expected = [ 'debug' => true, 'client_id' => 'corpid@123', @@ -122,26 +122,26 @@ public function testStaticCall() } $officialAccountInstances = [ - Application::officialAccount(['appid' => 'appid@456']), - Application::make('officialAccount', ['appid' => 'appid@456']), + Factory::officialAccount(['appid' => 'appid@456']), + Factory::make('officialAccount', ['appid' => 'appid@456']), ]; foreach ($officialAccountInstances as $instance) { - $this->assertInstanceOf('EasyWeChat\Applications\OfficialAccount\OfficialAccount', $instance); + $this->assertInstanceOf('EasyWeChat\Applications\OfficialAccount\Application', $instance); $this->assertArraySubset(['appid' => 'appid@456'], $instance->fetch('config')->all()); } $openPlatformInstances = [ - Application::openPlatform(['appid' => 'appid@789']), - Application::make('openPlatform', ['appid' => 'appid@789']), + Factory::openPlatform(['appid' => 'appid@789']), + Factory::make('openPlatform', ['appid' => 'appid@789']), ]; foreach ($openPlatformInstances as $instance) { - $this->assertInstanceOf('EasyWeChat\Applications\OpenPlatform\OpenPlatform', $instance); + $this->assertInstanceOf('EasyWeChat\Applications\OpenPlatform\Application', $instance); $this->assertArraySubset(['appid' => 'appid@789'], $instance->fetch('config')->all()); } $miniProgramInstances = [ - Application::miniProgram(['appid' => 'appid@890']), - Application::make('miniProgram', ['appid' => 'appid@890']), + Factory::miniProgram(['appid' => 'appid@890']), + Factory::make('miniProgram', ['appid' => 'appid@890']), ]; foreach ($miniProgramInstances as $instance) { $this->assertInstanceOf('EasyWeChat\Applications\MiniProgram\MiniProgram', $instance); diff --git a/tests/Foundation/Core/AbstractAPITest.php b/tests/Foundation/Core/AbstractAPITest.php index 4c078283b..4caecc175 100644 --- a/tests/Foundation/Core/AbstractAPITest.php +++ b/tests/Foundation/Core/AbstractAPITest.php @@ -35,7 +35,7 @@ public function testConstruct() $accessToken = \Mockery::mock(AccessToken::class); $api = new FooAPI($accessToken); - $this->assertEquals($accessToken, $api->getAccessToken()); + $this->assertSame($accessToken, $api->getAccessToken()); } public function testHttpInstance() @@ -56,7 +56,7 @@ public function testHttpInstance() $mock->shouldReceive('getMiddlewares')->andReturn([1, 2, 3]); }); $api->setHttp($http); - $this->assertEquals($http, $api->getHttp()); + $this->assertSame($http, $api->getHttp()); } public function testParseJSON() @@ -78,7 +78,7 @@ public function testParseJSON() $collection = $api->parseJSON('get', ['foo', ['bar']]); $this->assertInstanceOf(Collection::class, $collection); - $this->assertEquals(['foo', ['bar']], $collection->all()); + $this->assertSame(['foo', ['bar']], $collection->all()); // test error $http = \Mockery::mock(Http::class.'[getMiddlewares,get,parseJSON]', function ($mock) { diff --git a/tests/Foundation/Core/AccessTokenAtrributesTest.php b/tests/Foundation/Core/AccessTokenAtrributesTest.php index c8c8668ce..d7d887518 100644 --- a/tests/Foundation/Core/AccessTokenAtrributesTest.php +++ b/tests/Foundation/Core/AccessTokenAtrributesTest.php @@ -66,18 +66,18 @@ public function testClientIdAndClientSecret() { $officialAccount = $this->getOfficialAccount('app-id', 'app-secret'); - $this->assertEquals('app-id', $officialAccount->getClientId()); - $this->assertEquals('app-secret', $officialAccount->getClientSecret()); + $this->assertSame('app-id', $officialAccount->getClientId()); + $this->assertSame('app-secret', $officialAccount->getClientSecret()); $miniProgram = $this->getMiniProgram('mini-app-id', 'mini-secret'); - $this->assertEquals('mini-app-id', $miniProgram->getClientId()); - $this->assertEquals('mini-secret', $miniProgram->getClientSecret()); + $this->assertSame('mini-app-id', $miniProgram->getClientId()); + $this->assertSame('mini-secret', $miniProgram->getClientSecret()); $openPlatform = $this->getOpenPlatform('open-app-id', 'open-secret'); - $this->assertEquals('open-app-id', $openPlatform->getClientId()); - $this->assertEquals('open-secret', $openPlatform->getClientSecret()); + $this->assertSame('open-app-id', $openPlatform->getClientId()); + $this->assertSame('open-secret', $openPlatform->getClientSecret()); } public function testGetQueryName() @@ -86,9 +86,9 @@ public function testGetQueryName() $miniProgram = $this->getMiniProgram('mini-app-id', 'mini-secret'); $openPlatform = $this->getOpenPlatform('open-app-id', 'open-secret'); - $this->assertEquals('access_token', $officialAccount->getQueryName()); - $this->assertEquals('access_token', $miniProgram->getQueryName()); - $this->assertEquals('component_access_token', $openPlatform->getQueryName()); + $this->assertSame('access_token', $officialAccount->getQueryName()); + $this->assertSame('access_token', $miniProgram->getQueryName()); + $this->assertSame('component_access_token', $openPlatform->getQueryName()); } public function testGetQueryFields() @@ -108,9 +108,9 @@ public function testGetCacheKey() $miniProgram = $this->getMiniProgram('mini-app-id', 'mini-secret'); $openPlatform = $this->getOpenPlatform('open-app-id', 'open-secret'); - $this->assertEquals('easywechat.common.access_token.app-id', $officialAccount->getCacheKey()); - $this->assertEquals('easywechat.common.mini.program.access_token.mini-app-id', $miniProgram->getCacheKey()); - $this->assertEquals('easywechat.open_platform.component_access_token.open-app-id', $openPlatform->getCacheKey()); + $this->assertSame('easywechat.common.access_token.app-id', $officialAccount->getCacheKey()); + $this->assertSame('easywechat.common.mini.program.access_token.mini-app-id', $miniProgram->getCacheKey()); + $this->assertSame('easywechat.open_platform.component_access_token.open-app-id', $openPlatform->getCacheKey()); } public function testGetTokenFromServer() @@ -119,7 +119,7 @@ public function testGetTokenFromServer() $miniProgramResult = $this->getMiniProgram('mini-app-id', 'mini-secret')->getTokenFromServer(); $openPlatformResult = $this->getOpenPlatform('open-app-id', 'open-secret')->getTokenFromServer(); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/token', $officialAccountResult['endpoint']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/token', $officialAccountResult['endpoint']); $this->assertSame([ 'appid' => 'app-id', 'secret' => 'app-secret', @@ -127,7 +127,7 @@ public function testGetTokenFromServer() ], $officialAccountResult['params'] ); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/token', $miniProgramResult['endpoint']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/token', $miniProgramResult['endpoint']); $this->assertSame([ 'appid' => 'mini-app-id', 'secret' => 'mini-secret', @@ -135,7 +135,7 @@ public function testGetTokenFromServer() ], $miniProgramResult['params'] ); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/component/api_component_token', $openPlatformResult['endpoint']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/component/api_component_token', $openPlatformResult['endpoint']); $this->assertSame([ 'component_appid' => 'open-app-id', 'component_appsecret' => 'open-secret', diff --git a/tests/Foundation/Core/HttpTest.php b/tests/Foundation/Core/HttpTest.php index 8ce35aa5e..d630765e6 100755 --- a/tests/Foundation/Core/HttpTest.php +++ b/tests/Foundation/Core/HttpTest.php @@ -58,18 +58,18 @@ public function testRequestWithJsonResponse() { $http = new Http(); $http->setClient($this->getGuzzleWithResponse(json_encode(['errcode' => '0', 'errmsg' => 'ok']))); - $this->assertEquals(['errcode' => '0', 'errmsg' => 'ok'], json_decode($http->request('http://overtrue.me', 'GET')->getBody(), true)); + $this->assertSame(['errcode' => '0', 'errmsg' => 'ok'], json_decode($http->request('http://overtrue.me', 'GET')->getBody(), true)); $http->setClient($this->getGuzzleWithResponse(json_encode(['foo' => 'bar']))); $response = $http->request('http://overtrue.me', 'GET'); - $this->assertEquals(json_encode(['foo' => 'bar']), $response->getBody()); + $this->assertSame(json_encode(['foo' => 'bar']), $response->getBody()); $http->setClient($this->getGuzzleWithResponse('non-json content')); $response = $http->request('http://overtrue.me', 'GET'); - $this->assertEquals('non-json content', $response->getBody()); + $this->assertSame('non-json content', $response->getBody()); } /** @@ -87,11 +87,11 @@ public function testParseJSON() } $http->setClient($this->getGuzzleWithResponse('{"foo":"bar"}')); - $this->assertEquals(['foo' => 'bar'], $http->parseJSON($http->request('http://overtrue.me', 'GET'))); + $this->assertSame(['foo' => 'bar'], $http->parseJSON($http->request('http://overtrue.me', 'GET'))); $http = new Http(); $http->setClient($this->getGuzzleWithResponse('')); - $this->assertEquals(null, $http->parseJSON($http->request('http://overtrue.me', 'GET'))); + $this->assertSame(null, $http->parseJSON($http->request('http://overtrue.me', 'GET'))); } /** @@ -109,9 +109,9 @@ public function testGet() $response = $http->get('http://easywechat.org', ['foo' => 'bar']); - $this->assertEquals('http://easywechat.org', $response['url']); - $this->assertEquals('GET', $response['method']); - $this->assertEquals(['query' => ['foo' => 'bar']], $response['body']); + $this->assertSame('http://easywechat.org', $response['url']); + $this->assertSame('GET', $response['method']); + $this->assertSame(['query' => ['foo' => 'bar']], $response['body']); } /** @@ -130,16 +130,16 @@ public function testPost() // array $response = $http->post('http://easywechat.org', ['foo' => 'bar']); - $this->assertEquals('http://easywechat.org', $response['url']); - $this->assertEquals('POST', $response['method']); - $this->assertEquals(['form_params' => ['foo' => 'bar']], $response['body']); + $this->assertSame('http://easywechat.org', $response['url']); + $this->assertSame('POST', $response['method']); + $this->assertSame(['form_params' => ['foo' => 'bar']], $response['body']); // string $response = $http->post('http://easywechat.org', 'hello here.'); - $this->assertEquals('http://easywechat.org', $response['url']); - $this->assertEquals('POST', $response['method']); - $this->assertEquals(['body' => 'hello here.'], $response['body']); + $this->assertSame('http://easywechat.org', $response['url']); + $this->assertSame('POST', $response['method']); + $this->assertSame(['body' => 'hello here.'], $response['body']); } /** @@ -157,21 +157,21 @@ public function testJson() $response = $http->json('http://easywechat.org', ['foo' => 'bar']); - $this->assertEquals('http://easywechat.org', $response['url']); - $this->assertEquals('POST', $response['method']); + $this->assertSame('http://easywechat.org', $response['url']); + $this->assertSame('POST', $response['method']); - $this->assertEquals([], $response['body']['query']); - $this->assertEquals(json_encode(['foo' => 'bar']), $response['body']['body']); - $this->assertEquals(['content-type' => 'application/json'], $response['body']['headers']); + $this->assertSame([], $response['body']['query']); + $this->assertSame(json_encode(['foo' => 'bar']), $response['body']['body']); + $this->assertSame(['content-type' => 'application/json'], $response['body']['headers']); $response = $http->json('http://easywechat.org', ['foo' => 'bar'], JSON_UNESCAPED_UNICODE); - $this->assertEquals('http://easywechat.org', $response['url']); - $this->assertEquals('POST', $response['method']); + $this->assertSame('http://easywechat.org', $response['url']); + $this->assertSame('POST', $response['method']); - $this->assertEquals([], $response['body']['query']); - $this->assertEquals(json_encode(['foo' => 'bar']), $response['body']['body']); - $this->assertEquals(['content-type' => 'application/json'], $response['body']['headers']); + $this->assertSame([], $response['body']['query']); + $this->assertSame(json_encode(['foo' => 'bar']), $response['body']['body']); + $this->assertSame(['content-type' => 'application/json'], $response['body']['headers']); } /** @@ -189,13 +189,13 @@ public function testUpload() $response = $http->upload('http://easywechat.org', ['foo' => 'bar', 'hello' => 'world'], ['overtrue' => 'easywechat']); - $this->assertEquals('http://easywechat.org', $response['url']); - $this->assertEquals('POST', $response['method']); + $this->assertSame('http://easywechat.org', $response['url']); + $this->assertSame('POST', $response['method']); $this->assertContains(['name' => 'overtrue', 'contents' => 'easywechat'], $response['body']['multipart']); - $this->assertEquals('foo', $response['body']['multipart'][0]['name']); - $this->assertEquals('bar', $response['body']['multipart'][0]['contents']); - $this->assertEquals('hello', $response['body']['multipart'][1]['name']); - $this->assertEquals('world', $response['body']['multipart'][1]['contents']); + $this->assertSame('foo', $response['body']['multipart'][0]['name']); + $this->assertSame('bar', $response['body']['multipart'][0]['contents']); + $this->assertSame('hello', $response['body']['multipart'][1]['name']); + $this->assertSame('world', $response['body']['multipart'][1]['contents']); } public function testUserHandler() diff --git a/tests/MiniProgram/EncryptorTest.php b/tests/MiniProgram/EncryptorTest.php index e8b0b7976..cf8af212d 100644 --- a/tests/MiniProgram/EncryptorTest.php +++ b/tests/MiniProgram/EncryptorTest.php @@ -43,7 +43,7 @@ public function testDecrypt() $decrypted = $this->getEncryptor()->decryptData($encryptedData); - $this->assertEquals('oGZUI0egBJY1zhBYw2KhdUfwVJJE', $decrypted->openId); - $this->assertEquals('ocMvos6NjeKLIBqg5Mr9QjxrP1FA', $decrypted->unionId); + $this->assertSame('oGZUI0egBJY1zhBYw2KhdUfwVJJE', $decrypted->openId); + $this->assertSame('ocMvos6NjeKLIBqg5Mr9QjxrP1FA', $decrypted->unionId); } } diff --git a/tests/MiniProgram/MiniProgramServerGuardTest.php b/tests/MiniProgram/MiniProgramServerGuardTest.php index 2806d333c..f24a1ffc4 100644 --- a/tests/MiniProgram/MiniProgramServerGuardTest.php +++ b/tests/MiniProgram/MiniProgramServerGuardTest.php @@ -33,7 +33,7 @@ public function testValidateRequest() { $result = $this->getServer(['echostr' => '3804283725124844375'])->serve(); - $this->assertEquals('3804283725124844375', $result->getContent()); + $this->assertSame('3804283725124844375', $result->getContent()); } public function testUserEnterSession() @@ -58,15 +58,15 @@ public function testUserEnterSession() $server = $this->getServer([], $json); $res = $server->setMessageHandler(function ($message) { - $this->assertEquals('user_enter_tempsession', $message->Event); + $this->assertSame('user_enter_tempsession', $message->Event); })->serve(); - $this->assertEquals('success', $res->getContent()); + $this->assertSame('success', $res->getContent()); $server = $this->getServer([], $xml); $res2 = $server->setMessageHandler(function ($message) { - $this->assertEquals('user_enter_tempsession', $message->Event); + $this->assertSame('user_enter_tempsession', $message->Event); })->serve(); - $this->assertEquals('success', $res2->getContent()); + $this->assertSame('success', $res2->getContent()); } } diff --git a/tests/MiniProgram/Stats/StatsTest.php b/tests/MiniProgram/Stats/StatsTest.php index d75e99a1b..f0ccb31b5 100644 --- a/tests/MiniProgram/Stats/StatsTest.php +++ b/tests/MiniProgram/Stats/StatsTest.php @@ -37,8 +37,8 @@ public function testSummaryTrend() $stats = $this->getStats(); $result = $stats->summaryTrend('20170313', '20170313'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend', $result['api']); - $this->assertEquals(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend', $result['api']); + $this->assertSame(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); } /** @@ -49,8 +49,8 @@ public function testDailyVisitTrend() $stats = $this->getStats(); $result = $stats->dailyVisitTrend('20170313', '20170313'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend', $result['api']); - $this->assertEquals(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend', $result['api']); + $this->assertSame(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); } /** @@ -61,8 +61,8 @@ public function testWeeklyVisitTrend() $stats = $this->getStats(); $result = $stats->weeklyVisitTrend('20170306', '20170312'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend', $result['api']); - $this->assertEquals(['begin_date' => '20170306', 'end_date' => '20170312'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappidweeklyvisittrend', $result['api']); + $this->assertSame(['begin_date' => '20170306', 'end_date' => '20170312'], $result['params']); } /** @@ -73,8 +73,8 @@ public function testMonthlyVisitTrend() $stats = $this->getStats(); $result = $stats->monthlyVisitTrend('20170201', '20170228'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend', $result['api']); - $this->assertEquals(['begin_date' => '20170201', 'end_date' => '20170228'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyvisittrend', $result['api']); + $this->assertSame(['begin_date' => '20170201', 'end_date' => '20170228'], $result['params']); } /** @@ -85,8 +85,8 @@ public function testVisitDistribution() $stats = $this->getStats(); $result = $stats->visitDistribution('20170313', '20170313'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution', $result['api']); - $this->assertEquals(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappidvisitdistribution', $result['api']); + $this->assertSame(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); } /** @@ -97,8 +97,8 @@ public function testDailyRetainInfo() $stats = $this->getStats(); $result = $stats->dailyRetainInfo('20170313', '20170313'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo', $result['api']); - $this->assertEquals(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo', $result['api']); + $this->assertSame(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); } /** @@ -109,8 +109,8 @@ public function testWeeklyRetainInfo() $stats = $this->getStats(); $result = $stats->weeklyRetainInfo('20170306', '20170312'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo', $result['api']); - $this->assertEquals(['begin_date' => '20170306', 'end_date' => '20170312'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappidweeklyretaininfo', $result['api']); + $this->assertSame(['begin_date' => '20170306', 'end_date' => '20170312'], $result['params']); } /** @@ -121,8 +121,8 @@ public function testMontylyRetainInfo() $stats = $this->getStats(); $result = $stats->montylyRetainInfo('20170201', '20170228'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo', $result['api']); - $this->assertEquals(['begin_date' => '20170201', 'end_date' => '20170228'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappidmonthlyretaininfo', $result['api']); + $this->assertSame(['begin_date' => '20170201', 'end_date' => '20170228'], $result['params']); } /** @@ -133,7 +133,7 @@ public function testVisitPage() $stats = $this->getStats(); $result = $stats->visitPage('20170313', '20170313'); - $this->assertEquals('https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage', $result['api']); - $this->assertEquals(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); + $this->assertSame('https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage', $result['api']); + $this->assertSame(['begin_date' => '20170313', 'end_date' => '20170313'], $result['params']); } } diff --git a/tests/OfficialAccount/Broadcast/ClientTest.php b/tests/OfficialAccount/Broadcast/ClientTest.php index 36f806b1a..b771a88cc 100755 --- a/tests/OfficialAccount/Broadcast/ClientTest.php +++ b/tests/OfficialAccount/Broadcast/ClientTest.php @@ -49,7 +49,7 @@ public function testSend() ], 'msgtype' => 'text', ]; - $this->assertEquals($data, $response['params']); + $this->assertSame($data, $response['params']); $broadcast = $this->getBroadcast(); @@ -67,7 +67,7 @@ public function testSend() ], 'msgtype' => 'text', ]; - $this->assertEquals($data, $response['params']); + $this->assertSame($data, $response['params']); } /** @@ -87,7 +87,7 @@ public function testPreview() ], 'msgtype' => 'text', ]; - $this->assertEquals($data, $response['params']); + $this->assertSame($data, $response['params']); $broadcast = $this->getBroadcast(); @@ -101,7 +101,7 @@ public function testPreview() ], 'msgtype' => 'text', ]; - $this->assertEquals($data, $response['params']); + $this->assertSame($data, $response['params']); } /** @@ -114,7 +114,7 @@ public function testDelete() $response = $broadcast->delete('MSG_ID'); $this->assertStringStartsWith(Broadcast::API_DELETE, $response['api']); - $this->assertEquals('MSG_ID', $response['params']['msg_id']); + $this->assertSame('MSG_ID', $response['params']['msg_id']); } /** @@ -127,7 +127,7 @@ public function testStatus() $response = $broadcast->status('MSG_ID'); $this->assertStringStartsWith(Broadcast::API_GET, $response['api']); - $this->assertEquals('MSG_ID', $response['params']['msg_id']); + $this->assertSame('MSG_ID', $response['params']['msg_id']); } public function testAlias() @@ -145,79 +145,79 @@ public function testAlias() // sendText $result = $broadcast->sendText('hello', 'overtrue'); - $this->assertEquals(['api' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue'], $result); + $this->assertSame(['api' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue'], $result); // sendNews $result = $broadcast->sendNews('hello', 'overtrue'); - $this->assertEquals(['api' => Broadcast::MSG_TYPE_NEWS, 'message' => 'hello', 'to' => 'overtrue'], $result); + $this->assertSame(['api' => Broadcast::MSG_TYPE_NEWS, 'message' => 'hello', 'to' => 'overtrue'], $result); // sendVoice $result = $broadcast->sendVoice('hello', 'overtrue'); - $this->assertEquals(['api' => Broadcast::MSG_TYPE_VOICE, 'message' => 'hello', 'to' => 'overtrue'], $result); + $this->assertSame(['api' => Broadcast::MSG_TYPE_VOICE, 'message' => 'hello', 'to' => 'overtrue'], $result); // sendImage $result = $broadcast->sendImage('hello', 'overtrue'); - $this->assertEquals(['api' => Broadcast::MSG_TYPE_IMAGE, 'message' => 'hello', 'to' => 'overtrue'], $result); + $this->assertSame(['api' => Broadcast::MSG_TYPE_IMAGE, 'message' => 'hello', 'to' => 'overtrue'], $result); // sendVideo $result = $broadcast->sendVideo('hello', 'overtrue'); - $this->assertEquals(['api' => Broadcast::MSG_TYPE_VIDEO, 'message' => 'hello', 'to' => 'overtrue'], $result); + $this->assertSame(['api' => Broadcast::MSG_TYPE_VIDEO, 'message' => 'hello', 'to' => 'overtrue'], $result); // sendCard $result = $broadcast->sendCard('hello', 'overtrue'); - $this->assertEquals(['api' => Broadcast::MSG_TYPE_CARD, 'message' => 'hello', 'to' => 'overtrue'], $result); + $this->assertSame(['api' => Broadcast::MSG_TYPE_CARD, 'message' => 'hello', 'to' => 'overtrue'], $result); ////////// preview ///////// // previewText $result = $broadcast->previewText('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); // previewNews $result = $broadcast->previewNews('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_NEWS, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_NEWS, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); // previewVoice $result = $broadcast->previewVoice('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_VOICE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_VOICE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); // previewImage $result = $broadcast->previewImage('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_IMAGE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_IMAGE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); // previewVideo $result = $broadcast->previewVideo('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_VIDEO, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_VIDEO, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); // previewCard $result = $broadcast->previewCard('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_CARD, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_CARD, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_OPENID], $result); // previewByName $result = $broadcast->previewByName(Broadcast::MSG_TYPE_TEXT, 'hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); // previewTextByName $result = $broadcast->previewTextByName('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_TEXT, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); // previewNewsByName $result = $broadcast->previewNewsByName('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_NEWS, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_NEWS, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); // previewVoiceByName $result = $broadcast->previewVoiceByName('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_VOICE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_VOICE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); // previewImageByName $result = $broadcast->previewImageByName('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_IMAGE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_IMAGE, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); // previewVideoByName $result = $broadcast->previewVideoByName('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_VIDEO, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_VIDEO, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); // previewCardByName $result = $broadcast->previewCardByName('hello', 'overtrue'); - $this->assertEquals(['msgType' => Broadcast::MSG_TYPE_CARD, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); + $this->assertSame(['msgType' => Broadcast::MSG_TYPE_CARD, 'message' => 'hello', 'to' => 'overtrue', 'by' => Broadcast::PREVIEW_BY_NAME], $result); } } diff --git a/tests/OfficialAccount/Broadcast/MessageBuilderTest.php b/tests/OfficialAccount/Broadcast/MessageBuilderTest.php index 750423f96..fe69b0360 100755 --- a/tests/OfficialAccount/Broadcast/MessageBuilderTest.php +++ b/tests/OfficialAccount/Broadcast/MessageBuilderTest.php @@ -28,8 +28,8 @@ public function testMsgType() $response = $messageBuilder->msgType(Broadcast::MSG_TYPE_TEXT); - $this->assertEquals($messageBuilder, $response); - $this->assertEquals(Broadcast::MSG_TYPE_TEXT, $messageBuilder->msgType); + $this->assertSame($messageBuilder, $response); + $this->assertSame(Broadcast::MSG_TYPE_TEXT, $messageBuilder->msgType); // exception $messageBuilder->msgType('link'); @@ -44,8 +44,8 @@ public function testMessage() $response = $messageBuilder->message('CONTENT'); - $this->assertEquals($messageBuilder, $response); - $this->assertEquals('CONTENT', $messageBuilder->message); + $this->assertSame($messageBuilder, $response); + $this->assertSame('CONTENT', $messageBuilder->message); } /** @@ -57,8 +57,8 @@ public function testTo() $response = $messageBuilder->to('GROUP'); - $this->assertEquals($messageBuilder, $response); - $this->assertEquals('GROUP', $messageBuilder->to); + $this->assertSame($messageBuilder, $response); + $this->assertSame('GROUP', $messageBuilder->to); } /** @@ -79,7 +79,7 @@ public function testBuild() ], 'msgtype' => 'text', ]; - $this->assertEquals($message, $messageBuilder->build()); + $this->assertSame($message, $messageBuilder->build()); $messageBuilder = new MessageBuilder(); $messageBuilder->msgType(Broadcast::MSG_TYPE_VIDEO)->message('MEDIA_ID'); @@ -92,7 +92,7 @@ public function testBuild() ], 'msgtype' => 'mpvideo', ]; - $this->assertEquals($message, $messageBuilder->build()); + $this->assertSame($message, $messageBuilder->build()); $messageBuilder = new MessageBuilder(); $messageBuilder->msgType(Broadcast::MSG_TYPE_VIDEO)->message(['MEDIA_ID', 'TITLE', 'DESCRIPTION'])->to(['OPENID1', 'OPENID2', 'OPENID3']); @@ -109,7 +109,7 @@ public function testBuild() ], 'msgtype' => 'video', ]; - $this->assertEquals($message, $messageBuilder->build()); + $this->assertSame($message, $messageBuilder->build()); // exception $messageBuilder = new MessageBuilder(); @@ -133,7 +133,7 @@ public function testBuildPreview() ], 'msgtype' => 'text', ]; - $this->assertEquals($message, $messageBuilder->buildPreview(Broadcast::PREVIEW_BY_OPENID)); + $this->assertSame($message, $messageBuilder->buildPreview(Broadcast::PREVIEW_BY_OPENID)); $messageBuilder = new MessageBuilder(); $messageBuilder->msgType(Broadcast::MSG_TYPE_TEXT)->message('CONTENT')->to('WXH'); @@ -144,7 +144,7 @@ public function testBuildPreview() ], 'msgtype' => 'text', ]; - $this->assertEquals($message, $messageBuilder->buildPreview(Broadcast::PREVIEW_BY_NAME)); + $this->assertSame($message, $messageBuilder->buildPreview(Broadcast::PREVIEW_BY_NAME)); // exception $messageBuilder = new MessageBuilder(); diff --git a/tests/OfficialAccount/Broadcast/TransformerTest.php b/tests/OfficialAccount/Broadcast/TransformerTest.php index e8679d475..e1c0840f2 100755 --- a/tests/OfficialAccount/Broadcast/TransformerTest.php +++ b/tests/OfficialAccount/Broadcast/TransformerTest.php @@ -23,7 +23,7 @@ public function testTransform() { $transformer = new Transformer('link', 'http://easywechat.org'); - $this->assertEquals([], $transformer->transform()); + $this->assertSame([], $transformer->transform()); } /** @@ -40,7 +40,7 @@ public function testTransformText() 'msgtype' => 'text', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); } /** @@ -57,7 +57,7 @@ public function testTransformNews() 'msgtype' => 'mpnews', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); } /** @@ -74,7 +74,7 @@ public function testTransformImage() 'msgtype' => 'image', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); } /** @@ -95,7 +95,7 @@ public function testTransformVideo() 'msgtype' => 'video', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); // exception (new Transformer('video', ['MEDIA_ID', 'TITLE']))->transform(); @@ -115,7 +115,7 @@ public function testTransformMpvideo() 'msgtype' => 'mpvideo', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); } /** @@ -132,7 +132,7 @@ public function testTransformVoice() 'msgtype' => 'voice', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); } /** @@ -149,6 +149,6 @@ public function testTransformCard() 'msgtype' => 'wxcard', ]; - $this->assertEquals($msg, $transformer->transform()); + $this->assertSame($msg, $transformer->transform()); } } diff --git a/tests/OfficialAccount/Card/ClientTest.php b/tests/OfficialAccount/Card/ClientTest.php index 864f5eb34..38ac9e4db 100644 --- a/tests/OfficialAccount/Card/ClientTest.php +++ b/tests/OfficialAccount/Card/ClientTest.php @@ -127,8 +127,8 @@ public function testCreate() $result = $card->create($cardType, $baseInfo, $especial); $this->assertStringStartsWith(Card::API_CREATE_CARD, $result['api']); - $this->assertEquals($cardType, $result['params']['card']['card_type']); - $this->assertEquals($baseInfo, $result['params']['card'][$type]['base_info']); + $this->assertSame($cardType, $result['params']['card']['card_type']); + $this->assertSame($baseInfo, $result['params']['card'][$type]['base_info']); } //创建二维码 @@ -163,7 +163,7 @@ public function testQRCode() $result = $card->QRCode($cards); $this->assertStringStartsWith(Card::API_CREATE_QRCODE, $result['api']); - $this->assertEquals($cards, $result['params']); + $this->assertSame($cards, $result['params']); } //ticket 换取二维码图片 @@ -247,11 +247,11 @@ public function testCreateLandingPage() $result = $card->createLandingPage($banner, $pageTitle, $canShare, $scene, $cardList); $this->assertStringStartsWith(Card::API_CREATE_LANDING_PAGE, $result['api']); - $this->assertEquals($banner, $result['params']['banner']); - $this->assertEquals($pageTitle, $result['params']['page_title']); - $this->assertEquals($canShare, $result['params']['can_share']); - $this->assertEquals($scene, $result['params']['scene']); - $this->assertEquals($cardList, $result['params']['card_list']); + $this->assertSame($banner, $result['params']['banner']); + $this->assertSame($pageTitle, $result['params']['page_title']); + $this->assertSame($canShare, $result['params']['can_share']); + $this->assertSame($scene, $result['params']['scene']); + $this->assertSame($cardList, $result['params']['card_list']); } //导入code接口 @@ -264,8 +264,8 @@ public function testDeposit() $result = $card->deposit($cardId, $code); $this->assertStringStartsWith(Card::API_DEPOSIT_CODE, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); } //查询导入code数目 @@ -277,7 +277,7 @@ public function testGetDepositedCount() $result = $card->getDepositedCount($cardId); $this->assertStringStartsWith(Card::API_GET_DEPOSIT_COUNT, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($cardId, $result['params']['card_id']); } //核查code接口 @@ -290,8 +290,8 @@ public function testCheckCode() $result = $card->checkCode($cardId, $code); $this->assertStringStartsWith(Card::API_CHECK_CODE, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); } //图文消息群发卡券 @@ -303,7 +303,7 @@ public function testGetHtml() $result = $card->getHtml($cardId); $this->assertStringStartsWith(Card::API_GET_HTML, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($cardId, $result['params']['card_id']); } //设置测试白名单 @@ -317,11 +317,11 @@ public function testSetTestWhitelist() // openids $result = $card->setTestWhitelist($openids); $this->assertStringStartsWith(Card::API_SET_TEST_WHITE_LIST, $result['api']); - $this->assertEquals($openids, $result['params']['openid']); + $this->assertSame($openids, $result['params']['openid']); // usernames $result = $card->setTestWhitelistByUsername($usernames); $this->assertStringStartsWith(Card::API_SET_TEST_WHITE_LIST, $result['api']); - $this->assertEquals($usernames, $result['params']['username']); + $this->assertSame($usernames, $result['params']['username']); } //查询Code接口 @@ -335,9 +335,9 @@ public function testGetCode() $result = $card->getCode($code, $checkConsume, $cardId); $this->assertStringStartsWith(Card::API_GET_CODE, $result['api']); - $this->assertEquals($code, $result['params']['code']); - $this->assertEquals($checkConsume, $result['params']['check_consume']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); + $this->assertSame($checkConsume, $result['params']['check_consume']); + $this->assertSame($cardId, $result['params']['card_id']); } //核销Code接口 @@ -350,24 +350,24 @@ public function testConsume() $result = $card->consume($cardId, $code); $this->assertStringStartsWith(Card::API_CONSUME_CARD, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); // test cardId $result = $card->consume($code); $this->assertStringStartsWith(Card::API_CONSUME_CARD, $result['api']); - $this->assertEquals($code, $result['params']['code']); + $this->assertSame($code, $result['params']['code']); $this->assertArrayNotHasKey('card_id', $result['params']); $result = $card->consume($cardId, $code); $this->assertStringStartsWith(Card::API_CONSUME_CARD, $result['api']); - $this->assertEquals($code, $result['params']['code']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); $result = $card->consume($code, $cardId); $this->assertStringStartsWith(Card::API_CONSUME_CARD, $result['api']); - $this->assertEquals($code, $result['params']['code']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); } //Code解码接口 @@ -379,7 +379,7 @@ public function testDecryptCode() $result = $card->decryptCode($encryptedCode); $this->assertStringStartsWith(Card::API_DECRYPT_CODE, $result['api']); - $this->assertEquals($encryptedCode, $result['params']['encrypt_code']); + $this->assertSame($encryptedCode, $result['params']['encrypt_code']); } //获取用户已领取卡券接口 @@ -392,8 +392,8 @@ public function testGetUserCards() $result = $card->getUserCards($openid, $cardId); $this->assertStringStartsWith(Card::API_GET_CARD_LIST, $result['api']); - $this->assertEquals($openid, $result['params']['openid']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($openid, $result['params']['openid']); + $this->assertSame($cardId, $result['params']['card_id']); } //查看卡券详情 @@ -405,7 +405,7 @@ public function testGetCard() $result = $card->getCard($cardId); $this->assertStringStartsWith(Card::API_GET_CARD, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($cardId, $result['params']['card_id']); } //批量查询卡列表 @@ -419,9 +419,9 @@ public function testLists() $result = $card->lists($offset, $count, $statusList); $this->assertStringStartsWith(Card::API_LIST_CARD, $result['api']); - $this->assertEquals($offset, $result['params']['offset']); - $this->assertEquals($count, $result['params']['count']); - $this->assertEquals($statusList, $result['params']['status_list']); + $this->assertSame($offset, $result['params']['offset']); + $this->assertSame($count, $result['params']['count']); + $this->assertSame($statusList, $result['params']['status_list']); } //更改卡券信息接口 and 设置跟随推荐接口 @@ -445,8 +445,8 @@ public function testUpdate() $result = $card->update($cardId, $type, $baseInfo); $this->assertStringStartsWith(Card::API_UPDATE_CARD, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals($baseInfo, $result['params'][$type]['base_info']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame($baseInfo, $result['params'][$type]['base_info']); } //设置微信买单接口 @@ -459,8 +459,8 @@ public function testSetPayCell() $result = $card->setPayCell($cardId, $isOpen); $this->assertStringStartsWith(Card::API_SET_PAY_CELL, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals($isOpen, $result['params']['is_open']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame($isOpen, $result['params']['is_open']); } //修改库存接口 @@ -472,12 +472,12 @@ public function testModifyStock() $result = $card->increaseStock($cardId, 100); $this->assertStringStartsWith(Card::API_MODIFY_STOCK, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals(100, $result['params']['increase_stock_value']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame(100, $result['params']['increase_stock_value']); $result = $card->reduceStock($cardId, 100); $this->assertStringStartsWith(Card::API_MODIFY_STOCK, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals(100, $result['params']['reduce_stock_value']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame(100, $result['params']['reduce_stock_value']); } //更改Code接口 @@ -493,9 +493,9 @@ public function testUpdateCode() $result = $card->updateCode($code, $newCode, $cardId); $this->assertStringStartsWith(Card::API_UPDATE_CODE, $result['api']); - $this->assertEquals($code, $result['params']['code']); - $this->assertEquals($newCode, $result['params']['new_code']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); + $this->assertSame($newCode, $result['params']['new_code']); + $this->assertSame($cardId, $result['params']['card_id']); } //删除卡券接口 @@ -507,7 +507,7 @@ public function testDelete() $result = $card->delete($cardId); $this->assertStringStartsWith(Card::API_DELETE_CARD, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($cardId, $result['params']['card_id']); } //设置卡券失效 @@ -520,8 +520,8 @@ public function testDisable() $result = $card->disable($code, $cardId); $this->assertStringStartsWith(Card::API_DISABLE_CARD, $result['api']); - $this->assertEquals($code, $result['params']['code']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); } //会员卡接口激活 @@ -543,7 +543,7 @@ public function testActivate() $result = $card->activate($activate); $this->assertStringStartsWith(Card::API_ACTIVATE_MEMBER_CARD, $result['api']); - $this->assertEquals($activate, $result['params']); + $this->assertSame($activate, $result['params']); } //设置开卡字段接口 @@ -579,7 +579,7 @@ public function testActivateUserForm() $result = $card->activateUserForm($cardId, $requiredForm, $optionalForm); $this->assertStringStartsWith(Card::API_ACTIVATE_MEMBER_USER_FORM, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($cardId, $result['params']['card_id']); } //拉取会员信息接口 @@ -592,8 +592,8 @@ public function testGetMemberCardUser() $result = $card->getMemberCardUser($cardId, $code); $this->assertStringStartsWith(Card::API_GET_MEMBER_USER_INFO, $result['api']); - $this->assertEquals($cardId, $result['params']['card_id']); - $this->assertEquals($code, $result['params']['code']); + $this->assertSame($cardId, $result['params']['card_id']); + $this->assertSame($code, $result['params']['code']); } //更新会员信息 @@ -615,7 +615,7 @@ public function testUpdateMemberCardUser() $result = $card->updateMemberCardUser($updateUser); $this->assertStringStartsWith(Card::API_UPDATE_MEMBER_CARD_USER, $result['api']); - $this->assertEquals($updateUser, $result['params']); + $this->assertSame($updateUser, $result['params']); } //添加子商户 @@ -637,7 +637,7 @@ public function testCreateSubMerchant() $result = $card->createSubMerchant($info); $this->assertStringStartsWith(Card::API_CREATE_SUB_MERCHANT, $result['api']); - $this->assertEquals($info, $result['params']['info']); + $this->assertSame($info, $result['params']['info']); } //添加子商户 @@ -659,8 +659,8 @@ public function testUpdateSubMerchant() $result = $card->updateSubMerchant('12', $info); $this->assertStringStartsWith(Card::API_UPDATE_SUB_MERCHANT, $result['api']); - $this->assertEquals(12, $result['params']['info']['merchant_id']); - $this->assertEquals($info, Arr::except($result['params']['info'], 'merchant_id')); + $this->assertSame(12, $result['params']['info']['merchant_id']); + $this->assertSame($info, Arr::except($result['params']['info'], 'merchant_id')); } //卡券开放类目查询接口 diff --git a/tests/OfficialAccount/Comment/ClientTest.php b/tests/OfficialAccount/Comment/ClientTest.php index 203d73399..78e024084 100644 --- a/tests/OfficialAccount/Comment/ClientTest.php +++ b/tests/OfficialAccount/Comment/ClientTest.php @@ -19,7 +19,7 @@ public function testOpenComment() { $result = $this->getComment()->open('xxx123', 0); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/open', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/open', $result['api']); $this->assertSame(['msg_data_id' => 'xxx123', 'index' => 0], $result['params']); } @@ -27,7 +27,7 @@ public function testCloseComment() { $result = $this->getComment()->close('xxx123', 0); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/close', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/close', $result['api']); $this->assertSame(['msg_data_id' => 'xxx123', 'index' => 0], $result['params']); } @@ -35,7 +35,7 @@ public function testListComment() { $result = $this->getComment()->lists('xxx123', 0, 10, 20, 0); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/list', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/list', $result['api']); $this->assertSame([ 'msg_data_id' => 'xxx123', 'index' => 0, @@ -49,7 +49,7 @@ public function testMarkElect() { $result = $this->getComment()->markElect('xxx123', 0, 'comment-id'); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/markelect', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/markelect', $result['api']); $this->assertSame([ 'msg_data_id' => 'xxx123', 'index' => 0, @@ -61,7 +61,7 @@ public function testUnmarkElect() { $result = $this->getComment()->unmarkElect('xxx123', 0, 'comment-id'); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/unmarkelect', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/unmarkelect', $result['api']); $this->assertSame([ 'msg_data_id' => 'xxx123', 'index' => 0, @@ -73,7 +73,7 @@ public function testDeleteComment() { $result = $this->getComment()->delete('xxx123', 0, 'comment-id'); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/delete', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/delete', $result['api']); $this->assertSame([ 'msg_data_id' => 'xxx123', 'index' => 0, @@ -85,7 +85,7 @@ public function testAddReply() { $result = $this->getComment()->reply('xxx123', 0, 'comment-id', 'content...'); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/reply/add', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/reply/add', $result['api']); $this->assertSame([ 'msg_data_id' => 'xxx123', 'index' => 0, @@ -98,7 +98,7 @@ public function testDeleteReply() { $result = $this->getComment()->deleteReply('xxx123', 0, 'comment-id'); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/comment/reply/delete', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/comment/reply/delete', $result['api']); $this->assertSame([ 'msg_data_id' => 'xxx123', 'index' => 0, diff --git a/tests/OfficialAccount/Core/CoreAccessTokenTest.php b/tests/OfficialAccount/Core/CoreAccessTokenTest.php index ff92cde7f..9756b5f82 100755 --- a/tests/OfficialAccount/Core/CoreAccessTokenTest.php +++ b/tests/OfficialAccount/Core/CoreAccessTokenTest.php @@ -39,9 +39,9 @@ public function testGetToken() $accessToken->setCache($cache); $accessToken->setHttp($http); - $this->assertEquals('thisIsACachedToken', $accessToken->getToken()); + $this->assertSame('thisIsACachedToken', $accessToken->getToken()); // forceRefresh - $this->assertEquals('thisIsATokenFromHttp', $accessToken->getToken(true)); + $this->assertSame('thisIsATokenFromHttp', $accessToken->getToken(true)); } /** @@ -54,7 +54,6 @@ public function testNonCachedGetToken() // non-cached $cache = \Mockery::mock(Cache::class, function ($mock) use ($cacheObj) { $mock->shouldReceive('fetch')->andReturnUsing(function ($cacheKey) { - return; }); $mock->shouldReceive('save')->andReturnUsing(function ($key, $token, $expire) use ($cacheObj) { @@ -77,9 +76,9 @@ public function testNonCachedGetToken() $accessToken->setCache($cache); $accessToken->setHttp($http); - $this->assertEquals('thisIsATokenFromHttp', $accessToken->getToken()); - $this->assertEquals('thisIsATokenFromHttp', $cacheObj->token); - $this->assertEquals(5700, $cacheObj->expire); + $this->assertSame('thisIsATokenFromHttp', $accessToken->getToken()); + $this->assertSame('thisIsATokenFromHttp', $cacheObj->token); + $this->assertSame(5700, $cacheObj->expire); $http = \Mockery::mock(Http::class.'[get]', function ($mock) { $mock->shouldReceive('get')->andReturn(json_encode([ @@ -102,8 +101,8 @@ public function testGetterAndSetter() { $accessToken = new AccessToken('appId', 'secret'); - $this->assertEquals('secret', $accessToken->getClientSecret()); - $this->assertEquals('appId', $accessToken->getClientId()); + $this->assertSame('secret', $accessToken->getClientSecret()); + $this->assertSame('appId', $accessToken->getClientId()); $this->assertInstanceOf(\Doctrine\Common\Cache\FilesystemCache::class, $accessToken->getCache()); @@ -115,14 +114,14 @@ public function testGetterAndSetter() }); $accessToken->setCache($cache); - $this->assertEquals($cache, $accessToken->getCache()); + $this->assertSame($cache, $accessToken->getCache()); - $this->assertEquals('access_token', $accessToken->getQueryName()); + $this->assertSame('access_token', $accessToken->getQueryName()); $this->assertArrayHasKey('access_token', $accessToken->getQueryFields()); $accessToken->setQueryName('foo'); - $this->assertEquals('foo', $accessToken->getQueryName()); + $this->assertSame('foo', $accessToken->getQueryName()); $this->assertArrayHasKey('foo', $accessToken->getQueryFields()); $this->assertArrayNotHasKey('access_token', $accessToken->getQueryFields()); } @@ -131,8 +130,8 @@ public function testSetToken() { $accessToken = new AccessToken('appId', 'secret'); - $this->assertEquals('secret', $accessToken->getClientSecret()); - $this->assertEquals('appId', $accessToken->getClientId()); + $this->assertSame('secret', $accessToken->getClientSecret()); + $this->assertSame('appId', $accessToken->getClientId()); $this->assertInstanceOf(\Doctrine\Common\Cache\FilesystemCache::class, $accessToken->getCache()); @@ -147,6 +146,6 @@ public function testSetToken() $accessToken->setToken('foo'); - $this->assertEquals('foo', $accessToken->getToken()); + $this->assertSame('foo', $accessToken->getToken()); } } diff --git a/tests/OfficialAccount/CustomerService/ClientTest.php b/tests/OfficialAccount/CustomerService/ClientTest.php index 6e4482984..bc88918e0 100755 --- a/tests/OfficialAccount/CustomerService/ClientTest.php +++ b/tests/OfficialAccount/CustomerService/ClientTest.php @@ -60,8 +60,8 @@ public function testCreate() $response = $customerService->create('anzhengchao@test', 'overtrue'); $this->assertStringStartsWith(CustomerService::API_CREATE, $response['api']); - $this->assertEquals('anzhengchao@test', $response['params']['kf_account']); - $this->assertEquals('overtrue', $response['params']['nickname']); + $this->assertSame('anzhengchao@test', $response['params']['kf_account']); + $this->assertSame('overtrue', $response['params']['nickname']); } /** @@ -74,8 +74,8 @@ public function testUpdate() $response = $customerService->update('anzhengchao@test', 'overtrue'); $this->assertStringStartsWith(CustomerService::API_UPDATE, $response['api']); - $this->assertEquals('anzhengchao@test', $response['params']['kf_account']); - $this->assertEquals('overtrue', $response['params']['nickname']); + $this->assertSame('anzhengchao@test', $response['params']['kf_account']); + $this->assertSame('overtrue', $response['params']['nickname']); } /** @@ -88,8 +88,8 @@ public function testInvite() $response = $customerService->invite('anzhengchao@test', 'overtrue'); $this->assertStringStartsWith(CustomerService::API_INVITE_BIND, $response['api']); - $this->assertEquals('anzhengchao@test', $response['params']['kf_account']); - $this->assertEquals('overtrue', $response['params']['invite_wx']); + $this->assertSame('anzhengchao@test', $response['params']['kf_account']); + $this->assertSame('overtrue', $response['params']['invite_wx']); } /** @@ -117,6 +117,6 @@ public function testAvatar() $this->assertStringStartsWith(CustomerService::API_AVATAR_UPLOAD, $response['api']); $this->assertContains('anzhengchao@test', $response['quires']['kf_account']); - $this->assertEquals(['media' => '/foobar/avatar.jpg'], $response['params']); + $this->assertSame(['media' => '/foobar/avatar.jpg'], $response['params']); } } diff --git a/tests/OfficialAccount/CustomerService/MessageBuilderTest.php b/tests/OfficialAccount/CustomerService/MessageBuilderTest.php index 5a58747c4..6a22eebbd 100755 --- a/tests/OfficialAccount/CustomerService/MessageBuilderTest.php +++ b/tests/OfficialAccount/CustomerService/MessageBuilderTest.php @@ -37,7 +37,7 @@ public function testMessage() $response = $MessageBuilder->message('hello'); - $this->assertEquals($MessageBuilder, $response); + $this->assertSame($MessageBuilder, $response); $this->assertInstanceOf(Text::class, $MessageBuilder->message); } @@ -50,8 +50,8 @@ public function testBy() $response = $MessageBuilder->by('hello'); - $this->assertEquals($MessageBuilder, $response); - $this->assertEquals('hello', $MessageBuilder->account); + $this->assertSame($MessageBuilder, $response); + $this->assertSame('hello', $MessageBuilder->account); $this->assertNull($MessageBuilder->by); } @@ -64,8 +64,8 @@ public function testTo() $response = $MessageBuilder->to('overtrue'); - $this->assertEquals($MessageBuilder, $response); - $this->assertEquals('overtrue', $MessageBuilder->to); + $this->assertSame($MessageBuilder, $response); + $this->assertSame('overtrue', $MessageBuilder->to); } /** @@ -79,10 +79,10 @@ public function testSend() $response = $MessageBuilder->message('hello')->by('overtrue')->to('easywechat')->send(); - $this->assertEquals('text', $response['msgtype']); - $this->assertEquals('hello', $response['text']['content']); - $this->assertEquals('overtrue', $response['customservice']['kf_account']); - $this->assertEquals('easywechat', $response['touser']); + $this->assertSame('text', $response['msgtype']); + $this->assertSame('hello', $response['text']['content']); + $this->assertSame('overtrue', $response['customservice']['kf_account']); + $this->assertSame('easywechat', $response['touser']); // exception $MessageBuilder = $this->getMessageBuilder(); @@ -106,6 +106,6 @@ public function testRawMessage() $message = new Raw($string); $response = $MessageBuilder->message($message)->send(); - $this->assertEquals($string, $response); + $this->assertSame($string, $response); } } diff --git a/tests/OfficialAccount/CustomerService/SessionTest.php b/tests/OfficialAccount/CustomerService/SessionTest.php index 33f8765f2..d5e276f79 100644 --- a/tests/OfficialAccount/CustomerService/SessionTest.php +++ b/tests/OfficialAccount/CustomerService/SessionTest.php @@ -66,8 +66,8 @@ public function testCreate() $response = $session->create('anzhengchao@test', 'overtrue_openid'); $this->assertStringStartsWith(Session::API_CREATE, $response['api']); - $this->assertEquals('anzhengchao@test', $response['params']['kf_account']); - $this->assertEquals('overtrue_openid', $response['params']['openid']); + $this->assertSame('anzhengchao@test', $response['params']['kf_account']); + $this->assertSame('overtrue_openid', $response['params']['openid']); } /** @@ -80,8 +80,8 @@ public function testClose() $response = $session->close('anzhengchao@test', 'overtrue_openid'); $this->assertStringStartsWith(Session::API_CLOSE, $response['api']); - $this->assertEquals('anzhengchao@test', $response['params']['kf_account']); - $this->assertEquals('overtrue_openid', $response['params']['openid']); + $this->assertSame('anzhengchao@test', $response['params']['kf_account']); + $this->assertSame('overtrue_openid', $response['params']['openid']); } /** diff --git a/tests/OfficialAccount/CustomerService/TransformerTest.php b/tests/OfficialAccount/CustomerService/TransformerTest.php index 36a963e1c..ee75cc9e8 100755 --- a/tests/OfficialAccount/CustomerService/TransformerTest.php +++ b/tests/OfficialAccount/CustomerService/TransformerTest.php @@ -30,7 +30,7 @@ public function testTransform() $message = \Mockery::mock(Link::class); $transformer = new Transformer(); - $this->assertEquals([], $transformer->transform($message)); + $this->assertSame([], $transformer->transform($message)); } /** @@ -43,7 +43,7 @@ public function testTransformText() $transformer = new Transformer(); - $this->assertEquals(['msgtype' => 'text', 'text' => ['content' => 'foo']], $transformer->transform($message)); + $this->assertSame(['msgtype' => 'text', 'text' => ['content' => 'foo']], $transformer->transform($message)); } /** @@ -56,7 +56,7 @@ public function testTransformImage() $transformer = new Transformer(); - $this->assertEquals(['msgtype' => 'image', 'image' => ['media_id' => 'foo']], $transformer->transform($message)); + $this->assertSame(['msgtype' => 'image', 'image' => ['media_id' => 'foo']], $transformer->transform($message)); } /** @@ -73,11 +73,11 @@ public function testTransformVideo() $transformer = new Transformer(); $result = $transformer->transform($message); - $this->assertEquals('video', $result['msgtype']); - $this->assertEquals('foo', $result['video']['media_id']); - $this->assertEquals('hello world', $result['video']['title']); - $this->assertEquals('description string.', $result['video']['description']); - $this->assertEquals('thumb media id', $result['video']['thumb_media_id']); + $this->assertSame('video', $result['msgtype']); + $this->assertSame('foo', $result['video']['media_id']); + $this->assertSame('hello world', $result['video']['title']); + $this->assertSame('description string.', $result['video']['description']); + $this->assertSame('thumb media id', $result['video']['thumb_media_id']); } /** @@ -90,7 +90,7 @@ public function testTransformVoice() $transformer = new Transformer(); - $this->assertEquals(['msgtype' => 'voice', 'voice' => ['media_id' => 'foo']], $transformer->transform($message)); + $this->assertSame(['msgtype' => 'voice', 'voice' => ['media_id' => 'foo']], $transformer->transform($message)); } /** @@ -106,9 +106,9 @@ public function testTransformNews() 'description' => 'foobar', ])); - $this->assertEquals('news', $result['msgtype']); - $this->assertEquals('overtrue', $result['news']['articles'][0]['title']); - $this->assertEquals('foobar', $result['news']['articles'][0]['description']); + $this->assertSame('news', $result['msgtype']); + $this->assertSame('overtrue', $result['news']['articles'][0]['title']); + $this->assertSame('foobar', $result['news']['articles'][0]['description']); // more $news = [ @@ -117,8 +117,8 @@ public function testTransformNews() ]; $result = $transformer->transform($news); - $this->assertEquals('news', $result['msgtype']); - $this->assertEquals('foo', $result['news']['articles'][0]['title']); - $this->assertEquals('bar', $result['news']['articles'][1]['title']); + $this->assertSame('news', $result['msgtype']); + $this->assertSame('foo', $result['news']['articles'][0]['title']); + $this->assertSame('bar', $result['news']['articles'][1]['title']); } } diff --git a/tests/OfficialAccount/Encryption/EncryptionEncryptorTest.php b/tests/OfficialAccount/Encryption/EncryptionEncryptorTest.php index 9be491d45..969c841ac 100644 --- a/tests/OfficialAccount/Encryption/EncryptionEncryptorTest.php +++ b/tests/OfficialAccount/Encryption/EncryptionEncryptorTest.php @@ -27,10 +27,10 @@ public function testDecrypt() $encrypted = "\n \n \n\n"; $decrypted = $this->getEncryptor()->decryptMsg('4f3ad57b6989f09f4eb392acce4f9e93942ed890', '260774613', '1458300676', $encrypted); - $this->assertEquals('asdasdasd', $decrypted['ToUserName']); - $this->assertEquals('asdasdasdsadasd', $decrypted['FromUserName']); - $this->assertEquals('1234567898', $decrypted['CreateTime']); - $this->assertEquals('hello', $decrypted['Content']); + $this->assertSame('asdasdasd', $decrypted['ToUserName']); + $this->assertSame('asdasdasdsadasd', $decrypted['FromUserName']); + $this->assertSame('1234567898', $decrypted['CreateTime']); + $this->assertSame('hello', $decrypted['Content']); } public function testEncryptAndDecrypt() @@ -49,11 +49,11 @@ public function testEncryptAndDecrypt() $encrypted = $this->getEncryptor()->encryptMsg($xml, 'xxxxxx', '1407743423'); $array = XML::parse($encrypted); - $this->assertEquals('1407743423', $array['TimeStamp']); - $this->assertEquals('xxxxxx', $array['Nonce']); + $this->assertSame('1407743423', $array['TimeStamp']); + $this->assertSame('xxxxxx', $array['Nonce']); $this->assertNotEmpty($array['Encrypt']); $this->assertNotEmpty($array['MsgSignature']); - $this->assertEquals($raw, $this->getEncryptor()->decryptMsg($array['MsgSignature'], $array['Nonce'], $array['TimeStamp'], $encrypted)); + $this->assertSame($raw, $this->getEncryptor()->decryptMsg($array['MsgSignature'], $array['Nonce'], $array['TimeStamp'], $encrypted)); } } diff --git a/tests/OfficialAccount/Fundamental/ClientTest.php b/tests/OfficialAccount/Fundamental/ClientTest.php index 60a604c6d..c9a869ada 100644 --- a/tests/OfficialAccount/Fundamental/ClientTest.php +++ b/tests/OfficialAccount/Fundamental/ClientTest.php @@ -23,7 +23,7 @@ public function testClearQuota() { $result = $this->make('wxappid')->clearQuota(); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/clear_quota', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/clear_quota', $result['api']); $this->assertSame(['appid' => 'wxappid'], $result['params']); } @@ -34,7 +34,7 @@ public function testGetCallbackIp() { $result = $this->make()->getCallbackIp(); - $this->assertEquals('https://api.weixin.qq.com/cgi-bin/getcallbackip', $result['api']); + $this->assertSame('https://api.weixin.qq.com/cgi-bin/getcallbackip', $result['api']); } /** diff --git a/tests/OfficialAccount/Js/ClientTest.php b/tests/OfficialAccount/Js/ClientTest.php index 39a1d0ff3..3415a6762 100755 --- a/tests/OfficialAccount/Js/ClientTest.php +++ b/tests/OfficialAccount/Js/ClientTest.php @@ -71,7 +71,7 @@ public function testConfig() $config = $js->config(['startRecord', 'uploadImage'], true, true, false); - $this->assertEquals(['startRecord', 'uploadImage'], $config['jsApiList']); + $this->assertSame(['startRecord', 'uploadImage'], $config['jsApiList']); } /** @@ -90,7 +90,7 @@ public function testGetConfigArray() $config = $js->getConfigArray(['startRecord', 'uploadImage']); - $this->assertEquals(['startRecord', 'uploadImage'], $config['jsApiList']); + $this->assertSame(['startRecord', 'uploadImage'], $config['jsApiList']); } /** @@ -108,7 +108,7 @@ public function testTicket() $js->setHttp($http); $js->setUrl('http://easywechat.org'); - $this->assertEquals('foo', $js->ticket()); + $this->assertSame('foo', $js->ticket()); $http = $this->getMockHttp(); $cache = $this->getMockCache(); @@ -125,7 +125,7 @@ public function testTicket() $js->setCache($cache); $js->setHttp($http); - $this->assertEquals('overtrue.ticket', $js->ticket()); + $this->assertSame('overtrue.ticket', $js->ticket()); } /** @@ -144,23 +144,23 @@ public function testSignature() $signaturePack = $js->signature(); - $this->assertEquals('http://easywechat.org', $signaturePack['url']); - $this->assertEquals('foo', $signaturePack['appId']); + $this->assertSame('http://easywechat.org', $signaturePack['url']); + $this->assertSame('foo', $signaturePack['appId']); $this->assertArrayHasKey('signature', $signaturePack); $this->assertArrayHasKey('nonceStr', $signaturePack); $this->assertArrayHasKey('timestamp', $signaturePack); $signaturePack = $js->signature('http://overtrue.me'); - $this->assertEquals('http://overtrue.me', $signaturePack['url']); + $this->assertSame('http://overtrue.me', $signaturePack['url']); $signaturePack = $js->signature('http://overtrue.me', 'foobar'); - $this->assertEquals('http://overtrue.me', $signaturePack['url']); - $this->assertEquals('foobar', $signaturePack['nonceStr']); + $this->assertSame('http://overtrue.me', $signaturePack['url']); + $this->assertSame('foobar', $signaturePack['nonceStr']); $signaturePack = $js->signature('http://overtrue.me', 'foobar', 1234578902); - $this->assertEquals('http://overtrue.me', $signaturePack['url']); - $this->assertEquals('foobar', $signaturePack['nonceStr']); - $this->assertEquals('1234578902', $signaturePack['timestamp']); + $this->assertSame('http://overtrue.me', $signaturePack['url']); + $this->assertSame('foobar', $signaturePack['nonceStr']); + $this->assertSame('1234578902', $signaturePack['timestamp']); } /** @@ -182,7 +182,7 @@ public function testGetSignature() $url = 'http://easywechat.org'; $expect = sha1("jsapi_ticket={$ticket}&noncestr={$nonce}×tamp={$timestamp}&url={$url}"); - $this->assertEquals($expect, $js->getSignature($ticket, $nonce, $timestamp, $url)); + $this->assertSame($expect, $js->getSignature($ticket, $nonce, $timestamp, $url)); } /** @@ -198,11 +198,11 @@ public function testSetUrl() $js->setHttp($http); $js->setUrl('http://easywechat.org'); - $this->assertEquals('http://easywechat.org', $js->getUrl()); + $this->assertSame('http://easywechat.org', $js->getUrl()); $accessToken = $this->getMockAccessToken(); $js = new Js($accessToken, $cache); $js->setHttp($http); - $this->assertEquals('http://localhost', $js->getUrl()); + $this->assertSame('http://localhost', $js->getUrl()); } } } diff --git a/tests/OfficialAccount/Material/ClientTest.php b/tests/OfficialAccount/Material/ClientTest.php index 40d6138db..55e1c90e1 100755 --- a/tests/OfficialAccount/Material/ClientTest.php +++ b/tests/OfficialAccount/Material/ClientTest.php @@ -99,7 +99,7 @@ public function testUploadVideo() $this->assertStringStartsWith(Material::API_UPLOAD, $response[0]); $this->assertContains('stubs/video.mp4', $response[1]['media']); - $this->assertEquals(json_encode(['title' => 'foo', 'introduction' => 'a mp4 video.']), $response[2]['description']); + $this->assertSame(json_encode(['title' => 'foo', 'introduction' => 'a mp4 video.']), $response[2]['description']); } /** @@ -112,15 +112,15 @@ public function testUploadArticle() $response = $material->uploadArticle(['foo' => 'bar']); $this->assertStringStartsWith(Material::API_NEWS_UPLOAD, $response[0]); - $this->assertEquals(['articles' => ['foo' => 'bar']], $response[1]); + $this->assertSame(['articles' => ['foo' => 'bar']], $response[1]); $response = $material->uploadArticle(new Article(['title' => 'foo'])); - $this->assertEquals(['articles' => [['title' => 'foo']]], $response[1]); + $this->assertSame(['articles' => [['title' => 'foo']]], $response[1]); $response = $material->uploadArticle([new Article(['title' => 'foo', 'show_cover' => 0]), new Article(['title' => 'bar'])]); - $this->assertEquals(['articles' => [['title' => 'foo', 'show_cover_pic' => 0], ['title' => 'bar']]], $response[1]); + $this->assertSame(['articles' => [['title' => 'foo', 'show_cover_pic' => 0], ['title' => 'bar']]], $response[1]); } /** @@ -133,17 +133,17 @@ public function testUpdateArticle() $response = $material->updateArticle('foo', ['title' => 'bar']); $this->assertStringStartsWith(Material::API_NEWS_UPDATE, $response[0]); - $this->assertEquals('foo', $response[1]['media_id']); - $this->assertEquals(0, $response[1]['index']); - $this->assertEquals(['title' => 'bar'], $response[1]['articles']); + $this->assertSame('foo', $response[1]['media_id']); + $this->assertSame(0, $response[1]['index']); + $this->assertSame(['title' => 'bar'], $response[1]['articles']); // multi $response = $material->updateArticle('foo', [['title' => 'bar']]); - $this->assertEquals(['title' => 'bar'], $response[1]['articles']); + $this->assertSame(['title' => 'bar'], $response[1]['articles']); // invalid $article $response = $material->updateArticle('foo', ['abc' => 'bar']); - $this->assertEquals([], $response[1]['articles']); + $this->assertSame([], $response[1]['articles']); } /** @@ -176,7 +176,7 @@ public function testGet() $response = $material->get('foo'); $this->assertStringStartsWith(Material::API_GET, $response['api']); - $this->assertEquals(['media_id' => 'foo'], $response['params']); + $this->assertSame(['media_id' => 'foo'], $response['params']); // media $http = \Mockery::mock(Http::class.'[json]'); @@ -188,7 +188,7 @@ public function testGet() $response = $material->get('bar'); - $this->assertEquals('media content', $response); + $this->assertSame('media content', $response); } /** @@ -201,7 +201,7 @@ public function testDelete() $response = $material->delete('foo'); $this->assertStringStartsWith(Material::API_DELETE, $response[0]); - $this->assertEquals(['media_id' => 'foo'], $response[1]); + $this->assertSame(['media_id' => 'foo'], $response[1]); } /** @@ -221,7 +221,7 @@ public function testLists() ]; $this->assertStringStartsWith(Material::API_LISTS, $response[0]); - $this->assertEquals($params, $response[1]); + $this->assertSame($params, $response[1]); // out of range $response = $material->lists('image', 1, 21); @@ -233,7 +233,7 @@ public function testLists() ]; $this->assertStringStartsWith(Material::API_LISTS, $response[0]); - $this->assertEquals($params, $response[1]); + $this->assertSame($params, $response[1]); } /** diff --git a/tests/OfficialAccount/Material/TemporaryClientTest.php b/tests/OfficialAccount/Material/TemporaryClientTest.php index 1fdf3fbf6..7e3510f17 100755 --- a/tests/OfficialAccount/Material/TemporaryClientTest.php +++ b/tests/OfficialAccount/Material/TemporaryClientTest.php @@ -57,10 +57,10 @@ public function testDownload() $response = $temporary->download('foo', __DIR__); - $this->assertEquals('foo', $request->mediaId); - $this->assertEquals('foo.jpg', $response); - $this->assertEquals(__DIR__.'/foo.jpg', $GLOBALS['temporary_download_filename']); - $this->assertEquals($request, $GLOBALS['temporary_download_content']); + $this->assertSame('foo', $request->mediaId); + $this->assertSame('foo.jpg', $response); + $this->assertSame(__DIR__.'/foo.jpg', $GLOBALS['temporary_download_filename']); + $this->assertSame($request, $GLOBALS['temporary_download_content']); // exception path not exists. $response = $temporary->download('foo', '/this-is-are-non-exists-path'); @@ -83,7 +83,7 @@ public function testUpload() $result = $temporary->upload('image', __DIR__.'/stubs/image.jpg'); $this->assertStringStartsWith(Temporary::API_UPLOAD, $result[0]); - $this->assertEquals(['media' => __DIR__.'/stubs/image.jpg'], $result[1]); + $this->assertSame(['media' => __DIR__.'/stubs/image.jpg'], $result[1]); $temporary->upload('image', '/this-is-are-non-exists-path/foo.jpg'); // exception,invalid path } @@ -111,10 +111,10 @@ public function testProxyMethods() return [$type, $path]; }); - $this->assertEquals(['image', '/foobar'], $temporary->uploadImage('/foobar')); - $this->assertEquals(['video', '/foobar'], $temporary->uploadVideo('/foobar')); - $this->assertEquals(['voice', '/foobar'], $temporary->uploadVoice('/foobar')); - $this->assertEquals(['thumb', '/foobar'], $temporary->uploadThumb('/foobar')); + $this->assertSame(['image', '/foobar'], $temporary->uploadImage('/foobar')); + $this->assertSame(['video', '/foobar'], $temporary->uploadVideo('/foobar')); + $this->assertSame(['voice', '/foobar'], $temporary->uploadVoice('/foobar')); + $this->assertSame(['thumb', '/foobar'], $temporary->uploadThumb('/foobar')); } } } diff --git a/tests/OfficialAccount/Menu/ClientTest.php b/tests/OfficialAccount/Menu/ClientTest.php index 0d9e8d693..4db7ee1c7 100755 --- a/tests/OfficialAccount/Menu/ClientTest.php +++ b/tests/OfficialAccount/Menu/ClientTest.php @@ -64,14 +64,14 @@ public function testAdd() // normal $response = $menu->add($buttons); $this->assertStringStartsWith(Menu::API_CREATE, $response['api']); - $this->assertEquals($excepted, $response['params']['button']); + $this->assertSame($excepted, $response['params']['button']); // conditional $matchRule = ['group_id' => 2, 'province' => '广东']; $response = $menu->add($buttons, $matchRule); $this->assertStringStartsWith(Menu::API_CONDITIONAL_CREATE, $response['api']); - $this->assertEquals($excepted, $response['params']['button']); - $this->assertEquals($matchRule, $response['params']['matchrule']); + $this->assertSame($excepted, $response['params']['button']); + $this->assertSame($matchRule, $response['params']['matchrule']); } /** @@ -108,7 +108,7 @@ public function testDestroy() $response = $menu->destroy(23); $this->assertStringStartsWith(Menu::API_CONDITIONAL_DELETE, $response['api']); - $this->assertEquals(23, $response['params']['menuid']); + $this->assertSame(23, $response['params']['menuid']); } /** @@ -121,6 +121,6 @@ public function testTest() $response = $menu->test(234); $this->assertStringStartsWith(Menu::API_CONDITIONAL_TEST, $response['api']); - $this->assertEquals(234, $response['params']['user_id']); + $this->assertSame(234, $response['params']['user_id']); } } diff --git a/tests/OfficialAccount/Message/MessageAbstractMessageTest.php b/tests/OfficialAccount/Message/MessageAbstractMessageTest.php index de83f8d63..a071b7ca3 100755 --- a/tests/OfficialAccount/Message/MessageAbstractMessageTest.php +++ b/tests/OfficialAccount/Message/MessageAbstractMessageTest.php @@ -28,17 +28,17 @@ public function testGetterAndSetter() { $foo = new FooMessage(['foo' => 'overtrue']); - $this->assertEquals('overtrue', $foo->foo); + $this->assertSame('overtrue', $foo->foo); // normal $foo->foo = 'hello'; $foo->bar = 'barbar'; - $this->assertEquals('hello', $foo->foo); - $this->assertEquals('barbar', $foo->bar); + $this->assertSame('hello', $foo->foo); + $this->assertSame('barbar', $foo->bar); // property $foo->id = 6; - $this->assertEquals(6, $foo->id); + $this->assertSame(6, $foo->id); // non-exists $foo->nonExists = 'hello'; diff --git a/tests/OfficialAccount/Message/MessageArticleTest.php b/tests/OfficialAccount/Message/MessageArticleTest.php index 4f36e5a31..f822a5bdf 100644 --- a/tests/OfficialAccount/Message/MessageArticleTest.php +++ b/tests/OfficialAccount/Message/MessageArticleTest.php @@ -37,9 +37,9 @@ public function testAttributes() 'show_cover_pic', 'content', 'content_source_url', ]); - $this->assertEquals($return, $attributes); + $this->assertSame($return, $attributes); - $this->assertEquals($article->show_cover, $attributes['show_cover_pic']); - $this->assertEquals($article->source_url, $attributes['content_source_url']); + $this->assertSame($article->show_cover, $attributes['show_cover_pic']); + $this->assertSame($article->source_url, $attributes['content_source_url']); } } diff --git a/tests/OfficialAccount/Message/MessageImageTest.php b/tests/OfficialAccount/Message/MessageImageTest.php index abdf32683..b048620d9 100755 --- a/tests/OfficialAccount/Message/MessageImageTest.php +++ b/tests/OfficialAccount/Message/MessageImageTest.php @@ -25,7 +25,7 @@ public function testMedia() $return = $image->media('foobar'); - $this->assertEquals($image, $return); - $this->assertEquals('foobar', $return->media_id); + $this->assertSame($image, $return); + $this->assertSame('foobar', $return->media_id); } } diff --git a/tests/OfficialAccount/Message/MessageMaterialTest.php b/tests/OfficialAccount/Message/MessageMaterialTest.php index 0e7057810..669e8fe40 100644 --- a/tests/OfficialAccount/Message/MessageMaterialTest.php +++ b/tests/OfficialAccount/Message/MessageMaterialTest.php @@ -23,7 +23,7 @@ public function testAttributes() { $material = new Material('text', 'mediaId'); - $this->assertEquals('text', $material->type); - $this->assertEquals('mediaId', $material->media_id); + $this->assertSame('text', $material->type); + $this->assertSame('mediaId', $material->media_id); } } diff --git a/tests/OfficialAccount/Message/MessageVideoTest.php b/tests/OfficialAccount/Message/MessageVideoTest.php index 87911b9eb..086163542 100755 --- a/tests/OfficialAccount/Message/MessageVideoTest.php +++ b/tests/OfficialAccount/Message/MessageVideoTest.php @@ -25,8 +25,8 @@ public function testMedia() $return = $video->media('foobar'); - $this->assertEquals($video, $return); - $this->assertEquals('foobar', $return->media_id); + $this->assertSame($video, $return); + $this->assertSame('foobar', $return->media_id); } /** @@ -38,7 +38,7 @@ public function testThumb() $return = $video->thumb('thumbFoo'); - $this->assertEquals($video, $return); - $this->assertEquals('thumbFoo', $return->thumb_media_id); + $this->assertSame($video, $return); + $this->assertSame('thumbFoo', $return->thumb_media_id); } } diff --git a/tests/OfficialAccount/Message/MessageVoiceTest.php b/tests/OfficialAccount/Message/MessageVoiceTest.php index f2a06b4c6..adb1e6215 100755 --- a/tests/OfficialAccount/Message/MessageVoiceTest.php +++ b/tests/OfficialAccount/Message/MessageVoiceTest.php @@ -25,7 +25,7 @@ public function testMedia() $return = $voice->media('foobar'); - $this->assertEquals($voice, $return); - $this->assertEquals('foobar', $return->media_id); + $this->assertSame($voice, $return); + $this->assertSame('foobar', $return->media_id); } } diff --git a/tests/OfficialAccount/POI/ClientTest.php b/tests/OfficialAccount/POI/ClientTest.php index c4386f17b..b1addc661 100755 --- a/tests/OfficialAccount/POI/ClientTest.php +++ b/tests/OfficialAccount/POI/ClientTest.php @@ -49,7 +49,7 @@ public function testGet() $response = $POI->get('foo'); $this->assertStringStartsWith(POI::API_GET, $response['api']); - $this->assertEquals('foo', $response['params']['poi_id']); + $this->assertSame('foo', $response['params']['poi_id']); } /** @@ -65,8 +65,8 @@ public function testLists() $this->assertArrayHasKey('limit', $response['params']); $response = $POI->lists(10, 30); - $this->assertEquals(10, $response['params']['begin']); - $this->assertEquals(30, $response['params']['limit']); + $this->assertSame(10, $response['params']['begin']); + $this->assertSame(30, $response['params']['limit']); } /** @@ -80,7 +80,7 @@ public function testCreate() $response = $POI->create($data); $this->assertStringStartsWith(POI::API_CREATE, $response['api']); - $this->assertEquals(['business' => ['base_info' => $data]], $response['params']); + $this->assertSame(['business' => ['base_info' => $data]], $response['params']); } /** @@ -92,7 +92,7 @@ public function testUpdate() $response = $POI->update('foo', ['foo' => 'bar']); $this->assertStringStartsWith(POI::API_UPDATE, $response['api']); - $this->assertEquals(['business' => ['base_info' => ['poi_id' => 'foo', 'foo' => 'bar']]], $response['params']); + $this->assertSame(['business' => ['base_info' => ['poi_id' => 'foo', 'foo' => 'bar']]], $response['params']); } /** @@ -104,6 +104,6 @@ public function testDelete() $response = $POI->delete('foo'); $this->assertStringStartsWith(POI::API_DELETE, $response['api']); - $this->assertEquals('foo', $response['params']['poi_id']); + $this->assertSame('foo', $response['params']['poi_id']); } } diff --git a/tests/OfficialAccount/Payment/CashCouponClientTest.php b/tests/OfficialAccount/Payment/CashCouponClientTest.php index c3a641eda..f119f390d 100644 --- a/tests/OfficialAccount/Payment/CashCouponClientTest.php +++ b/tests/OfficialAccount/Payment/CashCouponClientTest.php @@ -57,11 +57,11 @@ public function testSend() $response = $api->send(['foo' => 'bar']); - $this->assertEquals(API::API_SEND, $response['api']); - $this->assertEquals('wxTestAppId', $response['options']['body']['appid']); - $this->assertEquals('testMerchantId', $response['options']['body']['mch_id']); + $this->assertSame(API::API_SEND, $response['api']); + $this->assertSame('wxTestAppId', $response['options']['body']['appid']); + $this->assertSame('testMerchantId', $response['options']['body']['mch_id']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame('bar', $response['options']['body']['foo']); } public function testQueryStock() @@ -70,11 +70,11 @@ public function testQueryStock() $response = $api->queryStock(['coupon_stock_id' => '1234']); - $this->assertEquals(API::API_QUERY_STOCK, $response['api']); - $this->assertEquals('wxTestAppId', $response['options']['body']['appid']); - $this->assertEquals('testMerchantId', $response['options']['body']['mch_id']); + $this->assertSame(API::API_QUERY_STOCK, $response['api']); + $this->assertSame('wxTestAppId', $response['options']['body']['appid']); + $this->assertSame('testMerchantId', $response['options']['body']['mch_id']); - $this->assertEquals('1234', $response['options']['body']['coupon_stock_id']); + $this->assertSame('1234', $response['options']['body']['coupon_stock_id']); } public function testQuery() @@ -83,10 +83,10 @@ public function testQuery() $response = $api->query(['foo' => 'bar']); - $this->assertEquals(API::API_QUERY, $response['api']); - $this->assertEquals('wxTestAppId', $response['options']['body']['appid']); - $this->assertEquals('testMerchantId', $response['options']['body']['mch_id']); + $this->assertSame(API::API_QUERY, $response['api']); + $this->assertSame('wxTestAppId', $response['options']['body']['appid']); + $this->assertSame('testMerchantId', $response['options']['body']['mch_id']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame('bar', $response['options']['body']['foo']); } } diff --git a/tests/OfficialAccount/Payment/LuckyMoneyClientTest.php b/tests/OfficialAccount/Payment/LuckyMoneyClientTest.php index 1432ab66d..c39c3d7fc 100644 --- a/tests/OfficialAccount/Payment/LuckyMoneyClientTest.php +++ b/tests/OfficialAccount/Payment/LuckyMoneyClientTest.php @@ -62,16 +62,16 @@ public function testPrepare() $response = $api->prepare(['foo' => 'bar']); - $this->assertEquals(API::API_PREPARE, $response['api']); - $this->assertEquals('wxTestAppId', $response['options']['body']['wxappid']); - $this->assertEquals('testMerchantId', $response['options']['body']['mch_id']); + $this->assertSame(API::API_PREPARE, $response['api']); + $this->assertSame('wxTestAppId', $response['options']['body']['wxappid']); + $this->assertSame('testMerchantId', $response['options']['body']['mch_id']); - $this->assertEquals('1000052601', $response['options']['body']['auth_mchid']); - $this->assertEquals('wxbf42bd79c4391863', $response['options']['body']['auth_appid']); + $this->assertSame('1000052601', $response['options']['body']['auth_mchid']); + $this->assertSame('wxbf42bd79c4391863', $response['options']['body']['auth_appid']); - $this->assertEquals('ALL_RAND', $response['options']['body']['amt_type']); + $this->assertSame('ALL_RAND', $response['options']['body']['amt_type']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame('bar', $response['options']['body']['foo']); } /** @@ -82,8 +82,8 @@ public function testQuery() $api = $this->getAPI(); $response = $api->query('testTradeNoFoo'); - $this->assertEquals(API::API_QUERY, $response['api']); - $this->assertEquals('testTradeNoFoo', $response['options']['body']['mch_billno']); + $this->assertSame(API::API_QUERY, $response['api']); + $this->assertSame('testTradeNoFoo', $response['options']['body']['mch_billno']); } /** @@ -94,16 +94,16 @@ public function testSend() $api = $this->getAPI(); $response = $api->send(['foo' => 'bar'], API::TYPE_NORMAL); - $this->assertEquals(API::API_SEND, $response['api']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame(API::API_SEND, $response['api']); + $this->assertSame('bar', $response['options']['body']['foo']); - $this->assertEquals('wxTestAppId', $response['options']['body']['wxappid']); + $this->assertSame('wxTestAppId', $response['options']['body']['wxappid']); $response = $api->send(['foo' => 'bar'], API::TYPE_GROUP); - $this->assertEquals(API::API_SEND_GROUP, $response['api']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame(API::API_SEND_GROUP, $response['api']); + $this->assertSame('bar', $response['options']['body']['foo']); - $this->assertEquals('wxTestAppId', $response['options']['body']['wxappid']); + $this->assertSame('wxTestAppId', $response['options']['body']['wxappid']); } /** @@ -114,10 +114,10 @@ public function testSendNormal() $api = $this->getAPI(); $response = $api->sendNormal(['foo' => 'bar']); - $this->assertEquals(API::API_SEND, $response['api']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame(API::API_SEND, $response['api']); + $this->assertSame('bar', $response['options']['body']['foo']); - $this->assertEquals(1, $response['options']['body']['total_num']); + $this->assertSame(1, $response['options']['body']['total_num']); } /** @@ -128,8 +128,8 @@ public function testSendGroup() $api = $this->getAPI(); $response = $api->sendGroup(['foo' => 'bar']); - $this->assertEquals(API::API_SEND_GROUP, $response['api']); - $this->assertEquals('bar', $response['options']['body']['foo']); + $this->assertSame(API::API_SEND_GROUP, $response['api']); + $this->assertSame('bar', $response['options']['body']['foo']); } /** @@ -141,6 +141,6 @@ public function testMerchantGetterAndSetter() $merchant = \Mockery::mock(Merchant::class); $api->setMerchant($merchant); - $this->assertEquals($merchant, $api->getMerchant()); + $this->assertSame($merchant, $api->getMerchant()); } } diff --git a/tests/OfficialAccount/Payment/LuckyMoneyTest.php b/tests/OfficialAccount/Payment/LuckyMoneyTest.php index 9e3d2dd30..d60d22629 100644 --- a/tests/OfficialAccount/Payment/LuckyMoneyTest.php +++ b/tests/OfficialAccount/Payment/LuckyMoneyTest.php @@ -48,14 +48,14 @@ public function testSetterAndGetter() $api = \Mockery::mock(API::class); $luckyMoney->setAPI($api); - $this->assertEquals($api, $luckyMoney->getAPI()); + $this->assertSame($api, $luckyMoney->getAPI()); $merchant = \Mockery::mock(Merchant::class); $api = \Mockery::mock(API::class); $luckyMoney->setAPI($api); $luckyMoney->setMerchant($merchant); - $this->assertEquals($merchant, $luckyMoney->getMerchant()); - $this->assertEquals($merchant, $merchant); + $this->assertSame($merchant, $luckyMoney->getMerchant()); + $this->assertSame($merchant, $merchant); } } diff --git a/tests/OfficialAccount/Payment/NotifyTest.php b/tests/OfficialAccount/Payment/NotifyTest.php index bfaa286c4..e48d77545 100644 --- a/tests/OfficialAccount/Payment/NotifyTest.php +++ b/tests/OfficialAccount/Payment/NotifyTest.php @@ -53,7 +53,7 @@ public function testGetNotify() $notify = new Notify(new Merchant(['key' => 'sign_key']), $request); $this->assertInstanceOf(Collection::class, $notify->getNotify()); - $this->assertEquals('bar', $notify->getNotify()->foo); + $this->assertSame('bar', $notify->getNotify()->foo); } /** diff --git a/tests/OfficialAccount/Payment/PaymentClientTest.php b/tests/OfficialAccount/Payment/PaymentClientTest.php index a85b036e5..6a617f362 100755 --- a/tests/OfficialAccount/Payment/PaymentClientTest.php +++ b/tests/OfficialAccount/Payment/PaymentClientTest.php @@ -78,11 +78,11 @@ public function testPrepare() $response = $api->prepare($order); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/unifiedorder', $response['api']); - $this->assertEquals('wxTestAppId', $response['params']['appid']); - $this->assertEquals('merchant_default_notify_url', $response['params']['notify_url']); - $this->assertEquals('testMerchantId', $response['params']['mch_id']); - $this->assertEquals('bar', $response['params']['foo']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/unifiedorder', $response['api']); + $this->assertSame('wxTestAppId', $response['params']['appid']); + $this->assertSame('merchant_default_notify_url', $response['params']['notify_url']); + $this->assertSame('testMerchantId', $response['params']['mch_id']); + $this->assertSame('bar', $response['params']['foo']); } /** @@ -97,10 +97,10 @@ public function testPay() $response = $api->pay($order); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/micropay', $response['api']); - $this->assertEquals('wxTestAppId', $response['params']['appid']); - $this->assertEquals('testMerchantId', $response['params']['mch_id']); - $this->assertEquals('bar', $response['params']['foo']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/micropay', $response['api']); + $this->assertSame('wxTestAppId', $response['params']['appid']); + $this->assertSame('testMerchantId', $response['params']['mch_id']); + $this->assertSame('bar', $response['params']['foo']); } /** @@ -111,17 +111,17 @@ public function testQuery() $api = $this->getAPI(); $response = $api->query('testTradeNoFoo'); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/orderquery', $response['api']); - $this->assertEquals('testTradeNoFoo', $response['params']['out_trade_no']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/orderquery', $response['api']); + $this->assertSame('testTradeNoFoo', $response['params']['out_trade_no']); $response = $api->query('testTradeNoBar', API::TRANSACTION_ID); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/orderquery', $response['api']); - $this->assertEquals('testTradeNoBar', $response['params']['transaction_id']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/orderquery', $response['api']); + $this->assertSame('testTradeNoBar', $response['params']['transaction_id']); $response = $api->queryByTransactionId('testTransactionId'); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/orderquery', $response['api']); - $this->assertEquals('testTransactionId', $response['params']['transaction_id']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/orderquery', $response['api']); + $this->assertSame('testTransactionId', $response['params']['transaction_id']); } /** @@ -132,8 +132,8 @@ public function testClose() $api = $this->getAPI(); $response = $api->close('testTradeNo'); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/closeorder', $response['api']); - $this->assertEquals('testTradeNo', $response['params']['out_trade_no']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/closeorder', $response['api']); + $this->assertSame('testTradeNo', $response['params']['out_trade_no']); } /** @@ -144,12 +144,12 @@ public function testReverse() $api = $this->getAPI(); $response = $api->reverse('testTradeNo'); - $this->assertEquals('https://api.mch.weixin.qq.com/secapi/pay/reverse', $response['api']); - $this->assertEquals('testTradeNo', $response['params']['out_trade_no']); + $this->assertSame('https://api.mch.weixin.qq.com/secapi/pay/reverse', $response['api']); + $this->assertSame('testTradeNo', $response['params']['out_trade_no']); $response = $api->reverse('testTransactionId', API::TRANSACTION_ID); - $this->assertEquals('https://api.mch.weixin.qq.com/secapi/pay/reverse', $response['api']); - $this->assertEquals('testTransactionId', $response['params']['transaction_id']); + $this->assertSame('https://api.mch.weixin.qq.com/secapi/pay/reverse', $response['api']); + $this->assertSame('testTransactionId', $response['params']['transaction_id']); } /** @@ -160,23 +160,23 @@ public function testRefund() $api = $this->getAPI(); $response = $api->refund('testTradeNo', 'testRefundNo', 100); - $this->assertEquals('https://api.mch.weixin.qq.com/secapi/pay/refund', $response['api']); - $this->assertEquals('testRefundNo', $response['params']['out_refund_no']); - $this->assertEquals(100, $response['params']['total_fee']); - $this->assertEquals(100, $response['params']['refund_fee']); - $this->assertEquals('CNY', $response['params']['refund_fee_type']); - $this->assertEquals('testMerchantId', $response['params']['op_user_id']); - $this->assertEquals('testTradeNo', $response['params']['out_trade_no']); + $this->assertSame('https://api.mch.weixin.qq.com/secapi/pay/refund', $response['api']); + $this->assertSame('testRefundNo', $response['params']['out_refund_no']); + $this->assertSame(100, $response['params']['total_fee']); + $this->assertSame(100, $response['params']['refund_fee']); + $this->assertSame('CNY', $response['params']['refund_fee_type']); + $this->assertSame('testMerchantId', $response['params']['op_user_id']); + $this->assertSame('testTradeNo', $response['params']['out_trade_no']); $response = $api->refund('testTradeNo', 'testRefundNo', 100, 50); - $this->assertEquals('testRefundNo', $response['params']['out_refund_no']); - $this->assertEquals(100, $response['params']['total_fee']); - $this->assertEquals(50, $response['params']['refund_fee']); + $this->assertSame('testRefundNo', $response['params']['out_refund_no']); + $this->assertSame(100, $response['params']['total_fee']); + $this->assertSame(50, $response['params']['refund_fee']); $response = $api->refund('testTradeNo', 'testRefundNo', 100, 50); - $this->assertEquals('testRefundNo', $response['params']['out_refund_no']); - $this->assertEquals(100, $response['params']['total_fee']); - $this->assertEquals(50, $response['params']['refund_fee']); + $this->assertSame('testRefundNo', $response['params']['out_refund_no']); + $this->assertSame(100, $response['params']['total_fee']); + $this->assertSame(50, $response['params']['refund_fee']); } /** @@ -187,12 +187,12 @@ public function testQueryRefund() $api = $this->getAPI(); $response = $api->queryRefund('testTradeNo'); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/refundquery', $response['api']); - $this->assertEquals('testTradeNo', $response['params']['out_trade_no']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/refundquery', $response['api']); + $this->assertSame('testTradeNo', $response['params']['out_trade_no']); $response = $api->queryRefund('testTransactionId', API::TRANSACTION_ID); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/refundquery', $response['api']); - $this->assertEquals('testTransactionId', $response['params']['transaction_id']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/refundquery', $response['api']); + $this->assertSame('testTransactionId', $response['params']['transaction_id']); } /** @@ -224,14 +224,14 @@ public function testDownloadBill() $api->shouldReceive('getHttp')->andReturn($http); $response = $api->downloadBill('20150901'); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/downloadbill', $response['api']); - $this->assertEquals('20150901', $response['params']['bill_date']); - $this->assertEquals(API::BILL_TYPE_ALL, $response['params']['bill_type']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/downloadbill', $response['api']); + $this->assertSame('20150901', $response['params']['bill_date']); + $this->assertSame(API::BILL_TYPE_ALL, $response['params']['bill_type']); $response = $api->downloadBill('20150901', API::BILL_TYPE_SUCCESS); - $this->assertEquals('https://api.mch.weixin.qq.com/pay/downloadbill', $response['api']); - $this->assertEquals('20150901', $response['params']['bill_date']); - $this->assertEquals(API::BILL_TYPE_SUCCESS, $response['params']['bill_type']); + $this->assertSame('https://api.mch.weixin.qq.com/pay/downloadbill', $response['api']); + $this->assertSame('20150901', $response['params']['bill_date']); + $this->assertSame(API::BILL_TYPE_SUCCESS, $response['params']['bill_type']); } /** @@ -242,14 +242,14 @@ public function testUrlShorten() $api = $this->getAPI(); $response = $api->urlShorten('http://easywechat.org'); - $this->assertEquals('https://api.mch.weixin.qq.com/tools/shorturl', $response['api']); - $this->assertEquals('http://easywechat.org', $response['params']['long_url']); + $this->assertSame('https://api.mch.weixin.qq.com/tools/shorturl', $response['api']); + $this->assertSame('http://easywechat.org', $response['params']['long_url']); $sandboxPayment = $this->getAPI(true); $response = $sandboxPayment->urlShorten('http://easywechat.org'); - $this->assertEquals('https://api.mch.weixin.qq.com/tools/shorturl', $response['api']); - $this->assertEquals('http://easywechat.org', $response['params']['long_url']); + $this->assertSame('https://api.mch.weixin.qq.com/tools/shorturl', $response['api']); + $this->assertSame('http://easywechat.org', $response['params']['long_url']); } /** @@ -261,14 +261,14 @@ public function testAuthCodeToOpenId() $response = $api->authCodeToOpenId('authcode'); - $this->assertEquals('https://api.mch.weixin.qq.com/tools/authcodetoopenid', $response['api']); - $this->assertEquals('authcode', $response['params']['auth_code']); + $this->assertSame('https://api.mch.weixin.qq.com/tools/authcodetoopenid', $response['api']); + $this->assertSame('authcode', $response['params']['auth_code']); $sandboxPayment = $this->getAPI(true); $response = $sandboxPayment->authCodeToOpenId('authcode'); - $this->assertEquals('https://api.mch.weixin.qq.com/tools/authcodetoopenid', $response['api']); - $this->assertEquals('authcode', $response['params']['auth_code']); + $this->assertSame('https://api.mch.weixin.qq.com/tools/authcodetoopenid', $response['api']); + $this->assertSame('authcode', $response['params']['auth_code']); } /** @@ -280,6 +280,6 @@ public function testMerchantGetterAndSetter() $merchant = \Mockery::mock(Merchant::class); $api->setMerchant($merchant); - $this->assertEquals($merchant, $api->getMerchant()); + $this->assertSame($merchant, $api->getMerchant()); } } diff --git a/tests/OfficialAccount/Payment/PaymentTest.php b/tests/OfficialAccount/Payment/PaymentTest.php index a4de2b6b3..9b3103599 100755 --- a/tests/OfficialAccount/Payment/PaymentTest.php +++ b/tests/OfficialAccount/Payment/PaymentTest.php @@ -97,7 +97,7 @@ public function testHandleNotify() }); $this->assertInstanceOf(Response::class, $response); - $this->assertEquals(XML::build([ + $this->assertSame(XML::build([ 'return_code' => 'SUCCESS', 'return_msg' => 'OK', ]), $response->getContent()); @@ -106,7 +106,7 @@ public function testHandleNotify() return 'error_message'; }); - $this->assertEquals(XML::build([ + $this->assertSame(XML::build([ 'return_code' => 'FAIL', 'return_msg' => 'error_message', ]), $response->getContent()); @@ -115,7 +115,7 @@ public function testHandleNotify() return false; }); - $this->assertEquals(XML::build([ + $this->assertSame(XML::build([ 'return_code' => 'FAIL', 'return_msg' => '', ]), $response->getContent()); @@ -144,7 +144,7 @@ public function testHandleScanNotify() throw new \Exception('Operation failed', 1048); }); - $this->assertEquals(XML::build([ + $this->assertSame(XML::build([ 'return_code' => 'SUCCESS', 'return_msg' => 1048, 'result_code' => 'FAIL', @@ -162,9 +162,9 @@ public function testConfigForPayment() $json = $payment->configForPayment('prepayId'); $array = json_decode($json, true); - $this->assertEquals('wxTestAppId', $array['appId']); - $this->assertEquals('prepay_id=prepayId', $array['package']); - $this->assertEquals('MD5', $array['signType']); + $this->assertSame('wxTestAppId', $array['appId']); + $this->assertSame('prepay_id=prepayId', $array['package']); + $this->assertSame('MD5', $array['signType']); $this->assertArrayHasKey('timeStamp', $array); $this->assertArrayHasKey('nonceStr', $array); $this->assertArrayHasKey('paySign', $array); @@ -179,9 +179,9 @@ public function testConfigForJSSDKPayment() $config = $payment->configForJSSDKPayment('prepayId'); - $this->assertEquals('wxTestAppId', $config['appId']); - $this->assertEquals('prepay_id=prepayId', $config['package']); - $this->assertEquals('MD5', $config['signType']); + $this->assertSame('wxTestAppId', $config['appId']); + $this->assertSame('prepay_id=prepayId', $config['package']); + $this->assertSame('MD5', $config['signType']); $this->assertArrayHasKey('timestamp', $config); $this->assertArrayHasKey('nonceStr', $config); $this->assertArrayHasKey('paySign', $config); @@ -196,9 +196,9 @@ public function testConfigForAppPayment() $array = $payment->configForAppPayment('prepayId'); - $this->assertEquals('wxTestAppId', $array['appid']); - $this->assertEquals('prepayId', $array['prepayid']); - $this->assertEquals('Sign=WXPay', $array['package']); + $this->assertSame('wxTestAppId', $array['appid']); + $this->assertSame('prepayId', $array['prepayid']); + $this->assertSame('Sign=WXPay', $array['package']); $this->assertArrayHasKey('timestamp', $array); $this->assertArrayHasKey('noncestr', $array); $this->assertArrayHasKey('sign', $array); @@ -214,9 +214,9 @@ public function testConfigForShareAddress() $json = $payment->configForShareAddress('accessToken'); $array = json_decode($json, true); - $this->assertEquals('wxTestAppId', $array['appId']); - $this->assertEquals('jsapi_address', $array['scope']); - $this->assertEquals('SHA1', $array['signType']); + $this->assertSame('wxTestAppId', $array['appId']); + $this->assertSame('jsapi_address', $array['scope']); + $this->assertSame('SHA1', $array['signType']); $this->assertArrayHasKey('timeStamp', $array); $this->assertArrayHasKey('nonceStr', $array); $this->assertArrayHasKey('addrSign', $array); @@ -257,14 +257,14 @@ public function testSetterAndGetter() $api = \Mockery::mock(API::class); $payment->setAPI($api); - $this->assertEquals($api, $payment->getAPI()); + $this->assertSame($api, $payment->getAPI()); $merchant = \Mockery::mock(Merchant::class); $api = \Mockery::mock(API::class); $payment->setAPI($api); $payment->setMerchant($merchant); - $this->assertEquals($merchant, $payment->getMerchant()); - $this->assertEquals($merchant, $merchant); + $this->assertSame($merchant, $payment->getMerchant()); + $this->assertSame($merchant, $merchant); } } diff --git a/tests/OfficialAccount/QRCode/ClientTest.php b/tests/OfficialAccount/QRCode/ClientTest.php index 05df89665..89e9555c7 100755 --- a/tests/OfficialAccount/QRCode/ClientTest.php +++ b/tests/OfficialAccount/QRCode/ClientTest.php @@ -40,18 +40,18 @@ public function testForever() // normal $params = $qrcode->forever(5)['params']; - $this->assertEquals(QRCode::SCENE_QR_FOREVER, $params['action_name']); - $this->assertEquals(['scene_id' => 5], $params['action_info']['scene']); + $this->assertSame(QRCode::SCENE_QR_FOREVER, $params['action_name']); + $this->assertSame(['scene_id' => 5], $params['action_info']['scene']); // <= 0 $params = $qrcode->forever(0)['params']; - $this->assertEquals(QRCode::SCENE_QR_FOREVER_STR, $params['action_name']); - $this->assertEquals(['scene_str' => 0], $params['action_info']['scene']); + $this->assertSame(QRCode::SCENE_QR_FOREVER_STR, $params['action_name']); + $this->assertSame(['scene_str' => 0], $params['action_info']['scene']); // > QRCode::SCENE_MAX_VALUE $params = $qrcode->forever(QRCode::SCENE_MAX_VALUE)['params']; - $this->assertEquals(QRCode::SCENE_QR_FOREVER_STR, $params['action_name']); - $this->assertEquals(['scene_str' => QRCode::SCENE_MAX_VALUE], $params['action_info']['scene']); + $this->assertSame(QRCode::SCENE_QR_FOREVER_STR, $params['action_name']); + $this->assertSame(['scene_str' => QRCode::SCENE_MAX_VALUE], $params['action_info']['scene']); } /** @@ -63,21 +63,21 @@ public function testTemporary() // empty expire_seconds $params = $qrcode->temporary(5)['params']; - $this->assertEquals(QRCode::DAY * 7, $params['expire_seconds']); + $this->assertSame(QRCode::DAY * 7, $params['expire_seconds']); // expire_seconds = 2400 $params = $qrcode->temporary(5, 2400)['params']; - $this->assertEquals(2400, $params['expire_seconds']); + $this->assertSame(2400, $params['expire_seconds']); // $senceId = 'str' $params = $qrcode->temporary('str')['params']; - $this->assertEquals(QRCode::SCENE_QR_TEMPORARY, $params['action_name']); - $this->assertEquals(['scene_id' => 0], $params['action_info']['scene']); + $this->assertSame(QRCode::SCENE_QR_TEMPORARY, $params['action_name']); + $this->assertSame(['scene_id' => 0], $params['action_info']['scene']); // $senceId = 1 $params = $qrcode->temporary(1)['params']; - $this->assertEquals(QRCode::SCENE_QR_TEMPORARY, $params['action_name']); - $this->assertEquals(['scene_id' => 1], $params['action_info']['scene']); + $this->assertSame(QRCode::SCENE_QR_TEMPORARY, $params['action_name']); + $this->assertSame(['scene_id' => 1], $params['action_info']['scene']); } /** @@ -89,8 +89,8 @@ public function testCard() // $card = ['foo' => 'bar'] $params = $qrcode->card(['foo' => 'bar'])['params']; - $this->assertEquals(QRCode::SCENE_QR_CARD, $params['action_name']); - $this->assertEquals(['card' => ['foo' => 'bar']], $params['action_info']['scene']); + $this->assertSame(QRCode::SCENE_QR_CARD, $params['action_name']); + $this->assertSame(['card' => ['foo' => 'bar']], $params['action_info']['scene']); } /** @@ -102,6 +102,6 @@ public function testUrl() $ticket = 'foo'; - $this->assertEquals(QRCode::API_SHOW."?ticket={$ticket}", $qrcode->url($ticket)); + $this->assertSame(QRCode::API_SHOW."?ticket={$ticket}", $qrcode->url($ticket)); } } diff --git a/tests/OfficialAccount/Semantic/ClientTest.php b/tests/OfficialAccount/Semantic/ClientTest.php index fb67f96e9..8fdd17406 100755 --- a/tests/OfficialAccount/Semantic/ClientTest.php +++ b/tests/OfficialAccount/Semantic/ClientTest.php @@ -39,8 +39,8 @@ public function testQuery() ]; $this->assertStringStartsWith(Semantic::API_SEARCH, $semantic->query('foo', 'bar')['api']); - $this->assertEquals($expect, $semantic->query('foo', 'bar')['params']); - $this->assertEquals($expect, $semantic->query('foo', ['bar'])['params']); + $this->assertSame($expect, $semantic->query('foo', 'bar')['params']); + $this->assertSame($expect, $semantic->query('foo', ['bar'])['params']); $expect = [ 'query' => 'foo', @@ -48,7 +48,7 @@ public function testQuery() 'appid' => 'overtrue', ]; - $this->assertEquals($expect, $semantic->query('foo', ['bar', 'baz'])['params']); + $this->assertSame($expect, $semantic->query('foo', ['bar', 'baz'])['params']); $expect = [ 'query' => 'foo', @@ -57,6 +57,6 @@ public function testQuery() 'foo' => 'bar', ]; - $this->assertEquals($expect, $semantic->query('foo', ['bar', 'baz'], ['foo' => 'bar'])['params']); + $this->assertSame($expect, $semantic->query('foo', ['bar', 'baz'], ['foo' => 'bar'])['params']); } } diff --git a/tests/OfficialAccount/Server/ServerGuardTest.php b/tests/OfficialAccount/Server/ServerGuardTest.php index 3932758cb..ec41950a9 100755 --- a/tests/OfficialAccount/Server/ServerGuardTest.php +++ b/tests/OfficialAccount/Server/ServerGuardTest.php @@ -57,11 +57,11 @@ public function testServe() 'echostr' => 'foobar', ]); - $this->assertEquals('foobar', $server->serve()->getContent()); + $this->assertSame('foobar', $server->serve()->getContent()); $server = $this->getServer(); - $this->assertEquals(Guard::SUCCESS_EMPTY_RESPONSE, $server->serve()->getContent()); + $this->assertSame(Guard::SUCCESS_EMPTY_RESPONSE, $server->serve()->getContent()); } /** @@ -108,7 +108,7 @@ public function testResponseWithEncryptedRequest() $response = $server->serve()->getContent(); - $this->assertEquals(base64_encode($raw), $response); + $this->assertSame(base64_encode($raw), $response); } /** @@ -125,7 +125,7 @@ public function testResponseWithEvent() ]); $logEvent = null; $response = $server->serve(); - $this->assertEquals(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); + $this->assertSame(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); //with listener $server->setMessageHandler(function ($event) use (&$logEvent) { @@ -136,7 +136,7 @@ public function testResponseWithEvent() $response = $server->serve(); - $this->assertEquals('subscribe', $logEvent->get('Event')); + $this->assertSame('subscribe', $logEvent->get('Event')); $this->assertContains('subscribe', $response->getContent()); } @@ -153,11 +153,11 @@ public function testSetMessageHandler() }; $server->setMessageHandler($closure); - $this->assertEquals($closure, $server->getMessageHandler()); + $this->assertSame($closure, $server->getMessageHandler()); $server->setMessageHandler('Foo::bar'); - $this->assertEquals('Foo::bar', $server->getMessageHandler()); + $this->assertSame('Foo::bar', $server->getMessageHandler()); $server->setMessageHandler('foo'); // invalid } @@ -200,7 +200,7 @@ public function testResponseWithDifferentMsgType() ]); $logger = null; $response = $server->serve(); - $this->assertEquals(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); + $this->assertSame(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); //with all $server->setMessageHandler(function ($message) use (&$logger) { @@ -211,7 +211,7 @@ public function testResponseWithDifferentMsgType() $response = $server->serve(); - $this->assertEquals('hello', $logger->get('Content')); + $this->assertSame('hello', $logger->get('Content')); $this->assertContains('hello', $response->getContent()); //with image @@ -222,7 +222,7 @@ public function testResponseWithDifferentMsgType() }, Guard::ALL_MSG); $response = $server->serve(); - $this->assertEquals('hello', $logger->get('Content')); + $this->assertSame('hello', $logger->get('Content')); $this->assertContains('hello', $response->getContent()); //with text @@ -233,7 +233,7 @@ public function testResponseWithDifferentMsgType() }, Guard::TEXT_MSG); $response = $server->serve(); - $this->assertEquals('hello', $logger->get('Content')); + $this->assertSame('hello', $logger->get('Content')); $this->assertContains('hello', $response->getContent()); //with image @@ -244,7 +244,7 @@ public function testResponseWithDifferentMsgType() }, Guard::IMAGE_MSG); $response = $server->serve(); - $this->assertEquals(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); + $this->assertSame(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); // except image $server->setMessageHandler(function ($message) use (&$logger) { @@ -254,7 +254,7 @@ public function testResponseWithDifferentMsgType() }, Guard::ALL_MSG & ~Guard::TEXT_MSG); $response = $server->serve(); - $this->assertEquals(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); + $this->assertSame(Guard::SUCCESS_EMPTY_RESPONSE, $response->getContent()); } } diff --git a/tests/OfficialAccount/Server/ServerTransformerTest.php b/tests/OfficialAccount/Server/ServerTransformerTest.php index a58c57c05..c4b417357 100755 --- a/tests/OfficialAccount/Server/ServerTransformerTest.php +++ b/tests/OfficialAccount/Server/ServerTransformerTest.php @@ -31,9 +31,9 @@ public function testTransformText() $message = new Text(['content' => 'foo']); - $this->assertEquals(['Content' => 'foo'], $transformer->transform($message)); + $this->assertSame(['Content' => 'foo'], $transformer->transform($message)); - $this->assertEquals(['Content' => 'Text message.'], $transformer->transform('Text message.')); + $this->assertSame(['Content' => 'Text message.'], $transformer->transform('Text message.')); } /** @@ -45,7 +45,7 @@ public function testTransformImage() $message = new Image(['media_id' => 'bar']); - $this->assertEquals('bar', $transformer->transform($message)['Image']['MediaId']); + $this->assertSame('bar', $transformer->transform($message)['Image']['MediaId']); } /** @@ -59,7 +59,7 @@ public function testTransformVideo() $result = $transformer->transform($message); - $this->assertEquals('overtrue', $result['Video']['Title']); + $this->assertSame('overtrue', $result['Video']['Title']); $this->assertArrayHasKey('Description', $result['Video']); $this->assertArrayHasKey('MediaId', $result['Video']); $this->assertArrayNotHasKey('ThumbMediaId', $result['Video']); @@ -74,7 +74,7 @@ public function testTransformVoice() $message = new Voice(['media_id' => 'bar']); - $this->assertEquals('bar', $transformer->transform($message)['Voice']['MediaId']); + $this->assertSame('bar', $transformer->transform($message)['Voice']['MediaId']); } /** @@ -86,7 +86,7 @@ public function testTransformTransfer() $message = new Transfer(['account' => 'foo@bar.com']); - $this->assertEquals('foo@bar.com', $transformer->transform($message)['TransInfo']['KfAccount']); + $this->assertSame('foo@bar.com', $transformer->transform($message)['TransInfo']['KfAccount']); } /** @@ -102,9 +102,9 @@ public function testTransformNews() 'description' => 'foobar', ])); - $this->assertEquals(1, $result['ArticleCount']); - $this->assertEquals(1, count($result['Articles'])); - $this->assertEquals('foobar', $result['Articles'][0]['Description']); + $this->assertSame(1, $result['ArticleCount']); + $this->assertSame(1, count($result['Articles'])); + $this->assertSame('foobar', $result['Articles'][0]['Description']); $this->assertArrayHasKey('Url', $result['Articles'][0]); $this->assertArrayNotHasKey('Author', $result['Articles'][0]); @@ -122,10 +122,10 @@ public function testTransformNews() $result = $transformer->transform($articles); - $this->assertEquals(2, $result['ArticleCount']); - $this->assertEquals(2, count($result['Articles'])); - $this->assertEquals('foobar', $result['Articles'][0]['Description']); - $this->assertEquals('bar', $result['Articles'][1]['Description']); + $this->assertSame(2, $result['ArticleCount']); + $this->assertSame(2, count($result['Articles'])); + $this->assertSame('foobar', $result['Articles'][0]['Description']); + $this->assertSame('bar', $result['Articles'][1]['Description']); $this->assertArrayHasKey('Url', $result['Articles'][0]); $this->assertArrayNotHasKey('Author', $result['Articles'][0]); } diff --git a/tests/OfficialAccount/ShakeAround/DeviceTest.php b/tests/OfficialAccount/ShakeAround/DeviceTest.php index a78ab8f78..f2866ed93 100644 --- a/tests/OfficialAccount/ShakeAround/DeviceTest.php +++ b/tests/OfficialAccount/ShakeAround/DeviceTest.php @@ -54,7 +54,7 @@ public function testApply() $result = $device->apply(3, 'test'); $this->assertStringStartsWith(Device::API_DEVICE_APPLYID, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'quantity' => 3, @@ -64,7 +64,7 @@ public function testApply() $result = $device->apply(3, 'test', 'allen05ren'); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'quantity' => 3, @@ -75,7 +75,7 @@ public function testApply() $result = $device->apply(3, 'test', 'allen05ren', 1234); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -92,7 +92,7 @@ public function testGetStatus() $result = $device->getStatus(12345678); $this->assertStringStartsWith(Device::API_DEVICE_APPLYSTATUS, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -120,7 +120,7 @@ public function testUpdate() ], 'allen05ren'); $this->assertStringStartsWith(Device::API_DEVICE_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -150,7 +150,7 @@ public function testBindLocation() ], 1234); $this->assertStringStartsWith(Device::API_DEVICE_BINDLOCATION, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'device_identifier' => [ @@ -171,7 +171,7 @@ public function testBindLocation() 'minor' => 10002, ], 1234, 2, 'wxappid'); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $result = $device->bindLocation([ 'device_id' => 10100, @@ -206,7 +206,7 @@ public function testFetchByIds() ]); $this->assertStringStartsWith(Device::API_DEVICE_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -225,7 +225,7 @@ public function testPagination() $result = $device->pagination(0, 10); $this->assertStringStartsWith(Device::API_DEVICE_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -245,6 +245,6 @@ public function testFetchByApplyId() $result = $device->fetchByApplyId(12345678, 0, 10); $this->assertStringStartsWith(Device::API_DEVICE_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OfficialAccount/ShakeAround/GroupTest.php b/tests/OfficialAccount/ShakeAround/GroupTest.php index 5addb6f6c..9d25ce878 100644 --- a/tests/OfficialAccount/ShakeAround/GroupTest.php +++ b/tests/OfficialAccount/ShakeAround/GroupTest.php @@ -53,7 +53,7 @@ public function testAdd() $result = $group->add('overtrue'); $this->assertStringStartsWith(Group::API_ADD, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -71,7 +71,7 @@ public function testUpdate() $result = $group->update(12345678, 'allen05ren'); $this->assertStringStartsWith(Group::API_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -88,7 +88,7 @@ public function testDelete() $result = $group->delete(12345678); $this->assertStringStartsWith(Group::API_DELETE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -106,7 +106,7 @@ public function testLists() $result = $group->lists(0, 10); $this->assertStringStartsWith(Group::API_GET_LIST, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -125,7 +125,7 @@ public function testGetDetails() $result = $group->getDetails(12345678, 0, 10); $this->assertStringStartsWith(Group::API_GET_DETAIL, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -153,7 +153,7 @@ public function testAddDevice() ]); $this->assertStringStartsWith(Group::API_ADD_DEVICE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -181,6 +181,6 @@ public function testRemoveDevice() ]); $this->assertStringStartsWith(Group::API_DELETE_DEVICE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OfficialAccount/ShakeAround/MaterialTest.php b/tests/OfficialAccount/ShakeAround/MaterialTest.php index a5ae94df8..dadfbe83b 100644 --- a/tests/OfficialAccount/ShakeAround/MaterialTest.php +++ b/tests/OfficialAccount/ShakeAround/MaterialTest.php @@ -46,11 +46,11 @@ public function testUploadImage() $this->assertStringStartsWith(Material::API_MATERIAL_ADD, $result['api']); $this->assertContains('stubs/image.jpg', $result['media']); - $this->assertEquals('icon', $result['type']); + $this->assertSame('icon', $result['type']); $result = $material->uploadImage(__DIR__.'/stubs/image.jpg', 'license'); - $this->assertEquals('license', $result['type']); + $this->assertSame('license', $result['type']); $material->uploadImage(__DIR__.'/stubs/foo.jpg'); } diff --git a/tests/OfficialAccount/ShakeAround/PageTest.php b/tests/OfficialAccount/ShakeAround/PageTest.php index 8ef1639e0..994fe06d2 100644 --- a/tests/OfficialAccount/ShakeAround/PageTest.php +++ b/tests/OfficialAccount/ShakeAround/PageTest.php @@ -56,7 +56,7 @@ public function testAdd() $result = $page->add('主标题', '副标题', 'https://zb.weixin.qq.com', 'http://3gimg.qq.com/shake_nearby/dy/icon'); $this->assertStringStartsWith(Page::API_ADD, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'title' => '主标题', @@ -68,7 +68,7 @@ public function testAdd() $result = $page->add('主标题', '副标题', 'https://zb.weixin.qq.com', 'http://3gimg.qq.com/shake_nearby/dy/icon', '数据示例'); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -89,7 +89,7 @@ public function testUpdate() $result = $page->update(1234, '主标题', '副标题', 'https://zb.weixin.qq.com', 'http://3gimg.qq.com/shake_nearby/dy/icon'); $this->assertStringStartsWith(Page::API_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'page_id' => 1234, @@ -103,7 +103,7 @@ public function testUpdate() $result = $page->update(1234, '主标题', '副标题', 'https://zb.weixin.qq.com', 'http://3gimg.qq.com/shake_nearby/dy/icon', '数据示例'); $this->assertStringStartsWith(Page::API_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -121,7 +121,7 @@ public function testFetchByIds() $result = $page->fetchByIds([1234, 5678]); $this->assertStringStartsWith(Page::API_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -140,7 +140,7 @@ public function testPagination() $result = $page->pagination(0, 10); $this->assertStringStartsWith(Page::API_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -157,6 +157,6 @@ public function testDelete() $result = $page->delete(1234); $this->assertStringStartsWith(Page::API_DELETE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OfficialAccount/ShakeAround/RelationTest.php b/tests/OfficialAccount/ShakeAround/RelationTest.php index acea4d4c6..a33ed06e1 100644 --- a/tests/OfficialAccount/ShakeAround/RelationTest.php +++ b/tests/OfficialAccount/ShakeAround/RelationTest.php @@ -65,7 +65,7 @@ public function testBindPage() ], [12345, 23456, 334567]); $this->assertStringStartsWith(Relation::API_DEVICE_BINDPAGE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -93,7 +93,7 @@ public function testGetPageByDeviceId() ], true); $this->assertStringStartsWith(Relation::API_RELATION_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $relation = \Mockery::mock('EasyWeChat\Applications\OfficialAccount\ShakeAround\Relation[parseJSON]', [\Mockery::mock('EasyWeChat\Applications\OfficialAccount\Core\AccessToken')]); $relation->shouldReceive('parseJSON')->andReturnUsing(function ($method, $params) { @@ -114,7 +114,7 @@ public function testGetPageByDeviceId() 'major' => 10001, 'minor' => 10002, ]); - $this->assertEquals($expected, $result); + $this->assertSame($expected, $result); $relation = \Mockery::mock('EasyWeChat\Applications\OfficialAccount\ShakeAround\Relation[parseJSON]', [\Mockery::mock('EasyWeChat\Applications\OfficialAccount\Core\AccessToken')]); $relation->shouldReceive('parseJSON')->andReturnUsing(function ($method, $params) { @@ -152,7 +152,7 @@ public function testGetPageByDeviceId() 'minor' => 10002, ]); - $this->assertEquals($expected, $result); + $this->assertSame($expected, $result); } /** @@ -172,6 +172,6 @@ public function testGetDeviceByPageId() $result = $relation->getDeviceByPageId(1234, 0, 10); $this->assertStringStartsWith(Relation::API_RELATION_SEARCH, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OfficialAccount/ShakeAround/ShakeAroundTest.php b/tests/OfficialAccount/ShakeAround/ShakeAroundTest.php index df9d2678a..8cd09f2d0 100644 --- a/tests/OfficialAccount/ShakeAround/ShakeAroundTest.php +++ b/tests/OfficialAccount/ShakeAround/ShakeAroundTest.php @@ -62,7 +62,7 @@ public function testRegister() ]; $result = $shake_around->register('allen05ren', 13888888888, 'allen05ren@outlook.com', '0101', [], 'test'); $this->assertStringStartsWith(ShakeAround::API_ACCOUNT_REGISTER, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'name' => 'allen05ren', @@ -73,7 +73,7 @@ public function testRegister() ]; $result = $shake_around->register('allen05ren', 13888888888, 'allen05ren@outlook.com', '0101', []); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -96,7 +96,7 @@ public function testGetShakeInfo() $result = $shake_around->getShakeInfo('6ab3d8465166598a5f4e8c1b44f44645'); $this->assertStringStartsWith(ShakeAround::API_GET_SHAKE_INFO, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); $expected = [ 'ticket' => '6ab3d8465166598a5f4e8c1b44f44645', @@ -105,7 +105,7 @@ public function testGetShakeInfo() $result = $shake_around->getShakeInfo('6ab3d8465166598a5f4e8c1b44f44645', 1); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** diff --git a/tests/OfficialAccount/ShakeAround/StatsTest.php b/tests/OfficialAccount/ShakeAround/StatsTest.php index ad3cd1c04..f56de36ca 100644 --- a/tests/OfficialAccount/ShakeAround/StatsTest.php +++ b/tests/OfficialAccount/ShakeAround/StatsTest.php @@ -64,7 +64,7 @@ public function testDeviceSummary() ], 1438704000, 1438704000); $this->assertStringStartsWith(Stats::API_DEVICE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -82,7 +82,7 @@ public function testBatchDeviceSummary() $result = $stats->batchDeviceSummary(1438704000, 1); $this->assertStringStartsWith(Stats::API_DEVICE_LIST, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -101,7 +101,7 @@ public function testPageSummary() $result = $stats->pageSummary(1234, 1438704000, 1438704000); $this->assertStringStartsWith(Stats::API_PAGE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -119,6 +119,6 @@ public function testBatchPageSummary() $result = $stats->batchPageSummary(1425139200, 1); $this->assertStringStartsWith(Stats::API_PAGE_LIST, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OfficialAccount/Stats/ClientTest.php b/tests/OfficialAccount/Stats/ClientTest.php index afaf7044c..6d1b728e5 100755 --- a/tests/OfficialAccount/Stats/ClientTest.php +++ b/tests/OfficialAccount/Stats/ClientTest.php @@ -37,8 +37,8 @@ public function testuserSummary() $stats = $this->getStats(); $result = $stats->userSummary(1, 2); - $this->assertEquals(Stats::API_USER_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_USER_SUMMARY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -49,8 +49,8 @@ public function testuserCumulate() $stats = $this->getStats(); $result = $stats->userCumulate(1, 2); - $this->assertEquals(Stats::API_USER_CUMULATE, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_USER_CUMULATE, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -61,8 +61,8 @@ public function testarticleSummary() $stats = $this->getStats(); $result = $stats->articleSummary(1, 2); - $this->assertEquals(Stats::API_ARTICLE_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_ARTICLE_SUMMARY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -73,8 +73,8 @@ public function testarticleTotal() $stats = $this->getStats(); $result = $stats->articleTotal(1, 2); - $this->assertEquals(Stats::API_ARTICLE_TOTAL, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_ARTICLE_TOTAL, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -85,8 +85,8 @@ public function testuserReadSummary() $stats = $this->getStats(); $result = $stats->userReadSummary(1, 2); - $this->assertEquals(Stats::API_USER_READ_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_USER_READ_SUMMARY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -97,8 +97,8 @@ public function testuserReadHourly() $stats = $this->getStats(); $result = $stats->userReadHourly(1, 2); - $this->assertEquals(Stats::API_USER_READ_HOURLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_USER_READ_HOURLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -109,8 +109,8 @@ public function testuserShareSummary() $stats = $this->getStats(); $result = $stats->userShareSummary(1, 2); - $this->assertEquals(Stats::API_USER_SHARE_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_USER_SHARE_SUMMARY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -121,8 +121,8 @@ public function testuserShareHourly() $stats = $this->getStats(); $result = $stats->userShareHourly(1, 2); - $this->assertEquals(Stats::API_USER_SHARE_HOURLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_USER_SHARE_HOURLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -133,8 +133,8 @@ public function testupstreamMessageSummary() $stats = $this->getStats(); $result = $stats->upstreamMessageSummary(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_SUMMARY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -145,8 +145,8 @@ public function testupstreamMessageHourly() $stats = $this->getStats(); $result = $stats->upstreamMessageHourly(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_HOURLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_HOURLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -157,8 +157,8 @@ public function testupstreamMessageWeekly() $stats = $this->getStats(); $result = $stats->upstreamMessageWeekly(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_WEEKLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_WEEKLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -169,8 +169,8 @@ public function testupstreamMessageMonthly() $stats = $this->getStats(); $result = $stats->upstreamMessageMonthly(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_MONTHLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_MONTHLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -181,8 +181,8 @@ public function testupstreamMessageDistSummary() $stats = $this->getStats(); $result = $stats->upstreamMessageDistSummary(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_DIST_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_DIST_SUMMARY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -193,8 +193,8 @@ public function testupstreamMessageDistWeekly() $stats = $this->getStats(); $result = $stats->upstreamMessageDistWeekly(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_DIST_WEEKLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_DIST_WEEKLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -205,8 +205,8 @@ public function testupstreamMessageDistMonthly() $stats = $this->getStats(); $result = $stats->upstreamMessageDistMonthly(1, 2); - $this->assertEquals(Stats::API_UPSTREAM_MSG_DIST_MONTHLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(Stats::API_UPSTREAM_MSG_DIST_MONTHLY, $result['api']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -217,9 +217,9 @@ public function testinterfaceSummary() $stats = $this->getStats(); $result = $stats->interfaceSummary(1, 2); - $this->assertEquals(Stats::API_INTERFACE_SUMMARY, $result['api']); + $this->assertSame(Stats::API_INTERFACE_SUMMARY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } /** @@ -230,9 +230,9 @@ public function testinterfaceSummaryHourly() $stats = $this->getStats(); $result = $stats->interfaceSummaryHourly(1, 2); - $this->assertEquals(Stats::API_INTERFACE_SUMMARY_HOURLY, $result['api']); + $this->assertSame(Stats::API_INTERFACE_SUMMARY_HOURLY, $result['api']); - $this->assertEquals(['begin_date' => 1, 'end_date' => 2], $result['params']); + $this->assertSame(['begin_date' => 1, 'end_date' => 2], $result['params']); } //拉取卡券概况数据接口. @@ -246,9 +246,9 @@ public function testCardSummary() $result = $stats->cardSummary($beginDate, $endDate, $condSource); $this->assertStringStartsWith(Stats::API_CARD_SUMMARY, $result['api']); - $this->assertEquals($beginDate, $result['params']['begin_date']); - $this->assertEquals($endDate, $result['params']['end_date']); - $this->assertEquals($condSource, $result['params']['cond_source']); + $this->assertSame($beginDate, $result['params']['begin_date']); + $this->assertSame($endDate, $result['params']['end_date']); + $this->assertSame($condSource, $result['params']['cond_source']); } //获取免费券数据接口. @@ -263,10 +263,10 @@ public function testFreeCardSummary() $result = $stats->freeCardSummary($beginDate, $endDate, $condSource, $cardId); $this->assertStringStartsWith(Stats::API_FREE_CARD_SUMMARY, $result['api']); - $this->assertEquals($beginDate, $result['params']['begin_date']); - $this->assertEquals($endDate, $result['params']['end_date']); - $this->assertEquals($condSource, $result['params']['cond_source']); - $this->assertEquals($cardId, $result['params']['card_id']); + $this->assertSame($beginDate, $result['params']['begin_date']); + $this->assertSame($endDate, $result['params']['end_date']); + $this->assertSame($condSource, $result['params']['cond_source']); + $this->assertSame($cardId, $result['params']['card_id']); } //拉取会员卡数据接口. @@ -280,8 +280,8 @@ public function testMemberCardSummary() $result = $stats->memberCardSummary($beginDate, $endDate, $condSource); $this->assertStringStartsWith(Stats::API_MEMBER_CARD_SUMMARY, $result['api']); - $this->assertEquals($beginDate, $result['params']['begin_date']); - $this->assertEquals($endDate, $result['params']['end_date']); - $this->assertEquals($condSource, $result['params']['cond_source']); + $this->assertSame($beginDate, $result['params']['begin_date']); + $this->assertSame($endDate, $result['params']['end_date']); + $this->assertSame($condSource, $result['params']['cond_source']); } } diff --git a/tests/OfficialAccount/TemplateMessage/ClientTest.php b/tests/OfficialAccount/TemplateMessage/ClientTest.php index 35818617d..eda8ff75e 100755 --- a/tests/OfficialAccount/TemplateMessage/ClientTest.php +++ b/tests/OfficialAccount/TemplateMessage/ClientTest.php @@ -35,9 +35,9 @@ public function getNotice($mockHttp = false) $notice->shouldReceive('parseJSON')->andReturnUsing(function ($api, $params) { if (isset($params[1])) { return ['api' => $params[0], 'params' => $params[1]]; - } else { - return ['api' => $params[0]]; } + + return ['api' => $params[0]]; }); return $notice; @@ -53,8 +53,8 @@ public function testSetIndustry() $response = $notice->setIndustry('foo', 'bar'); $this->assertStringStartsWith(TemplateMessage::API_SET_INDUSTRY, $response['api']); - $this->assertEquals('foo', $response['params']['industry_id1']); - $this->assertEquals('bar', $response['params']['industry_id2']); + $this->assertSame('foo', $response['params']['industry_id1']); + $this->assertSame('bar', $response['params']['industry_id2']); } /** @@ -79,7 +79,7 @@ public function testAddTemplate() $response = $notice->addTemplate('foo'); $this->assertStringStartsWith(TemplateMessage::API_ADD_TEMPLATE, $response['api']); - $this->assertEquals('foo', $response['params']['template_id_short']); + $this->assertSame('foo', $response['params']['template_id_short']); } /** @@ -104,7 +104,7 @@ public function testDeletePrivateTemplate() $response = $notice->deletePrivateTemplate('foo'); $this->assertStringStartsWith(TemplateMessage::API_DEL_PRIVATE_TEMPLATE, $response['api']); - $this->assertEquals('foo', $response['params']['template_id']); + $this->assertSame('foo', $response['params']['template_id']); } /** @@ -124,23 +124,23 @@ public function testSend() $response = $notice->send(['touser' => 'foo', 'template_id' => 'bar']); $this->assertStringStartsWith(TemplateMessage::API_SEND_TEMPLATE_MESSAGE, $response['api']); - $this->assertEquals('foo', $response['params']['touser']); - $this->assertEquals('bar', $response['params']['template_id']); + $this->assertSame('foo', $response['params']['touser']); + $this->assertSame('bar', $response['params']['template_id']); // $this->assertEquals('#FF0000', $response['params']['topcolor']); // 貌似这个删除了 https://github.com/overtrue/wechat/pull/595 - $this->assertEquals([], $response['params']['data']); + $this->assertSame([], $response['params']['data']); $response = $notice->withTo('anzhengchao1')->withTemplateId('test_tpl_id')->withUrl('url')->withColor('color')->send(); - $this->assertEquals('anzhengchao1', $response['params']['touser']); - $this->assertEquals('test_tpl_id', $response['params']['template_id']); - $this->assertEquals('url', $response['params']['url']); + $this->assertSame('anzhengchao1', $response['params']['touser']); + $this->assertSame('test_tpl_id', $response['params']['template_id']); + $this->assertSame('url', $response['params']['url']); // $this->assertEquals('color', $response['params']['topcolor']); $response = $notice->foo('bar')->withReceiver('anzhengchao2')->withTemplate('tpl1')->withLink('link')->andColor('andColor')->send(); - $this->assertEquals('anzhengchao2', $response['params']['touser']); - $this->assertEquals('tpl1', $response['params']['template_id']); - $this->assertEquals('link', $response['params']['url']); + $this->assertSame('anzhengchao2', $response['params']['touser']); + $this->assertSame('tpl1', $response['params']['template_id']); + $this->assertSame('link', $response['params']['url']); // $this->assertEquals('andColor', $response['params']['topcolor']); } @@ -160,16 +160,16 @@ public function testFormatData() ]; $response = $notice->to('anzhengchao')->color('color1')->template('overtrue')->data($data)->send(); - $this->assertEquals('anzhengchao', $response['params']['touser']); + $this->assertSame('anzhengchao', $response['params']['touser']); // $this->assertEquals('color1', $response['params']['topcolor']); - $this->assertEquals('overtrue', $response['params']['template_id']); + $this->assertSame('overtrue', $response['params']['template_id']); // format1 - $this->assertEquals(['value' => '恭喜你购买成功!', 'color' => '#173177'], $response['params']['data']['first']); - $this->assertEquals(['value' => '巧克力', 'color' => '#173177'], $response['params']['data']['keynote1']); - $this->assertEquals(['value' => '39.8元', 'color' => '#173177'], $response['params']['data']['keynote2']); - $this->assertEquals(['value' => '2014年9月16日', 'color' => '#173177'], $response['params']['data']['keynote3']); - $this->assertEquals(['value' => '欢迎再次购买!', 'color' => '#173177'], $response['params']['data']['remark']); + $this->assertSame(['value' => '恭喜你购买成功!', 'color' => '#173177'], $response['params']['data']['first']); + $this->assertSame(['value' => '巧克力', 'color' => '#173177'], $response['params']['data']['keynote1']); + $this->assertSame(['value' => '39.8元', 'color' => '#173177'], $response['params']['data']['keynote2']); + $this->assertSame(['value' => '2014年9月16日', 'color' => '#173177'], $response['params']['data']['keynote3']); + $this->assertSame(['value' => '欢迎再次购买!', 'color' => '#173177'], $response['params']['data']['remark']); // format2 $data = [ @@ -183,12 +183,12 @@ public function testFormatData() $response = $notice->to('anzhengchao')->color('color1')->template('overtrue')->data($data)->send(); - $this->assertEquals(['value' => '恭喜你购买成功!', 'color' => '#555555'], $response['params']['data']['first']); - $this->assertEquals(['value' => '巧克力', 'color' => '#336699'], $response['params']['data']['keynote1']); - $this->assertEquals(['value' => '39.8元', 'color' => '#173177'], $response['params']['data']['keynote2']); - $this->assertEquals(['value' => '2014年9月16日', 'color' => '#888888'], $response['params']['data']['keynote3']); - $this->assertEquals(['value' => '欢迎再次购买!', 'color' => '#173177'], $response['params']['data']['remark']); - $this->assertEquals(['value' => 'error data item.', 'color' => '#173177'], $response['params']['data']['abc']); + $this->assertSame(['value' => '恭喜你购买成功!', 'color' => '#555555'], $response['params']['data']['first']); + $this->assertSame(['value' => '巧克力', 'color' => '#336699'], $response['params']['data']['keynote1']); + $this->assertSame(['value' => '39.8元', 'color' => '#173177'], $response['params']['data']['keynote2']); + $this->assertSame(['value' => '2014年9月16日', 'color' => '#888888'], $response['params']['data']['keynote3']); + $this->assertSame(['value' => '欢迎再次购买!', 'color' => '#173177'], $response['params']['data']['remark']); + $this->assertSame(['value' => 'error data item.', 'color' => '#173177'], $response['params']['data']['abc']); // format3 $data = [ @@ -200,10 +200,10 @@ public function testFormatData() ]; $response = $notice->to('anzhengchao')->color('color1')->template('overtrue')->data($data)->send(); - $this->assertEquals(['value' => '恭喜你购买成功!', 'color' => '#555555'], $response['params']['data']['first']); - $this->assertEquals(['value' => '巧克力', 'color' => '#336699'], $response['params']['data']['keynote1']); - $this->assertEquals(['value' => '39.8元', 'color' => '#FF0000'], $response['params']['data']['keynote2']); - $this->assertEquals(['value' => '2014年9月16日', 'color' => '#888888'], $response['params']['data']['keynote3']); - $this->assertEquals(['value' => '欢迎再次购买!', 'color' => '#5599FF'], $response['params']['data']['remark']); + $this->assertSame(['value' => '恭喜你购买成功!', 'color' => '#555555'], $response['params']['data']['first']); + $this->assertSame(['value' => '巧克力', 'color' => '#336699'], $response['params']['data']['keynote1']); + $this->assertSame(['value' => '39.8元', 'color' => '#FF0000'], $response['params']['data']['keynote2']); + $this->assertSame(['value' => '2014年9月16日', 'color' => '#888888'], $response['params']['data']['keynote3']); + $this->assertSame(['value' => '欢迎再次购买!', 'color' => '#5599FF'], $response['params']['data']['remark']); } } diff --git a/tests/OfficialAccount/Url/ClientTest.php b/tests/OfficialAccount/Url/ClientTest.php index e38ffd943..fd9e2ea33 100755 --- a/tests/OfficialAccount/Url/ClientTest.php +++ b/tests/OfficialAccount/Url/ClientTest.php @@ -29,7 +29,7 @@ public function testShorten() $response = $url->shorten('http://easywechat.org'); $this->assertStringStartsWith(Url::API_SHORTEN_URL, $response[1][0]); - $this->assertEquals('long2short', $response[1][1]['action']); - $this->assertEquals('http://easywechat.org', $response[1][1]['long_url']); + $this->assertSame('long2short', $response[1][1]['action']); + $this->assertSame('http://easywechat.org', $response[1][1]['long_url']); } } diff --git a/tests/OfficialAccount/User/UserClientTest.php b/tests/OfficialAccount/User/UserClientTest.php index ad7f8e3dc..2fbf3816b 100755 --- a/tests/OfficialAccount/User/UserClientTest.php +++ b/tests/OfficialAccount/User/UserClientTest.php @@ -39,8 +39,8 @@ public function testGet() $result = $user->get('openid_fo_overtrue'); $this->assertStringStartsWith(User::API_GET, $result['api']); - $this->assertEquals('openid_fo_overtrue', $result['params']['openid']); - $this->assertEquals('zh_CN', $result['params']['lang']); + $this->assertSame('openid_fo_overtrue', $result['params']['openid']); + $this->assertSame('zh_CN', $result['params']['lang']); } /** @@ -64,7 +64,7 @@ public function testBatchGet() ]; $this->assertStringStartsWith(User::API_BATCH_GET, $result['api']); - $this->assertEquals($expected, $result['params']['user_list']); + $this->assertSame($expected, $result['params']['user_list']); } /** @@ -77,7 +77,7 @@ public function testLists() $result = $user->lists('openid1'); $this->assertStringStartsWith(User::API_LIST, $result['api']); - $this->assertEquals('openid1', $result['params']['next_openid']); + $this->assertSame('openid1', $result['params']['next_openid']); } /** @@ -90,8 +90,8 @@ public function testRemark() $result = $user->remark('openid1', 'easywechat'); $this->assertStringStartsWith(User::API_REMARK, $result['api']); - $this->assertEquals('openid1', $result['params']['openid']); - $this->assertEquals('easywechat', $result['params']['remark']); + $this->assertSame('openid1', $result['params']['openid']); + $this->assertSame('easywechat', $result['params']['remark']); } /** @@ -103,10 +103,10 @@ public function testGroup() $result = $user->group('openid1'); - $this->assertEquals('openid1', $result['params']['openid']); + $this->assertSame('openid1', $result['params']['openid']); $result = $user->getGroup('openid2'); - $this->assertEquals('openid2', $result['params']['openid']); + $this->assertSame('openid2', $result['params']['openid']); } /** @@ -120,7 +120,7 @@ public function testBlacklist() $this->assertNull($result['params']['begin_openid']); $result = $user->blacklist('black-openid'); - $this->assertEquals('black-openid', $result['params']['begin_openid']); + $this->assertSame('black-openid', $result['params']['begin_openid']); } /** @@ -135,7 +135,7 @@ public function testBatchBlockUser() $expected = ['openid1', 'openid2']; $this->assertStringStartsWith(User::API_BATCH_BLACK_LIST, $result['api']); - $this->assertEquals($expected, $result['params']['openid_list']); + $this->assertSame($expected, $result['params']['openid_list']); } /** @@ -150,6 +150,6 @@ public function testBatchUnblockUser() $expected = ['openid1', 'openid2']; $this->assertStringStartsWith(User::API_BATCH_UNBLACK_LIST, $result['api']); - $this->assertEquals($expected, $result['params']['openid_list']); + $this->assertSame($expected, $result['params']['openid_list']); } } diff --git a/tests/OfficialAccount/User/UserGroupClientTest.php b/tests/OfficialAccount/User/UserGroupClientTest.php index 55c76113e..70db455f4 100755 --- a/tests/OfficialAccount/User/UserGroupClientTest.php +++ b/tests/OfficialAccount/User/UserGroupClientTest.php @@ -39,7 +39,7 @@ public function testCreate() $result = $group->create('overtrue'); $this->assertStringStartsWith(Group::API_CREATE, $result['api']); - $this->assertEquals(['name' => 'overtrue'], $result['params']['group']); + $this->assertSame(['name' => 'overtrue'], $result['params']['group']); } /** @@ -71,7 +71,7 @@ public function testUpdate() $result = $group->update(12, 'newName'); $this->assertStringStartsWith(Group::API_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -89,7 +89,7 @@ public function testDelete() $result = $group->delete(12); $this->assertStringStartsWith(Group::API_DELETE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -102,7 +102,7 @@ public function testUserGroup() $result = $group->userGroup('overtrue'); $this->assertStringStartsWith(Group::API_USER_GROUP_ID, $result['api']); - $this->assertEquals(['openid' => 'overtrue'], $result['params']); + $this->assertSame(['openid' => 'overtrue'], $result['params']); } /** @@ -120,7 +120,7 @@ public function testMoveUser() $result = $group->moveUser('overtrue', 13); $this->assertStringStartsWith(Group::API_MEMBER_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } /** @@ -138,6 +138,6 @@ public function testMoveUsers() $result = $group->moveUsers(['overtrue', 'foobar'], 13); $this->assertStringStartsWith(Group::API_MEMBER_BATCH_UPDATE, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OpenPlatform/Api/ApiTest.php b/tests/OpenPlatform/Api/ApiTest.php index 067f31c7d..de3f9272f 100644 --- a/tests/OpenPlatform/Api/ApiTest.php +++ b/tests/OpenPlatform/Api/ApiTest.php @@ -74,7 +74,7 @@ public function testGetClientId() { $api = new OpenPlatformApi($this->getAccessToken('app_id'), $this->getRequest()); - $this->assertEquals('app_id', $api->getClientId()); + $this->assertSame('app_id', $api->getClientId()); } } diff --git a/tests/OpenPlatform/Api/BaseApiTest.php b/tests/OpenPlatform/Api/BaseApiTest.php index 1af956d9d..d2603be9e 100644 --- a/tests/OpenPlatform/Api/BaseApiTest.php +++ b/tests/OpenPlatform/Api/BaseApiTest.php @@ -25,7 +25,7 @@ public function testGetAuthorizationInfo() ]; $this->assertStringStartsWith(BaseApi::GET_AUTH_INFO, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } public function testGetAuthorizerToken() @@ -39,7 +39,7 @@ public function testGetAuthorizerToken() ]; $this->assertStringStartsWith(BaseApi::GET_AUTHORIZER_TOKEN, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } public function testGetAuthorizerInfo() @@ -52,7 +52,7 @@ public function testGetAuthorizerInfo() ]; $this->assertStringStartsWith(BaseApi::GET_AUTHORIZER_INFO, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } public function testGetAuthorizerOption() @@ -66,7 +66,7 @@ public function testGetAuthorizerOption() ]; $this->assertStringStartsWith(BaseApi::GET_AUTHORIZER_OPTION, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } public function testSetAuthorizerOption() @@ -81,6 +81,6 @@ public function testSetAuthorizerOption() ]; $this->assertStringStartsWith(BaseApi::SET_AUTHORIZER_OPTION, $result['api']); - $this->assertEquals($expected, $result['params']); + $this->assertSame($expected, $result['params']); } } diff --git a/tests/OpenPlatform/Api/PreAuthorizationTest.php b/tests/OpenPlatform/Api/PreAuthorizationTest.php index de76a46d6..697ce9493 100644 --- a/tests/OpenPlatform/Api/PreAuthorizationTest.php +++ b/tests/OpenPlatform/Api/PreAuthorizationTest.php @@ -15,14 +15,14 @@ class PreAuthorizationTest extends ApiTest { public function testGetClientId() { - $this->assertEquals('appid@foobar', $this->mockPreAuthorization('appid@foobar')->getClientId()); + $this->assertSame('appid@foobar', $this->mockPreAuthorization('appid@foobar')->getClientId()); } public function testGetCode() { $preAuth = $this->mockPreAuthorization('appid@foobar', 'code@foobar'); - $this->assertEquals('code@foobar', $preAuth->getCode()); + $this->assertSame('code@foobar', $preAuth->getCode()); } public function testRedirect() @@ -30,6 +30,6 @@ public function testRedirect() $response = $this->mockPreAuthorization('appid@foobar', 'code@foobar')->redirect('http://domain.com/callback.php'); $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); - $this->assertEquals('https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=appid@foobar&pre_auth_code=code@foobar&redirect_uri=http%3A%2F%2Fdomain.com%2Fcallback.php', $response->getTargetUrl()); + $this->assertSame('https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=appid@foobar&pre_auth_code=code@foobar&redirect_uri=http%3A%2F%2Fdomain.com%2Fcallback.php', $response->getTargetUrl()); } } diff --git a/tests/OpenPlatform/AuthorizerAccessTokenTest.php b/tests/OpenPlatform/AuthorizerAccessTokenTest.php index cee022eaf..ed10449a2 100644 --- a/tests/OpenPlatform/AuthorizerAccessTokenTest.php +++ b/tests/OpenPlatform/AuthorizerAccessTokenTest.php @@ -22,36 +22,36 @@ public function testGetAppidAndOpenplatformAppid() { $instance = $this->make('appid@123'); - $this->assertEquals('appid@123', $instance->getAppId()); - $this->assertEquals('open-platform-appid', $instance->getClientId()); + $this->assertSame('appid@123', $instance->getAppId()); + $this->assertSame('open-platform-appid', $instance->getClientId()); } public function testGetToken() { $auth = $this->make('appid@123', 'token@123'); - $this->assertEquals('token@123', $auth->getToken()); + $this->assertSame('token@123', $auth->getToken()); } public function testGetTokenExpired() { $auth = $this->make('appid@123', null, 'token@456'); - $this->assertEquals('token@456', $auth->getToken()); + $this->assertSame('token@456', $auth->getToken()); } public function testGetTokenForced() { $auth = $this->make('appid@123', 'token@123', 'token@456'); - $this->assertEquals('token@456', $auth->getToken(true)); + $this->assertSame('token@456', $auth->getToken(true)); } public function testGetCacheKey() { $instance = $this->make('appid@123', 'token@123', 'token@456'); - $this->assertEquals('easywechat.open_platform.authorizer_access_token.open-platform-appidappid@123', $instance->getCacheKey()); + $this->assertSame('easywechat.open_platform.authorizer_access_token.open-platform-appidappid@123', $instance->getCacheKey()); } private function make($appId, $cachedToken = null, $newToken = null) diff --git a/tests/OpenPlatform/EventHandlers/ComponentVerifyTicketTest.php b/tests/OpenPlatform/EventHandlers/ComponentVerifyTicketTest.php index ddc110664..98448840d 100644 --- a/tests/OpenPlatform/EventHandlers/ComponentVerifyTicketTest.php +++ b/tests/OpenPlatform/EventHandlers/ComponentVerifyTicketTest.php @@ -31,6 +31,6 @@ public function testHandle() ]); $handler->handle($message); - $this->assertEquals('ticket@123123', $verifyTicket->getTicket()); + $this->assertSame('ticket@123123', $verifyTicket->getTicket()); } } diff --git a/tests/OpenPlatform/GuardTest.php b/tests/OpenPlatform/GuardTest.php index 2aef97c3a..5647dd70a 100644 --- a/tests/OpenPlatform/GuardTest.php +++ b/tests/OpenPlatform/GuardTest.php @@ -11,8 +11,8 @@ namespace EasyWeChat\Tests\OpenPlatform; -use EasyWeChat\Application; use EasyWeChat\Applications\OpenPlatform\Server\Guard; +use EasyWeChat\Factory; use EasyWeChat\Tests\TestCase; class GuardTest extends TestCase @@ -44,7 +44,7 @@ private function make() ], ]; - $app = new Application($config); + $app = new Factory($config); return $app->offsetGet('open_platform.instance')->server; } diff --git a/tests/OpenPlatform/OpenPlatformTest.php b/tests/OpenPlatform/OpenPlatformTest.php index 19d6bd529..4a3c0c683 100644 --- a/tests/OpenPlatform/OpenPlatformTest.php +++ b/tests/OpenPlatform/OpenPlatformTest.php @@ -12,9 +12,9 @@ namespace EasyWeChat\Tests\OpenPlatform; use Doctrine\Common\Cache\ArrayCache; -use EasyWeChat\Application; use EasyWeChat\Applications\OpenPlatform\Core\AccessToken; use EasyWeChat\Applications\OpenPlatform\Core\VerifyTicket; +use EasyWeChat\Factory; use EasyWeChat\Tests\TestCase; use Mockery as m; @@ -52,13 +52,13 @@ public function testMakeAuthorizer() $newApp = $app->offsetGet('open_platform.instance')->createAuthorizerApplication('authorizer-appid@999', 'authorizer-refresh-token'); $this->assertInstanceOf('EasyWeChat\Applications\OpenPlatform\Core\AuthorizerAccessToken', $newApp->access_token); - $this->assertEquals('authorizer-appid@999', $newApp->access_token->getAppId()); + $this->assertSame('authorizer-appid@999', $newApp->access_token->getAppId()); } /** * Makes application. * - * @return Application + * @return Factory */ private function make() { @@ -73,6 +73,6 @@ private function make() ], ]; - return new Application($config); + return new Factory($config); } } diff --git a/tests/OpenPlatform/VerifyTicketTest.php b/tests/OpenPlatform/VerifyTicketTest.php index 18ed6ef51..677eda6f8 100644 --- a/tests/OpenPlatform/VerifyTicketTest.php +++ b/tests/OpenPlatform/VerifyTicketTest.php @@ -33,7 +33,7 @@ public function testTicket() $verifyTicket = $this->getVerifyTicket('foobar'); $this->assertTrue($verifyTicket->setTicket('ticket@foobar')); - $this->assertEquals('ticket@foobar', $verifyTicket->getTicket()); + $this->assertSame('ticket@foobar', $verifyTicket->getTicket()); } /** @@ -43,10 +43,10 @@ public function testCacheKey() { $verifyTicket = $this->getVerifyTicket('app-id'); - $this->assertEquals('easywechat.open_platform.component_verify_ticket.app-id', $verifyTicket->getCacheKey()); + $this->assertSame('easywechat.open_platform.component_verify_ticket.app-id', $verifyTicket->getCacheKey()); $verifyTicket->setCacheKey('cache-key.app-id'); - $this->assertEquals('cache-key.app-id', $verifyTicket->getCacheKey()); + $this->assertSame('cache-key.app-id', $verifyTicket->getCacheKey()); } } diff --git a/tests/Support/Traits/PrefixedContainerTest.php b/tests/Support/Traits/PrefixedContainerTest.php index 5de95dc77..e79a02773 100644 --- a/tests/Support/Traits/PrefixedContainerTest.php +++ b/tests/Support/Traits/PrefixedContainerTest.php @@ -29,7 +29,7 @@ public function testFetch() 'application.foo' => 'foo@application', ]); - $this->assertEquals('foo@application', $app->fetch('foo')); + $this->assertSame('foo@application', $app->fetch('foo')); } /** @@ -48,7 +48,7 @@ public function testMagicGet() 'application.bar' => 'bar@application', ]); - $this->assertEquals('bar@application', $app->bar); + $this->assertSame('bar@application', $app->bar); } }