Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

30
vendor/swoole/tests/swoole_serialize/001.phpt vendored Executable file
View File

@ -0,0 +1,30 @@
--TEST--
swoole_serialize: Check for null serialisation
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
class Obj {
var $a;
var $b;
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
};
$f = new Obj(1,2);
$unserialized = swoole_serialize::pack($f);
file_put_contents("/tmp/swoole_seria_test", $unserialized);
echo "OK"
?>
--EXPECT--
OK

29
vendor/swoole/tests/swoole_serialize/002.phpt vendored Executable file
View File

@ -0,0 +1,29 @@
--TEST--
swoole_serialize: Check for null serialisation
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('null', null);
?>
--EXPECT--
null
NULL
OK

34
vendor/swoole/tests/swoole_serialize/003.phpt vendored Executable file
View File

@ -0,0 +1,34 @@
--TEST--
swoole_serialize: Check for bool serialisation
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('bool true', true);
test('bool false', false);
?>
--EXPECT--
bool true
bool(true)
OK
bool false
bool(false)
OK

53
vendor/swoole/tests/swoole_serialize/004.phpt vendored Executable file
View File

@ -0,0 +1,53 @@
--TEST--
swoole_serialize: Check for integer serialisation
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('zero: 0', 0);
test('small: 1', 1);
test('small: -1', -1);
test('medium: 1000', 1000);
test('medium: -1000', -1000);
test('large: 100000', 100000);
test('large: -100000', -100000);
?>
--EXPECT--
zero: 0
int(0)
OK
small: 1
int(1)
OK
small: -1
int(-1)
OK
medium: 1000
int(1000)
OK
medium: -1000
int(-1000)
OK
large: 100000
int(100000)
OK
large: -100000
int(-100000)
OK

29
vendor/swoole/tests/swoole_serialize/005.phpt vendored Executable file
View File

@ -0,0 +1,29 @@
--TEST--
swoole_serialize: Check for double serialisation
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('double: 123.456', 123.456);
?>
--EXPECT--
double: 123.456
float(123.456)
OK

33
vendor/swoole/tests/swoole_serialize/006.phpt vendored Executable file
View File

@ -0,0 +1,33 @@
--TEST--
swoole_serialize: Check for simple string serialization
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized === $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('empty: ""', "");
test('string: "foobar"', "foobar");
?>
--EXPECT--
empty: ""
string(0) ""
OK
string: "foobar"
string(6) "foobar"
OK

73
vendor/swoole/tests/swoole_serialize/007.phpt vendored Executable file
View File

@ -0,0 +1,73 @@
--TEST--
swoole_serialize: Check for simple array serialization
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('empty array:', array());
test('array(1, 2, 3)', array(1, 2, 3));
test('array(array(1, 2, 3), arr...', array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)));
?>
--EXPECT--
empty array:
array(0) {
}
OK
array(1, 2, 3)
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
OK
array(array(1, 2, 3), arr...
array(3) {
[0]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[1]=>
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
[2]=>
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
}
OK

61
vendor/swoole/tests/swoole_serialize/008.phpt vendored Executable file
View File

@ -0,0 +1,61 @@
--TEST--
swoole_serialize: Check for array+string serialization
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
test('array("foo", "foo", "foo")', array("foo", "foo", "foo"));
test('array("one" => 1, "two" => 2))', array("one" => 1, "two" => 2));
test('array("kek" => "lol", "lol" => "kek")', array("kek" => "lol", "lol" => "kek"));
test('array("" => "empty")', array("" => "empty"));
?>
--EXPECT--
array("foo", "foo", "foo")
array(3) {
[0]=>
string(3) "foo"
[1]=>
string(3) "foo"
[2]=>
string(3) "foo"
}
OK
array("one" => 1, "two" => 2))
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}
OK
array("kek" => "lol", "lol" => "kek")
array(2) {
["kek"]=>
string(3) "lol"
["lol"]=>
string(3) "kek"
}
OK
array("" => "empty")
array(1) {
[""]=>
string(5) "empty"
}
OK

85
vendor/swoole/tests/swoole_serialize/009.phpt vendored Executable file
View File

@ -0,0 +1,85 @@
--TEST--
swoole_serialize: Check for reference serialization
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
ini_set("display_errors", "Off");
function test($type, $variable, $test) {
// $serialized = serialize($variable);
// $unserialized = unserialize($serialized);
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
$a = array('foo');
test('array($a, $a)', array($a, $a), false);
test('array(&$a, &$a)', array(&$a, &$a), false);
$a = [];
$b = array(&$a);
$a[0] = &$b;
test('cyclic', $a, true);
?>
--EXPECT--
array($a, $a)
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
array(&$a, &$a)
array(2) {
[0]=>
array(1) {
[0]=>
string(3) "foo"
}
[1]=>
array(1) {
[0]=>
string(3) "foo"
}
}
OK
cyclic
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(1) {
[0]=>
NULL
}
}
}
}
}
OK

