Permalink
Browse files

Develop (#410)

* Bugfix close #389

* Fix tests.

* Fix url. close #393

* Payment::configForPayment() bugfix. EasyWeChat/docs#27

* Fix tests.

* Add methods for JSSDK payment.

* Fix tests.

* Applied fixes from StyleCI (#400)

* Scrutinizer Auto-Fixes (#399)

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com

* Filter the empty params. #402

* Add User Tag service.

* Applied fixes from StyleCI (#409)

* Typo.
  • Loading branch information...
1 parent ba17f63 commit fee6ef0d25f4efb2543241d0a746e7c918b8abb5 @overtrue committed May 4, 2016
Showing with 385 additions and 38 deletions.
  1. +1 −1 phpunit.xml.dist
  2. +8 −0 src/Foundation/ServiceProviders/UserServiceProvider.php
  3. +164 −0 src/User/Tag.php
  4. +1 −1 tests/Broadcast/BroadcastBroadcastTest.php
  5. +1 −1 tests/Broadcast/BroadcastMessageBuilderTest.php
  6. +1 −1 tests/Broadcast/BroadcastTransformerTest.php
  7. +1 −1 tests/Core/CoreAbstractAPITest.php
  8. +1 −1 tests/Core/CoreAccessTokenTest.php
  9. +1 −1 tests/Core/CoreHttpTest.php
  10. +1 −1 tests/Encryption/EncryptionEncryptorTest.php
  11. +1 −1 tests/Foundation/ApplicationTest.php
  12. +1 −1 tests/Js/JsJsTest.php
  13. +1 −1 tests/Material/MaterialMaterialTest.php
  14. +1 −1 tests/Material/MaterialTemporaryTest.php
  15. +1 −1 tests/Menu/MenuMenuTest.php
  16. +1 −1 tests/Message/MessageAbstractMessageTest.php
  17. +1 −1 tests/Message/MessageArticleTest.php
  18. +1 −1 tests/Message/MessageImageTest.php
  19. +1 −1 tests/Message/MessageMaterialTest.php
  20. +1 −1 tests/Message/MessageVideoTest.php
  21. +1 −1 tests/Message/MessageVoiceTest.php
  22. +1 −1 tests/Notice/NoticeNoticeTest.php
  23. +1 −1 tests/POI/POIPOITest.php
  24. +1 −1 tests/Payment/PaymentAPITest.php
  25. +1 −1 tests/Payment/PaymentLuckyMoneyAPITest.php
  26. +1 −1 tests/Payment/PaymentLuckyMoneyLuckyMoneyTest.php
  27. +1 −1 tests/Payment/PaymentNotifyTest.php
  28. +1 −1 tests/Payment/PaymentPaymentTest.php
  29. +1 −1 tests/QRCode/QRCodeQRCodeTest.php
  30. +1 −1 tests/Reply/ReplyReplyTest.php
  31. +1 −1 tests/Semantic/SemanticSemanticTest.php
  32. +1 −1 tests/Server/ServerGuardTest.php
  33. +1 −1 tests/Server/ServerTransformerTest.php
  34. +1 −1 tests/Staff/StaffMessageBuilderTest.php
  35. +1 −1 tests/Staff/StaffStaffTest.php
  36. +1 −1 tests/Staff/StaffTransformerTest.php
  37. +1 −1 tests/Stats/StatsStatsTest.php
  38. +29 −0 tests/TestCase.php
  39. +1 −1 tests/Url/UrlUrlTest.php
  40. +1 −1 tests/User/UserGroupTest.php
  41. +141 −0 tests/User/UserTagTest.php
  42. +1 −1 tests/User/UserUserTest.php
  43. +5 −0 tests/bootstrap.php
View
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
- bootstrap="vendor/autoload.php"
+ bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
@@ -26,6 +26,7 @@
namespace EasyWeChat\Foundation\ServiceProviders;
use EasyWeChat\User\Group;
+use EasyWeChat\User\Tag;
use EasyWeChat\User\User;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
@@ -53,7 +54,14 @@ public function register(Container $pimple)
return new Group($pimple['access_token']);
};
+ $tag = function ($pimple) {
+ return new Tag($pimple['access_token']);
+ };
+
$pimple['user_group'] = $group;
$pimple['user.group'] = $group;
+
+ $pimple['user_tag'] = $tag;
+ $pimple['user.tag'] = $tag;
}
}
View
@@ -0,0 +1,164 @@
+<?php
+
+/*
+ * This file is part of the overtrue/wechat.
+ *
+ * (c) overtrue <i@overtrue.me>
+ *
+ * This source file is subject to the MIT license that is bundled
+ * with this source code in the file LICENSE.
+ */
+
+/**
+ * Group.php.
+ *
+ * @author overtrue <i@overtrue.me>
+ * @copyright 2015 overtrue <i@overtrue.me>
+ *
+ * @link https://github.com/overtrue
+ * @link http://overtrue.me
+ */
+namespace EasyWeChat\User;
+
+use EasyWeChat\Core\AbstractAPI;
+
+/**
+ * Class Tag.
+ */
+class Tag extends AbstractAPI
+{
+ const API_GET = 'https://api.weixin.qq.com/cgi-bin/tags/get';
+ const API_CREATE = 'https://api.weixin.qq.com/cgi-bin/tags/create';
+ const API_UPDATE = 'https://api.weixin.qq.com/cgi-bin/tags/update';
+ const API_DELETE = 'https://api.weixin.qq.com/cgi-bin/tags/delete';
+ const API_USER_TAGS = 'https://api.weixin.qq.com/cgi-bin/tags/getidlist';
+ const API_MEMBER_BATCH_TAG = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging';
+ const API_MEMBER_BATCH_UNTAG = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging';
+ const API_USERS_OF_TAG = 'https://api.weixin.qq.com/cgi-bin/user/tag/get';
+
+ /**
+ * Create tag.
+ *
+ * @param string $name
+ *
+ * @return int
+ */
+ public function create($name)
+ {
+ $params = [
+ 'tag' => ['name' => $name],
+ ];
+
+ return $this->parseJSON('json', [self::API_CREATE, $params]);
+ }
+
+ /**
+ * List all tags.
+ *
+ * @return array
+ */
+ public function lists()
+ {
+ return $this->parseJSON('get', [self::API_GET]);
+ }
+
+ /**
+ * Update a tag name.
+ *
+ * @param int $tagId
+ * @param string $name
+ *
+ * @return bool
+ */
+ public function update($tagId, $name)
+ {
+ $params = [
+ 'tag' => [
+ 'id' => $tagId,
+ 'name' => $name,
+ ],
+ ];
+
+ return $this->parseJSON('json', [self::API_UPDATE, $params]);
+ }
+
+ /**
+ * Delete tag.
+ *
+ * @param int $tagId
+ *
+ * @return bool
+ */
+ public function delete($tagId)
+ {
+ $params = [
+ 'tag' => ['id' => $tagId],
+ ];
+
+ return $this->parseJSON('json', [self::API_DELETE, $params]);
+ }
+
+ /**
+ * Get user tags.
+ *
+ * @param string $openId
+ *
+ * @return int
+ */
+ public function userTags($openId)
+ {
+ $params = ['openid' => $openId];
+
+ return $this->parseJSON('json', [self::API_USER_TAGS, $params]);
+ }
+
+ /**
+ * Get users from a tag.
+ *
+ * @param string $openId
+ *
+ * @return int
+ */
+ public function usersOfTag($tagId)
+ {
+ $params = ['tagid' => $tagId];
+
+ return $this->parseJSON('json', [self::API_USERS_OF_TAG, $params]);
+ }
+
+ /**
+ * Batch tag users.
+ *
+ * @param array $openIds
+ * @param int $tagid
+ *
+ * @return bool
+ */
+ public function batchTagUsers(array $openIds, $tagId)
+ {
+ $params = [
+ 'openid_list' => $openIds,
+ 'tagid' => $tagId,
+ ];
+
+ return $this->parseJSON('json', [self::API_MEMBER_BATCH_TAG, $params]);
+ }
+
+ /**
+ * Untag users from a tag.
+ *
+ * @param array $openIds
+ * @param int $tagid
+ *
+ * @return bool
+ */
+ public function batchUntagUsers(array $openIds, $tagId)
+ {
+ $params = [
+ 'openid_list' => $openIds,
+ 'tagid' => $tagId,
+ ];
+
+ return $this->parseJSON('json', [self::API_MEMBER_BATCH_UNTAG, $params]);
+ }
+}
@@ -11,7 +11,7 @@
use EasyWeChat\Broadcast\Broadcast;
-class BroadcastBroadcastTest extends PHPUnit_Framework_TestCase
+class BroadcastBroadcastTest extends TestCase
{
public function getBroadcast()
{
@@ -12,7 +12,7 @@
use EasyWeChat\Broadcast\Broadcast;
use EasyWeChat\Broadcast\MessageBuilder;
-class BroadcastMessageBuilderTest extends PHPUnit_Framework_TestCase
+class BroadcastMessageBuilderTest extends TestCase
{
/**
* Test msgType().
@@ -11,7 +11,7 @@
use EasyWeChat\Broadcast\Transformer;
-class BroadcastTransformerTest extends PHPUnit_Framework_TestCase
+class BroadcastTransformerTest extends TestCase
{
/**
* Test transform().
@@ -22,7 +22,7 @@ public function getHttpInstance()
}
}
-class CoreAbstractAPITest extends PHPUnit_Framework_TestCase
+class CoreAbstractAPITest extends TestCase
{
/**
* Test __construct.
@@ -13,7 +13,7 @@
use EasyWeChat\Core\AccessToken;
use EasyWeChat\Core\Http;
-class CoreAccessTokenTest extends PHPUnit_Framework_TestCase
+class CoreAccessTokenTest extends TestCase
{
public function testGetToken()
{
@@ -14,7 +14,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
- class CoreHttpTest extends PHPUnit_Framework_TestCase
+ class CoreHttpTest extends TestCase
{
public function testConstruct()
{
@@ -3,7 +3,7 @@
use EasyWeChat\Encryption\Encryptor;
use EasyWeChat\Support\XML;
-class EncryptionEncryptorTest extends PHPUnit_Framework_TestCase
+class EncryptionEncryptorTest extends TestCase
{
public function getEncryptor()
{
@@ -15,7 +15,7 @@
use Pimple\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\Request;
-class ApplicationTest extends PHPUnit_Framework_TestCase
+class ApplicationTest extends TestCase
{
/**
* Test __construct().
@@ -13,7 +13,7 @@
use EasyWeChat\Core\Http;
use EasyWeChat\Js\Js;
- class JsJsTest extends PHPUnit_Framework_TestCase
+ class JsJsTest extends TestCase
{
public function getMockCache()
{
@@ -14,7 +14,7 @@
use EasyWeChat\Message\Article;
use GuzzleHttp\Psr7\Response;
-class MaterialMaterialTest extends PHPUnit_Framework_TestCase
+class MaterialMaterialTest extends TestCase
{
/**
* Return mock http.
@@ -15,7 +15,7 @@
use EasyWeChat\Material\Temporary;
use Mockery\Mock;
- class MaterialTemporaryTest extends PHPUnit_Framework_TestCase
+ class MaterialTemporaryTest extends TestCase
{
/**
* Return mock http.
@@ -11,7 +11,7 @@
use EasyWeChat\Menu\Menu;
-class MenuMenuTest extends PHPUnit_Framework_TestCase
+class MenuMenuTest extends TestCase
{
public function getMenu()
{
@@ -16,7 +16,7 @@ class FooMessage extends AbstractMessage
protected $properties = ['foo', 'bar'];
}
-class MessageAbstractMessageTest extends PHPUnit_Framework_TestCase
+class MessageAbstractMessageTest extends TestCase
{
/**
* Test __get().
@@ -11,7 +11,7 @@
use EasyWeChat\Message\Article;
-class MessageArticleTest extends PHPUnit_Framework_TestCase
+class MessageArticleTest extends TestCase
{
/**
* Test get attributes.
@@ -11,7 +11,7 @@
use EasyWeChat\Message\Image;
-class MessageImageTest extends PHPUnit_Framework_TestCase
+class MessageImageTest extends TestCase
{
/**
* Test media().
@@ -11,7 +11,7 @@
use EasyWeChat\Message\Material;
-class MessageMaterialTest extends PHPUnit_Framework_TestCase
+class MessageMaterialTest extends TestCase
{
/**
* Test get attributes.
@@ -11,7 +11,7 @@
use EasyWeChat\Message\Video;
-class MessageVideoTest extends PHPUnit_Framework_TestCase
+class MessageVideoTest extends TestCase
{
/**
* Test media().
@@ -11,7 +11,7 @@
use EasyWeChat\Message\Voice;
-class MessageVoiceTest extends PHPUnit_Framework_TestCase
+class MessageVoiceTest extends TestCase
{
/**
* Test media().
@@ -12,7 +12,7 @@
use EasyWeChat\Core\Exceptions\InvalidArgumentException;
use EasyWeChat\Notice\Notice;
-class NoticeNoticeTest extends PHPUnit_Framework_TestCase
+class NoticeNoticeTest extends TestCase
{
public function getNotice($mockHttp = false)
{
@@ -11,7 +11,7 @@
use EasyWeChat\POI\POI;
-class POIPOITest extends PHPUnit_Framework_TestCase
+class POIPOITest extends TestCase
{
public function getPOI()
{
@@ -16,7 +16,7 @@
use EasyWeChat\Support\XML;
use Psr\Http\Message\ResponseInterface;
-class PaymentAPITest extends PHPUnit_Framework_TestCase
+class PaymentAPITest extends TestCase
{
/**
* Build API instance.
@@ -14,7 +14,7 @@
use EasyWeChat\Payment\Merchant;
use EasyWeChat\Support\XML;
-class PaymentLuckyMoneyAPITest extends PHPUnit_Framework_TestCase
+class PaymentLuckyMoneyAPITest extends TestCase
{
public static function setUpBeforeClass()
{
Oops, something went wrong.

0 comments on commit fee6ef0

Please sign in to comment.