extesion deps
[m6w6/ext-http] / tests / factory.phpt
index f28eda77c498070fdea5bb8539b5ca3bfc821866..64969132757aa4be3b54f3aaddaa5e6b2cd0d76f 100644 (file)
@@ -3,45 +3,69 @@ factory
 --SKIPIF--
 <?php
 include "skipif.inc";
-in_array("curl", http\request\Factory::getAvailableDrivers()) or die ("skip CURL support missing");
+in_array("curl", http\Client\Factory::getAvailableDrivers()) or die ("skip CURL support missing");
 ?>
 --FILE--
 <?php
 echo "Test\n";
 
-class MyRequest extends http\Request {}
-class MyPool extends http\request\Pool {}
-class MyShare extends http\request\DataShare {}
+class MyClient extends http\Curl\Client {}
+class MyPool extends http\Curl\Client\Pool {}
+class MyShare extends http\Curl\Client\DataShare {}
   
-class MyFactory extends http\request\Factory {
+class MyFactory extends http\Client\Factory {
        protected $driver = "curl";
        protected $persistentHandleId = "My";
-       protected $requestClass = "MyRequest";
-       protected $requestPoolClass = "MyPool";
-       protected $requestDataShareClass = "MyShare";
+       protected $clientClass = "MyClient";
+       protected $clientPoolClass = "MyPool";
+       protected $clientDataShareClass = "MyShare";
        
        protected $dummy = "foo";
 }
 
 $f = new MyFactory(array("driver" => "curl"));
-$r = $f->createRequest();
+$r = $f->createClient();
 $p = $f->createPool();
 $s = $f->createDataShare();
 
-var_dump(array_map("get_class", array($f,$r,$p,$s)));
+$r->setRequest(new http\Client\Request("GET", "http://localhost/"));
+$x = $f->createPool($r);
+$y = $f->createDatashare($r);
+
+var_dump(
+       array_map("get_class", array($f,$r,$p,$s,$x,$y)), 
+       $f->getDriver()
+);
+
+foreach (array("Client", "Pool", "DataShare") as $type) {
+       try {
+               $f = new http\Client\Factory(array("driver" => "nonexistant"));
+               var_dump($f->{"create$type"}());
+       } catch (Exception $e) {
+               echo $e->getMessage(), "\n";
+       }
+}
 
 echo "Done\n";
 ?>
 --EXPECTF--
 Test
-array(4) {
+array(6) {
   [0]=>
   string(9) "MyFactory"
   [1]=>
-  string(9) "MyRequest"
+  string(8) "MyClient"
   [2]=>
   string(6) "MyPool"
   [3]=>
   string(7) "MyShare"
+  [4]=>
+  string(6) "MyPool"
+  [5]=>
+  string(7) "MyShare"
 }
+string(4) "curl"
+clients are not supported by this driver
+pools are not supported by this driver
+datashares are not supported by this driver
 Done