52
vendor/swoole/tests/swoole_serialize/010.phpt vendored Executable file
View File

@ -0,0 +1,52 @@
--TEST--
swoole_serialize: Array test
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
$a = array(
'a' => array(
'b' => 'c',
'd' => 'e'
),
'f' => array(
'g' => 'h'
)
);
test('array', $a, false);
?>
--EXPECT--
array
array(2) {
["a"]=>
array(2) {
["b"]=>
string(1) "c"
["d"]=>
string(1) "e"
}
["f"]=>
array(1) {
["g"]=>
string(1) "h"
}
}
OK

51
vendor/swoole/tests/swoole_serialize/012.phpt vendored Executable file
View File

@ -0,0 +1,51 @@
--TEST--
swoole_serialize: Object test
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
public $a;
protected $b;
private $c;
function __construct($a, $b, $c) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
}
}
$o = new Obj(1, 2, 3);
test('object', $o, false);
?>
--EXPECTF--
object
object(Obj)#%d (3) {
["a"]=>
int(1)
[%r"?b"?:protected"?%r]=>
int(2)
[%r"?c"?:("Obj":)?private"?%r]=>
int(3)
}
OK

58
vendor/swoole/tests/swoole_serialize/013.phpt vendored Executable file
View File

@ -0,0 +1,58 @@
--TEST--
swoole_serialize: Object-Array test
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
var $a;
var $b;
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
}
$o = array(new Obj(1, 2), new Obj(3, 4));
test('object', $o, false);
?>
--EXPECTF--
object
array(2) {
[0]=>
object(Obj)#%d (2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
[1]=>
object(Obj)#%d (2) {
["a"]=>
int(3)
["b"]=>
int(4)
}
}
OK

58
vendor/swoole/tests/swoole_serialize/014.phpt vendored Executable file
View File

@ -0,0 +1,58 @@
--TEST--
swoole_serialize: Object-Reference test
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
var $a;
var $b;
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
}
$o = new Obj(1, 2);
$a = array(&$o, &$o);
test('object', $a, false);
?>
--EXPECTF--
object
array(2) {
[0]=>
object(Obj)#%d (2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
[1]=>
object(Obj)#%d (2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
}
OK

64
vendor/swoole/tests/swoole_serialize/016.phpt vendored Executable file
View File

@ -0,0 +1,64 @@
--TEST--
swoole_serialize: Object test, __sleep
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized == $variable ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
public $a;
protected $b;
private $c;
var $d;
function __construct($a, $b, $c, $d) {
$this->a = $a;
$this->b = $b;
$this->c = $c;
$this->d = $d;
}
function __sleep() {
return array('a', 'b', 'c');
}
# function __wakeup() {
# $this->d = $this->a + $this->b + $this->c;
# }
}
$o = new Obj(1, 2, 3, 4);
test('object', $o, true);
?>
--EXPECTF--
object
object(Obj)#%d (4) {
["a"]=>
int(1)
[%r"?b"?:protected"?%r]=>
int(2)
[%r"?c"?:("Obj":)?private"?%r]=>
int(3)
["d"]=>
NULL
}
OK

52
vendor/swoole/tests/swoole_serialize/017.phpt vendored Executable file
View File

@ -0,0 +1,52 @@
--TEST--
swoole_serialize: Object test, __wakeup
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized->b == 3 ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
var $a;
var $b;
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
function __wakeup() {
$this->b = $this->a * 3;
}
}
$o = new Obj(1, 2);
test('object', $o, false);
?>
--EXPECTF--
object
object(Obj)#%d (2) {
["a"]=>
int(1)
["b"]=>
int(3)
}
OK

48
vendor/swoole/tests/swoole_serialize/019.phpt vendored Executable file
View File

@ -0,0 +1,48 @@
--TEST--
swoole_serialize: Object test, __autoload
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
function test($type, $test) {
$serialized = file_get_contents("/tmp/swoole_seria_test");
$unserialized = swoole_serialize::unpack($serialized);
echo $type, PHP_EOL;
var_dump($unserialized);
echo $test || $unserialized->b == 2 ? 'OK' : 'ERROR', PHP_EOL;
}
spl_autoload_register(function ($classname) {
class Obj {
var $a;
var $b;
function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
}
});
test('autoload', false);
?>
--EXPECTF--
autoload
object(Obj)#%d (2) {
["a"]=>
int(1)
["b"]=>
int(2)
}
OK

48
vendor/swoole/tests/swoole_serialize/020.phpt vendored Executable file
View File

