Skip to content

Commit

Permalink
fix tests for PHP-master
Browse files Browse the repository at this point in the history
  • Loading branch information
m6w6 committed Aug 27, 2024
1 parent 62d6ead commit d857a92
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion tests/client002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "Test\n";
class Observer implements SplObserver
{
#[ReturnTypeWillChange]
function update(SplSubject $client, http\Client\Request $request = null, StdClass $progress = null) {
function update(SplSubject $client, ?http\Client\Request $request = null, ?StdClass $progress = null) {
echo "P";
/* fence against buggy infof() calls in some curl versions */
$compare = $client->getProgressInfo($request);
Expand Down
42 changes: 21 additions & 21 deletions tests/client028.phpt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
--TEST--
client curl user handler
--SKIPIF--
<?php
<?php
include "skipif.inc";
skip_client_test();
?>
?>
--FILE--
<?php
<?php
echo "Test\n";

class UserHandler implements http\Client\Curl\User
Expand All @@ -20,23 +20,23 @@ class UserHandler implements http\Client\Curl\User
private $R = array();
private $W = array();
private $timeout = 1000;

function __construct(http\Client $client) {
$this->client = $client;
}

function init($run) {
$this->run = $run;
}

function timer(int $timeout_ms) {
echo "T";
$this->timeout = $timeout_ms;
}

function socket($socket, int $action) {
echo "S";

switch ($action) {
case self::POLL_NONE:
break;
Expand All @@ -45,14 +45,14 @@ class UserHandler implements http\Client\Curl\User
echo "U";
unset($this->fds["R"][$r]);
}

if (false !== ($w = array_search($socket, $this->fds["W"], true))) {
echo "U";
unset($this->fds["W"][$w]);
}

break;

default:
if ($action & self::POLL_IN) {
if (!in_array($socket, $this->fds["R"], true)) {
Expand All @@ -67,10 +67,10 @@ class UserHandler implements http\Client\Curl\User
break;
}
}

function once() {
echo "O";

foreach ($this->W as $w) {
call_user_func($this->run, $this->client, $w, self::POLL_OUT);
}
Expand All @@ -79,26 +79,26 @@ class UserHandler implements http\Client\Curl\User
}
return count($this->client);
}
function wait(int $timeout_ms = null) {

function wait(?int $timeout_ms = null) {
echo "W";

if ($timeout_ms === null) {
$timeout_ms = $this->timeout;
}
$ts = floor($timeout_ms / 1000);
$tu = ($timeout_ms % 1000) * 1000;

extract($this->fds);

if (($wfds = count($R) + count($W))) {
$nfds = stream_select($R, $W, $E, $ts, $tu);
} else {
$nfds = 0;
}
$this->R = (array) $R;
$this->W = (array) $W;

if ($nfds === false) {
return false;
}
Expand All @@ -109,10 +109,10 @@ class UserHandler implements http\Client\Curl\User
}
call_user_func($this->run, $this->client);
}

return true;
}

function send() {
$this->wait();
$this->once();
Expand Down
12 changes: 6 additions & 6 deletions tests/info002.phpt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
--TEST--
invalid HTTP info
--SKIPIF--
<?php
<?php
include "skipif.inc";
?>
--INI--
zend.exception_ignore_args=off
--FILE--
<?php
<?php

echo "Test\n";

function trap($cb) {
try {
$cb();
} catch (Exception $e) {
echo $e,"\n";
} catch (Exception $e) {
echo $e,"\n";
}
}

Expand All @@ -37,13 +37,13 @@ Test
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\057' at pos 4 of 'HTTP/1.1 99 Apples in my Basket' in %sinfo002.php:%d
Stack trace:
#0 %sinfo002.php(%d): http\Message->__construct('HTTP/1.1 99 App...')
#1 %sinfo002.php(%d): {closure}()
#1 %sinfo002.php(%d): {closure%s}()
#2 %sinfo002.php(%d): trap(Object(Closure))
#3 {main}
http\Exception\BadMessageException: http\Message::__construct(): Failed to parse headers: unexpected character '\040' at pos 7 of 'CONNECT HTTP/1.1' in %sinfo002.php:%d
Stack trace:
#0 %sinfo002.php(%d): http\Message->__construct('CONNECT HTTP/1....')
#1 %sinfo002.php(%d): {closure}()
#1 %sinfo002.php(%d): {closure%s}()
#2 %sinfo002.php(%d): trap(Object(Closure))
#3 {main}
HTTP/1.1 200
Expand Down

0 comments on commit d857a92

Please sign in to comment.