Skip to content

Commit

Permalink
Fine down the unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
twose committed Apr 20, 2018
1 parent 08ecb1b commit 140668f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
7 changes: 4 additions & 3 deletions README-en.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Saber

[![Latest Version](https://img.shields.io/github/release/swlib/swlib.svg?style=flat-square)](https://github.com/swlib/saber/releases)
[![Build Status](https://travis-ci.org/swlib/saber.svg?branch=master)](https://github.com/swlib/saber/releases)
[![Latest Version](https://img.shields.io/github/release/swlib/saber.svg?style=flat-square)](https://github.com/swlib/saber/releases)
[![Build Status](https://travis-ci.org/swlib/saber.svg?branch=master)](https://travis-ci.org/swlib/saber)
[![Php Version](https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000)](https://secure.php.net/)
[![Swoole Version](https://img.shields.io/badge/swoole-%3E=2.1.2-brightgreen.svg?maxAge=2592000)](https://github.com/swoole/swoole-src)
[![Saber License](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/swlib/saber/blob/master/LICENSE)
Expand Down Expand Up @@ -218,4 +218,5 @@ composer update
| headers | header |
| redirect | follow |
| form_data | query |
| useragent | ua |
| useragent | ua |

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Saber

[![Latest Version](https://img.shields.io/github/release/swlib/saber.svg?style=flat-square)](https://github.com/swlib/saber/releases)
[![Build Status](https://travis-ci.org/swlib/saber.svg?branch=master)](https://github.com/swlib/saber/releases)
[![Build Status](https://travis-ci.org/swlib/saber.svg?branch=master)](https://travis-ci.org/swlib/saber)
[![Php Version](https://img.shields.io/badge/php-%3E=7.1-brightgreen.svg?maxAge=2592000)](https://secure.php.net/)
[![Swoole Version](https://img.shields.io/badge/swoole-%3E=2.1.2-brightgreen.svg?maxAge=2592000)](https://github.com/swoole/swoole-src)
[![Saber License](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/swlib/saber/blob/master/LICENSE)
Expand All @@ -24,7 +24,7 @@ HTTP军刀(呆毛王), `Swoole人性化组件库`之PHP高性能HTTP客户端,
- 自动化 编码请求/解析响应 数据
- 毫秒超时定时器
- 超大文件上传, 断点重传
- W​ebSocket连接
- WebSocket连接
- 随机UA生成器

<br>
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="./test/bootstrap.php"
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -10,7 +10,7 @@
stopOnFailure="false">
<testsuites>
<testsuite name="Tests">
<directory suffix="Test.php">./test</directory>
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
Expand Down
6 changes: 3 additions & 3 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class Request extends \Swlib\Http\Request

use SpecialMarkTrait;

function __construct(?Uri $uri = null, string $method = 'GET', array $headers = [], ?StreamInterface $body = null)
function __construct(string $method = 'GET', $uri = '', array $headers = [], ?StreamInterface $body = null)
{
parent::__construct($uri, $method, $headers, $body);
parent::__construct($method, $uri, $headers, $body);
$this->__cookiesInitialization(true);
}

Expand Down Expand Up @@ -347,7 +347,7 @@ public function exec()

/** 获取IP地址 */
$host = $this->uri->getHost();
$port = $this->uri->getPort();
$port = $this->uri->getRealPort();
$is_ssl = $this->getSSL();
$is_ssl = ($is_ssl === self::SSL_AUTO) ? $port === 443 : (bool)$is_ssl;

Expand Down
5 changes: 3 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ function __construct(Request $request)

/** 转码 */
if (!empty($body = $request->client->body)) {
if (stristr($request->client->headers['content-type'], 'utf-8') === false) {
$type = explode('=', $request->client->headers['content-type'])[1] ?? null;
$contentType = $request->client->headers['content-type'] ?? '';
if ($contentType && stristr($contentType, 'utf-8') === false) {
$type = explode('=', $contentType)[1] ?? null;
if ($type) {
$body = iconv(strtoupper($type), 'UTF-8//IGNORE', $body);
}
Expand Down
4 changes: 3 additions & 1 deletion test/HttpTest.php → tests/SaberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Date: 2018/4/14 下午10:50
*/

namespace Swlib\Tests\Saber;

use PHPUnit\Framework\TestCase;
use Swlib\Http\ContentType;
use Swlib\Http\Exception\ClientException;
Expand All @@ -15,7 +17,7 @@
use Swlib\Http\SwUploadFile;
use Swlib\Saber;

class HttpTest extends TestCase
class SaberTest extends TestCase
{
public function testExceptionReport()
{
Expand Down
File renamed without changes
File renamed without changes.

0 comments on commit 140668f

Please sign in to comment.