xref: /php-src/ext/pdo/tests/pecl_bug_5217.phpt (revision f4a5db3e)
1--TEST--
2PDO Common: PECL Bug #5217 (serialize/unserialize safety)
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
16$db = PDOTest::factory();
17try {
18    $ser = serialize($db);
19    debug_zval_dump($ser);
20    $db = unserialize($ser);
21    $db->exec('CREATE TABLE test5217 (id int NOT NULL PRIMARY KEY, val VARCHAR(10))');
22} catch (Exception $e) {
23    echo "Safely caught " . $e->getMessage() . "\n";
24}
25
26echo "PHP Didn't crash!\n";
27?>
28--CLEAN--
29<?php
30require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
31$db = PDOTest::factory();
32PDOTest::dropTableIfExists($db, "test5217");
33?>
34--EXPECT--
35Safely caught Serialization of 'PDO' is not allowed
36PHP Didn't crash!
37