xref: /PHP-5.6/ext/pdo/tests/pecl_bug_5217.phpt (revision 1f655451)
1--TEST--
2PDO Common: PECL Bug #5217 (serialize/unserialze safety)
3--SKIPIF--
4<?php # vim:ft=php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8require_once $dir . 'pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15$db = PDOTest::factory();
16try {
17	$ser = serialize($db);
18	debug_zval_dump($ser);
19	$db = unserialize($ser);
20	$db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(10))');
21} catch (Exception $e) {
22	echo "Safely caught " . $e->getMessage() . "\n";
23}
24
25echo "PHP Didn't crash!\n";
26?>
27--EXPECT--
28Safely caught You cannot serialize or unserialize PDO instances
29PHP Didn't crash!
30