Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Jul 2, 2024
1 parent ab91af6 commit c19214a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
18 changes: 11 additions & 7 deletions tests/swoole_channel_coro/no_ctor.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ swoole_channel_coro: no ctor
<?php
require __DIR__ . '/../include/bootstrap.php';

class MyChan extends Swoole\Coroutine\Channel {
function __construct($size = null) {
class MyChan extends Swoole\Coroutine\Channel
{
function __construct($size = null)
{

}
}

go(function () {
$chan = new MyChan(100);
$chan->pop();
$pm = ProcessManager::exec(function () {
go(function () {
$chan = new MyChan(100);
$chan->pop();
});
});

Assert::contains($pm->getChildOutput(), "must call constructor first");
?>
--EXPECTF--
Fatal error: Swoole\Coroutine\Channel::pop(): you must call Channel constructor first in %s on line %d
--EXPECT--
24 changes: 13 additions & 11 deletions tests/swoole_global/channel_construct_check.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ swoole_global: socket construct check
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
go(function () {
$chan = new class () extends Co\Channel
{
public function __construct($size = 1)
{
// parent::__construct($size); // without parent call
}
};
$chan->push('123');

$pm = ProcessManager::exec(function () {
go(function () {
$chan = new class () extends Co\Channel {
public function __construct($size = 1)
{
// parent::__construct($size); // without parent call
}
};
$chan->push('123');
});
});
Assert::contains($pm->getChildOutput(), "must call constructor first");
?>
--EXPECTF--
Fatal error: Swoole\Coroutine\Channel::push(): you must call Channel constructor first in %s on line %d
--EXPECT--
21 changes: 11 additions & 10 deletions tests/swoole_global/socket_construct_check.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ swoole_global: socket construct check
--FILE--
<?php
require __DIR__ . '/../include/bootstrap.php';
go(function () {
$socket = new class (1, 2, 3) extends Co\Socket
{
public function __construct($domain, $type, $protocol)
{
// parent::__construct($domain, $type, $protocol); // without parent call
}
};
$socket->connect('127.0.0.1', 12345);
$pm = ProcessManager::exec(function () {
go(function () {
$socket = new class (1, 2, 3) extends Co\Socket {
public function __construct($domain, $type, $protocol)
{
// parent::__construct($domain, $type, $protocol); // without parent call
}
};
$socket->connect('127.0.0.1', 12345);
});
});
Assert::contains($pm->getChildOutput(), "must call constructor first");
?>
--EXPECTF--
Fatal error: Swoole\Coroutine\Socket::connect(): you must call Socket constructor first in %s on line %d
9 changes: 5 additions & 4 deletions tests/swoole_http2_client_coro/connect_twice.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ swoole_http2_client_coro: connect twice
<?php
require __DIR__ . '/../include/bootstrap.php';

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

Expand All @@ -14,19 +15,19 @@ run(function () {
$chan = new \Swoole\Coroutine\Channel(1);
go(function () use ($client, $chan) {
$client->connect();
$req = new \Swoole\Http2\Request();
$req = new Request();
$req->method = 'GET';
$req->path = '/io?io=' . str_repeat('xxx', 1000);
$client->send($req);
$chan->push(true);
$resp = $client->recv();
Assert::eq($resp->statusCode, 200);
Assert::contains($resp->data, '知乎');
Assert::eq($resp->statusCode, 302);
Assert::contains($resp->data, '302 Found');
$chan->pop();
});
go(function () use ($client, $chan) {
Assert::eq($client->connect(), false);
$req = new \Swoole\Http2\Request();
$req = new Request();
$req->method = 'GET';
$req->path = '/io?io=xxx';
$client->send($req);
Expand Down

0 comments on commit c19214a

Please sign in to comment.