mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
- Add more tests
This commit is contained in:
parent
617de19912
commit
3cdd2bcb01
4 changed files with 101 additions and 0 deletions
44
ext/standard/tests/serialize/002.phpt
Normal file
44
ext/standard/tests/serialize/002.phpt
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #25378 (unserialize() crashes with invalid data)
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
var_dump(unserialize('b:0;'));
|
||||||
|
var_dump(unserialize('b:1;'));
|
||||||
|
var_dump(unserialize('i:823;'));
|
||||||
|
var_dump(unserialize('s:0:"";'));
|
||||||
|
var_dump(unserialize('s:3:"foo";'));
|
||||||
|
var_dump(unserialize('a:1:{i:0;s:2:"12";}'));
|
||||||
|
var_dump(unserialize('a:2:{i:0;a:0:{}i:1;a:0:{}}'));
|
||||||
|
var_dump(unserialize('a:3:{i:0;s:3:"foo";i:1;s:3:"bar";i:2;s:3:"baz";}'));
|
||||||
|
var_dump(unserialize('O:8:"stdClass":0:{}'));
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
bool(false)
|
||||||
|
bool(true)
|
||||||
|
int(823)
|
||||||
|
string(0) ""
|
||||||
|
string(3) "foo"
|
||||||
|
array(1) {
|
||||||
|
[0]=>
|
||||||
|
string(2) "12"
|
||||||
|
}
|
||||||
|
array(2) {
|
||||||
|
[0]=>
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
[1]=>
|
||||||
|
array(0) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
array(3) {
|
||||||
|
[0]=>
|
||||||
|
string(3) "foo"
|
||||||
|
[1]=>
|
||||||
|
string(3) "bar"
|
||||||
|
[2]=>
|
||||||
|
string(3) "baz"
|
||||||
|
}
|
||||||
|
object(stdClass)#%d (0) {
|
||||||
|
}
|
||||||
|
===DONE===
|
10
ext/standard/tests/serialize/autoload_implements.p5c
Executable file
10
ext/standard/tests/serialize/autoload_implements.p5c
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class autoload_implements implements autoload_interface {
|
||||||
|
function testFunction()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
7
ext/standard/tests/serialize/autoload_interface.p5c
Executable file
7
ext/standard/tests/serialize/autoload_interface.p5c
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
interface autoload_interface {
|
||||||
|
function testFunction();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
40
ext/standard/tests/serialize/bug30234.phpt
Executable file
40
ext/standard/tests/serialize/bug30234.phpt
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
--TEST--
|
||||||
|
#30234 (__autoload() not invoked for interfaces)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (class_exists('autoload_root', false)) die('skip Autoload test classes exist already');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function __autoload($class_name)
|
||||||
|
{
|
||||||
|
require_once(dirname(__FILE__) . '/' . strtolower($class_name) . '.p5c');
|
||||||
|
echo __FUNCTION__ . '(' . $class_name . ")\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
var_dump(interface_exists('autoload_interface', false));
|
||||||
|
var_dump(class_exists('autoload_implements', false));
|
||||||
|
|
||||||
|
$o = unserialize('O:19:"Autoload_Implements":0:{}');
|
||||||
|
|
||||||
|
var_dump($o);
|
||||||
|
var_dump($o instanceof autoload_interface);
|
||||||
|
unset($o);
|
||||||
|
|
||||||
|
var_dump(interface_exists('autoload_interface', false));
|
||||||
|
var_dump(class_exists('autoload_implements', false));
|
||||||
|
|
||||||
|
?>
|
||||||
|
===DONE===
|
||||||
|
--EXPECTF--
|
||||||
|
bool(false)
|
||||||
|
bool(false)
|
||||||
|
__autoload(autoload_interface)
|
||||||
|
__autoload(Autoload_Implements)
|
||||||
|
object(autoload_implements)#%d (0) {
|
||||||
|
}
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
||||||
|
===DONE===
|
Loading…
Add table
Add a link
Reference in a new issue