2e06afe4f7c3bde0109b000172d8bef2f08ca581
[m6w6/ext-http] / tests / serialize001.phpt
1 --TEST--
2 serialization
3 --SKIPIF--
4 <?php include "skipif.inc"; ?>
5 --FILE--
6 <?php
7
8 class Client extends \http\Client\AbstractClient
9 {
10 function __construct() {
11 parent::__construct();
12 $this->request = new \http\Client\Request("GET", "http://localhost");
13 }
14 function send($request) {
15 }
16 }
17
18 $ext = new ReflectionExtension("http");
19 foreach ($ext->getClasses() as $class) {
20 if ($class->isInstantiable()) {
21 #printf("%s\n", $class->getName());
22 $instance = $class->newInstance();
23 $serialized = serialize($instance);
24 $unserialized = unserialize($serialized);
25
26 foreach (["toString", "toArray"] as $m) {
27 if ($class->hasMethod($m)) {
28 #printf("%s#%s\n", $class->getName(), $m);
29 $unserialized->$m();
30 }
31 }
32 if ($class->hasMethod("attach") && !$class->implementsInterface("\\SplSubject")) {
33 #printf("%s#%s\n", $class->getName(), "attach");
34 $unserialized->attach((new http\Curl\Client)->setRequest(new http\Client\Request("GET", "http://localhost")));
35 }
36 }
37 }
38 ?>
39 DONE
40 --EXPECTF--
41 DONE