diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_empty_filename.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_empty_filename.phpt new file mode 100644 index 0000000000000..8e474feabd30d --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_empty_filename.phpt @@ -0,0 +1,20 @@ +--TEST-- +PDO_sqlite: Testing empty filename +--EXTENSIONS-- +pdo_sqlite +--FILE-- +exec('CREATE TABLE test1 (id INT);')); + +// create with empty URI +$db = new PDO('sqlite:file:?cache=shared'); + +var_dump($db->exec('CREATE TABLE test1 (id INT);')); +?> +--EXPECT-- +int(0) +int(0) diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_filename_uri.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_filename_uri.phpt index a5d588c6b8709..b972be27cfbf2 100644 --- a/ext/pdo_sqlite/tests/pdo_sqlite_filename_uri.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_filename_uri.phpt @@ -5,6 +5,16 @@ pdo_sqlite --FILE-- exec('CREATE TABLE test1 (id INT);')); + +// create second connection to in-memory database +$db = new PDO('sqlite:file::memory:?cache=shared'); + +var_dump($db->exec('SELECT * from test1')); + // create with default read-write|create mode $filename = "file:" . __DIR__ . DIRECTORY_SEPARATOR . "pdo_sqlite_filename_uri.db"; @@ -29,6 +39,8 @@ if (file_exists($filename)) { ?> --EXPECTF-- int(0) +int(0) +int(0) Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in %s Stack trace: diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_open_basedir.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_open_basedir.phpt new file mode 100644 index 0000000000000..425d2190234bd --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_open_basedir.phpt @@ -0,0 +1,47 @@ +--TEST-- +PDO_sqlite: Testing filenames with open_basedir +--EXTENSIONS-- +pdo_sqlite +--INI-- +open_basedir=. +--FILE-- +exec('CREATE TABLE test1 (id INT);')); + +// create outside basedir +$filename = '..' . DIRECTORY_SEPARATOR . 'pdo_sqlite_filename.db'; + +new PDO('sqlite:' . $filename); +?> + +--CLEAN-- + +--EXPECTF-- +int(0) + +Fatal error: Uncaught PDOException: PDO::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s:%d +Stack trace: +%s +#1 {main} + +Next PDOException: open_basedir prohibits opening %s in %s:%d +Stack trace: +%s +#1 {main} + thrown in %s diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_open_basedir_uri.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_open_basedir_uri.phpt new file mode 100644 index 0000000000000..7525ae34a8e86 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_open_basedir_uri.phpt @@ -0,0 +1,32 @@ +--TEST-- +PDO_sqlite: Testing URIs with open_basedir +--EXTENSIONS-- +pdo_sqlite +--INI-- +open_basedir={TMP} +--FILE-- + + +--CLEAN-- + +--EXPECTF-- +Fatal error: Uncaught PDOException: open_basedir prohibits opening %s in %s:%d +Stack trace: +%s +#1 {main} + thrown in %s