Skip to content

Commit

Permalink
fix tests, --filter=unit
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 24, 2024
1 parent 1debe0c commit 781bc20
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
8 changes: 4 additions & 4 deletions tests/swoole_event/add_after_server_start.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require __DIR__ . '/../include/bootstrap.php';

use Swoole\Server;

const FILE = __DIR__.'/tmp_result.txt';
const FILE = __DIR__ . '/tmp_result.txt';

$pm = new SwooleTest\ProcessManager;
$pm->parentFunc = function ($pid) use ($pm) {
Expand All @@ -22,12 +22,12 @@ $pm->parentFunc = function ($pid) use ($pm) {
$pm->childFunc = function () use ($pm) {
$serv = new Server('127.0.0.1', $pm->getFreePort(), SWOOLE_PROCESS);
$serv->set(array(
"worker_num" => 1,
'worker_num' => 1,
'log_file' => '/dev/null',
));
$serv->on("start", function (Server $serv) use ($pm) {
$fp = stream_socket_client("tcp://www.qq.com:80", $errno, $errstr, 30);
fwrite($fp, "GET / HTTP/1.1\r\nHost: www.qq.com\r\n\r\n");
$fp = stream_socket_client("tcp://" . TEST_DOMAIN_2 . ":80", $errno, $errstr, 30);
fwrite($fp, "GET / HTTP/1.1\r\nHost: " . TEST_DOMAIN_2 . "\r\n\r\n");

Swoole\Event::add($fp, function ($fp) use ($pm) {
$resp = fread($fp, 8192);
Expand Down
18 changes: 11 additions & 7 deletions tests/swoole_http2_client_coro/connect_twice.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,33 @@ swoole_http2_client_coro: connect twice
<?php
require __DIR__ . '/../include/bootstrap.php';

use Swoole\Coroutine\Channel;
use Swoole\Http2\Request;
use function Swoole\Coroutine\run;
use function Swoole\Coroutine\go;

run(function () {
$client = new \Swoole\Coroutine\Http2\Client('www.zhihu.com', 443, true);
$chan = new \Swoole\Coroutine\Channel(1);
$client = new \Swoole\Coroutine\Http2\Client('httpbin.org', 443, true);
$chan = new Channel(1);
go(function () use ($client, $chan) {
$client->connect();
$req = new \Swoole\Http2\Request();
$req = new Request();
$uuid = uniqid();
$req->method = 'GET';
$req->path = '/io?io=' . str_repeat('xxx', 1000);
$req->path = '/base64/' . base64_encode($uuid);
$client->send($req);
$chan->push(true);
$resp = $client->recv();
Assert::eq($resp->statusCode, 200);
Assert::contains($resp->data, '知乎');
Assert::eq($resp->data, $uuid);
$chan->pop();
});
go(function () use ($client, $chan) {
Assert::eq($client->connect(), false);
$req = new \Swoole\Http2\Request();
$uuid = uniqid();
$req = new Request();
$req->method = 'GET';
$req->path = '/io?io=xxx';
$req->path = '/base64/' . base64_encode($uuid);
$client->send($req);
$chan->push(true);
Assert::eq($client->recv(), false);
Expand Down
4 changes: 2 additions & 2 deletions tests/swoole_http_client_coro/http_proxy.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ skip_if_offline();
<?php
require __DIR__ . '/../include/bootstrap.php';
go(function () {
$domain = 'www.qq.com';
$domain = 'www.baidu.com';
$cli = new Swoole\Coroutine\Http\Client($domain, 443, true);
// $cli->setHeaders(['Host' => $domain]); // without host header it can also work well
$cli->set([
Expand All @@ -20,7 +20,7 @@ go(function () {
]);
$result = $cli->get('/');
Assert::assert($result);
Assert::assert(stripos($cli->body, 'tencent') !== false);
Assert::assert(stripos($cli->body, '百度') !== false);
echo "DONE\n";
});
?>
Expand Down

0 comments on commit 781bc20

Please sign in to comment.