Skip to content

Commit

Permalink
Develop (#416)
Browse files Browse the repository at this point in the history
* 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.

* CS.

* Support guzzle basic options. #415

* En comment.
  • Loading branch information
overtrue committed May 17, 2016
1 parent b6898b8 commit f0c41e2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
29 changes: 29 additions & 0 deletions src/Core/Http.php
Expand Up @@ -46,6 +46,33 @@ class Http
*/
protected $middlewares = [];

/**
* Guzzle client default settings.
*
* @var array
*/
protected static $defaults = [];

/**
* Set guzzle default settings.
*
* @param array $defaults
*/
public static function setDefaultOptions($defaults = [])
{
self::$defaults = $defaults;
}

/**
* Return current guzzle default settings.
*
* @return array
*/
public static function getDefaultOptions()
{
return self::$defaults;
}

/**
* GET request.
*
Expand Down Expand Up @@ -192,6 +219,8 @@ public function request($url, $method = 'GET', $options = [])
{
$method = strtoupper($method);

$options = array_merge(self::$defaults, $options);

Log::debug('Client Request:', compact('url', 'method', 'options'));

$options['handler'] = $this->getHandler();
Expand Down
3 changes: 3 additions & 0 deletions src/Foundation/Application.php
Expand Up @@ -27,6 +27,7 @@

use Doctrine\Common\Cache\FilesystemCache;
use EasyWeChat\Core\AccessToken;
use EasyWeChat\Core\Http;
use EasyWeChat\Support\Log;
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
Expand Down Expand Up @@ -105,6 +106,8 @@ public function __construct($config)
$this->registerBase();
$this->initializeLogger();

Http::setDefaultOptions($this['config']->get('guzzle', []));

Log::debug('Current configuration:', $config);
}

Expand Down
6 changes: 3 additions & 3 deletions src/User/Tag.php
Expand Up @@ -115,7 +115,7 @@ public function userTags($openId)
/**
* Get users from a tag.
*
* @param string $openId
* @param string $tagId
*
* @return int
*/
Expand All @@ -130,7 +130,7 @@ public function usersOfTag($tagId)
* Batch tag users.
*
* @param array $openIds
* @param int $tagid
* @param int $tagId
*
* @return bool
*/
Expand All @@ -148,7 +148,7 @@ public function batchTagUsers(array $openIds, $tagId)
* Untag users from a tag.
*
* @param array $openIds
* @param int $tagid
* @param int $tagId
*
* @return bool
*/
Expand Down
13 changes: 13 additions & 0 deletions tests/Foundation/ApplicationTest.php
Expand Up @@ -9,6 +9,7 @@
* with this source code in the file LICENSE.
*/

use EasyWeChat\Core\Http;
use EasyWeChat\Foundation\Application;
use EasyWeChat\Foundation\Config;
use Pimple\Container;
Expand Down Expand Up @@ -43,6 +44,18 @@ public function testConstructor()
}
}

public function testHttpDefaultOptions()
{
$app = new Application([]);

$this->assertEmpty(Http::getDefaultOptions());

$config = ['guzzle' => ['timeout' => 5]];
$app = new Application($config);

$this->assertEquals($config['guzzle'], Http::getDefaultOptions());
}

/**
* test __set, __get.
*/
Expand Down

0 comments on commit f0c41e2

Please sign in to comment.