add pecl/http-v2 tests; release 1.0.3
authorMichael Wallner <mike@php.net>
Fri, 15 Nov 2013 09:22:38 +0000 (10:22 +0100)
committerMichael Wallner <mike@php.net>
Fri, 15 Nov 2013 09:22:38 +0000 (10:22 +0100)
package.xml
tests/http001.phpt [new file with mode: 0644]
tests/http002.phpt [new file with mode: 0644]
tests/http003.phpt [new file with mode: 0644]
tests/http004.phpt [new file with mode: 0644]

index a9798a3b223e6392e335b50dc5f292653bb6c350..2eac6d7ffa1f01d3b461c392316d10763b5474a2 100644 (file)
@@ -19,9 +19,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2013-08-20</date>
+ <date>2013-11-15</date>
  <version>
-  <release>1.0.2</release>
+  <release>1.0.3</release>
   <api>1.0.0</api>
  </version>
  <stability>
@@ -30,7 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
-* Fixed ZTS shutdown crash
+* Added pecl/http-v2 tests
 ]]></notes>
  <contents>
   <dir name="/">
@@ -39,6 +39,12 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <file role="src" name="config.m4" />
    <file role="src" name="php_raphf.h" />
    <file role="src" name="php_raphf.c" />
+   <dir name="tests">
+    <file role="test" name="http001.phpt" />
+    <file role="test" name="http002.phpt" />
+    <file role="test" name="http003.phpt" />
+    <file role="test" name="http004.phpt" />
+   </dir>
   </dir>
  </contents>
  <dependencies>
diff --git a/tests/http001.phpt b/tests/http001.phpt
new file mode 100644 (file)
index 0000000..a28d8e1
--- /dev/null
@@ -0,0 +1,85 @@
+--TEST--
+pecl/http-v2 - general and stat
+--SKIPIF--
+<?php
+if (!extension_loaded("http")) {
+       die("skip pecl/http needed");
+}
+if (!class_exists("http\\Client", false)) {
+       die("skip pecl/http-v2 with curl support needed");
+}
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+var_dump(raphf\stat_persistent_handles());
+
+$c = new http\Client("curl", "php.net:80");
+do {
+       $c->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 (file)
index 0000000..99d7260
--- /dev/null
@@ -0,0 +1,71 @@
+--TEST--
+pecl/http-v2 - clean with name and id
+--SKIPIF--
+<?php
+if (!extension_loaded("http")) {
+       die("skip pecl/http needed");
+}
+if (!class_exists("http\\Client", false)) {
+       die("skip pecl/http-v2 with curl support needed");
+}
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$c = new http\Client("curl", "php.net:80");
+do {
+       $c->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 (file)
index 0000000..996f4d7
--- /dev/null
@@ -0,0 +1,77 @@
+--TEST--
+pecl/http-v2 - clean with id only
+--SKIPIF--
+<?php
+if (!extension_loaded("http")) {
+       die("skip pecl/http needed");
+}
+if (!class_exists("http\\Client", false)) {
+       die("skip pecl/http-v2 with curl support needed");
+}
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+$c = new http\Client("curl", "php.net:80");
+do {
+       $c->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 (file)
index 0000000..0c47c7b
--- /dev/null
@@ -0,0 +1,113 @@
+--TEST--
+pecl/http-v2 - partial clean
+--SKIPIF--
+<?php
+if (!extension_loaded("http")) {
+       die("skip pecl/http needed");
+}
+if (!class_exists("http\\Client", false)) {
+       die("skip pecl/http-v2 with curl support needed");
+}
+?>
+--FILE--
+<?php
+echo "Test\n";
+
+var_dump(raphf\stat_persistent_handles());
+
+$c = new http\Client("curl", "php.net:80");
+$c2 = new http\Client("curl", "php.net:80");
+do {
+       $c->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