@ -0,0 +1,48 @@
--TEST--
swoole_serialize: Object test, stdclass
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
ini_set("display_errors", "Off");
function test($variable, $test) {
$serialized = swoole_serialize::pack($variable);
$unserialized = swoole_serialize::unpack($serialized, UNSERIALIZE_OBJECT_TO_STDCLASS);
echo UNSERIALIZE_OBJECT_TO_STDCLASS, PHP_EOL;
var_dump($unserialized);
echo get_class($unserialized->sub) == "stdClass" ? 'OK' : 'ERROR', PHP_EOL;
}
class Obj {
var $sub;
}
class subObj {
var $b = "sub";
}
$o = new Obj();
$o->sub = new subObj();
test($o, true);
?>
--EXPECTF--
2
object(stdClass)#4 (1) {
["sub"]=>
object(stdClass)#3 (1) {
["b"]=>
string(3) "sub"
}
}
OK

33
vendor/swoole/tests/swoole_serialize/021.phpt vendored Executable file
View File

@ -0,0 +1,33 @@
--TEST--
swoole_serialize: Object test, type undef
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
ini_set("display_errors", "Off");
class Foo
{
public $a = 'a';
}
$foo = new Foo();
$foo->a = 'b';
unset($foo->a);
$ser = swoole_serialize::pack($foo);
$bar = swoole_serialize::unpack($ser);
var_dump($bar);
?>
--EXPECTF--
object(Foo)#2 (1) {
["a"]=>
NULL
}

53
vendor/swoole/tests/swoole_serialize/022.phpt vendored Executable file
View File

@ -0,0 +1,53 @@
--TEST--
swoole_serialize: Object test, extends private
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
ini_set("display_errors", "Off");
abstract class AbstractAsyncTask
{
private $data = null;
public function __construct($data = null)
{
$this->data = $data;
}
public function getData()
{
return $this->data;
}
}
class test extends AbstractAsyncTask
{
}
$data = swoole_serialize::pack(new test('aaa'));
$a = swoole_serialize::unpack($data);
var_dump($a);
var_dump($a->getData());
?>
--EXPECTF--
object(test)#1 (1) {
["data":"AbstractAsyncTask":private]=>
string(3) "aaa"
}
string(3) "aaa"

53
vendor/swoole/tests/swoole_serialize/023.phpt vendored Executable file
View File

@ -0,0 +1,53 @@
--TEST--
swoole_serialize: Object test, extends protect
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
ini_set("display_errors", "Off");
abstract class AbstractAsyncTask
{
protected $data = null;
public function __construct($data = null)
{
$this->data = $data;
}
public function getData()
{
return $this->data;
}
}
class test extends AbstractAsyncTask
{
}
$data = swoole_serialize::pack(new test('aaa'));
$a = swoole_serialize::unpack($data);
var_dump($a);
var_dump($a->getData());
?>
--EXPECTF--
object(test)#1 (1) {
["data":protected]=>
string(3) "aaa"
}
string(3) "aaa"

View File

@ -0,0 +1,58 @@
--TEST--
swoole_serialize: pack & unpack
--SKIPIF--
<?php
require __DIR__ . '/../include/skipif.inc';
if (!class_exists("swoole_serialize", false))
{
echo "skip";
}
?>
--INI--
assert.active=1
assert.warning=1
assert.bail=0
assert.quiet_eval=0
--FILE--
<?php
require_once __DIR__ . '/../include/bootstrap.php';
// int
$int_data = mt_rand(100, 999);
$data = swoole_serialize::pack($int_data);
$un_data = swoole_serialize::unpack($data);
assert($int_data == $un_data);
// long
$long_data = mt_rand(100000000000, 999999999999);
$data = swoole_serialize::pack($long_data);
$un_data = swoole_serialize::unpack($data);
assert($long_data == $un_data);
// string
$str_data = str_repeat('bcy', 10);
$data = swoole_serialize::pack($str_data);
$un_data = swoole_serialize::unpack($data);
assert($str_data == $un_data);
// array
$arr_data = array_pad([], 32, '0123456789abcdefghijklmnopqrstuvwxyz');
$data = swoole_serialize::pack($arr_data);
$un_data = swoole_serialize::unpack($data);
assert($arr_data == $un_data);
// large array
$large_arr_data = array_pad([], 4096, '0123456789abcdefghijklmnopqrstuvwxyz');
$data = swoole_serialize::pack($large_arr_data);
$un_data = swoole_serialize::unpack($data);
assert($large_arr_data == $un_data);
// error array data
$data_out = substr($data, 0, 8192);
$err_data = @swoole_serialize::unpack($data_out);
assert($err_data == false);
?>
DONE
--EXPECTF--
DONE