From f6f642fe8923885b0ad25ca97be20a72fc9a539c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 15 Nov 2013 10:22:38 +0100 Subject: [PATCH] add pecl/http-v2 tests; release 1.0.3 --- package.xml | 12 +++-- tests/http001.phpt | 85 ++++++++++++++++++++++++++++++++++ tests/http002.phpt | 71 ++++++++++++++++++++++++++++ tests/http003.phpt | 77 ++++++++++++++++++++++++++++++ tests/http004.phpt | 113 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 355 insertions(+), 3 deletions(-) create mode 100644 tests/http001.phpt create mode 100644 tests/http002.phpt create mode 100644 tests/http003.phpt create mode 100644 tests/http004.phpt diff --git a/package.xml b/package.xml index a9798a3..2eac6d7 100644 --- a/package.xml +++ b/package.xml @@ -19,9 +19,9 @@ http://pear.php.net/dtd/package-2.0.xsd"> mike@php.net yes - 2013-08-20 + 2013-11-15 - 1.0.2 + 1.0.3 1.0.0 @@ -30,7 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> BSD, revised @@ -39,6 +39,12 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + + + + diff --git a/tests/http001.phpt b/tests/http001.phpt new file mode 100644 index 0000000..a28d8e1 --- /dev/null +++ b/tests/http001.phpt @@ -0,0 +1,85 @@ +--TEST-- +pecl/http-v2 - general and stat +--SKIPIF-- + +--FILE-- +enqueue(new http\Client\Request("GET", "http://php.net")); +} while (count($c) < 3); + +var_dump(raphf\stat_persistent_handles()); + +unset($c); + +var_dump(raphf\stat_persistent_handles()); + +?> +Done +--EXPECTF-- +Test +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(0) { + } + ["http\Client\Curl\Request"]=> + array(0) { + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(1) + ["free"]=> + int(0) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(3) + ["free"]=> + int(0) + } + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(1) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(3) + } + } +} +Done diff --git a/tests/http002.phpt b/tests/http002.phpt new file mode 100644 index 0000000..99d7260 --- /dev/null +++ b/tests/http002.phpt @@ -0,0 +1,71 @@ +--TEST-- +pecl/http-v2 - clean with name and id +--SKIPIF-- + +--FILE-- +enqueue(new http\Client\Request("GET", "http://php.net")); +} while (count($c) < 3); + +unset($c); + +var_dump(raphf\stat_persistent_handles()); + +raphf\clean_persistent_handles("http\\Client\\Curl"); +raphf\clean_persistent_handles("http\\Client\\Curl\\Request", "php.net:80"); + +var_dump(raphf\stat_persistent_handles()); + +?> +Done +--EXPECTF-- +Test +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(1) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(3) + } + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(0) { + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(0) + } + } +} +Done diff --git a/tests/http003.phpt b/tests/http003.phpt new file mode 100644 index 0000000..996f4d7 --- /dev/null +++ b/tests/http003.phpt @@ -0,0 +1,77 @@ +--TEST-- +pecl/http-v2 - clean with id only +--SKIPIF-- + +--FILE-- +enqueue(new http\Client\Request("GET", "http://php.net")); +} while (count($c) < 3); + +unset($c); + +var_dump(raphf\stat_persistent_handles()); + +raphf\clean_persistent_handles(null, "php.net:80"); + +var_dump(raphf\stat_persistent_handles()); + +?> +Done +--EXPECTF-- +Test +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(1) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(3) + } + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(0) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(0) + ["free"]=> + int(0) + } + } +} +Done diff --git a/tests/http004.phpt b/tests/http004.phpt new file mode 100644 index 0000000..0c47c7b --- /dev/null +++ b/tests/http004.phpt @@ -0,0 +1,113 @@ +--TEST-- +pecl/http-v2 - partial clean +--SKIPIF-- + +--FILE-- +enqueue(new http\Client\Request("GET", "http://php.net")); + $c2->enqueue(new http\Client\Request("GET", "http://php.net")); +} while (count($c) < 3); + +var_dump(raphf\stat_persistent_handles()); + +unset($c); + +var_dump(raphf\stat_persistent_handles()); + +raphf\clean_persistent_handles(); + +var_dump(raphf\stat_persistent_handles()); + +?> +Done +--EXPECTF-- +Test +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(0) { + } + ["http\Client\Curl\Request"]=> + array(0) { + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(2) + ["free"]=> + int(0) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(6) + ["free"]=> + int(0) + } + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(1) + ["free"]=> + int(1) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(3) + ["free"]=> + int(3) + } + } +} +object(stdClass)#%d (2) { + ["http\Client\Curl"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(1) + ["free"]=> + int(0) + } + } + ["http\Client\Curl\Request"]=> + array(1) { + ["php.net:80"]=> + array(2) { + ["used"]=> + int(3) + ["free"]=> + int(0) + } + } +} +Done -- 2.30.2