diff options
Diffstat (limited to 'ext/pdo_dblib/tests')
-rw-r--r-- | ext/pdo_dblib/tests/bug_38955.phpt | 57 | ||||
-rw-r--r-- | ext/pdo_dblib/tests/bug_45876.phpt | 35 | ||||
-rw-r--r-- | ext/pdo_dblib/tests/bug_47588.phpt | 45 | ||||
-rw-r--r-- | ext/pdo_dblib/tests/bug_50755.phpt | 29 | ||||
-rw-r--r-- | ext/pdo_dblib/tests/config.inc | 26 |
5 files changed, 192 insertions, 0 deletions
diff --git a/ext/pdo_dblib/tests/bug_38955.phpt b/ext/pdo_dblib/tests/bug_38955.phpt new file mode 100644 index 0000000..1954ed4 --- /dev/null +++ b/ext/pdo_dblib/tests/bug_38955.phpt @@ -0,0 +1,57 @@ +--TEST-- + PDO_DBLIB driver does not support transactions +--SKIPIF-- +<?php +if (!extension_loaded('pdo_dblib')) die('skip not loaded'); +require dirname(__FILE__) . '/config.inc'; +?> +--FILE-- +<?php +require dirname(__FILE__) . '/config.inc'; + +/*We see these rows */ +$db->query("CREATE table php_test(val int)"); +$db->beginTransaction(); +$db->query("INSERT INTO php_test(val) values(1)"); +$db->query("INSERT INTO php_test(val) values(2)"); +$db->query("INSERT INTO php_test(val) values(3)"); +$db->query("INSERT INTO php_test(val) values(4)"); +$db->commit(); + +/*We don't see these rows */ +$db->beginTransaction(); +$db->query("INSERT INTO php_test(val) values(5)"); +$db->query("INSERT INTO php_test(val) values(6)"); +$db->query("INSERT INTO php_test(val) values(7)"); +$db->query("INSERT INTO php_test(val) values(8)"); +$db->rollback(); + +$rs = $db->query("SELECT * FROM php_test"); +$rows = $rs->fetchAll(PDO::FETCH_ASSOC); +var_dump($rows); + +$db->query("DROP table php_test"); +?> +--EXPECT-- +array(4) { + [0]=> + array(1) { + ["val"]=> + string(1) "1" + } + [1]=> + array(1) { + ["val"]=> + string(1) "2" + } + [2]=> + array(1) { + ["val"]=> + string(1) "3" + } + [3]=> + array(1) { + ["val"]=> + string(1) "4" + } +} diff --git a/ext/pdo_dblib/tests/bug_45876.phpt b/ext/pdo_dblib/tests/bug_45876.phpt new file mode 100644 index 0000000..9209058 --- /dev/null +++ b/ext/pdo_dblib/tests/bug_45876.phpt @@ -0,0 +1,35 @@ +--TEST-- +PDO_DBLIB: Does not support get column meta +--SKIPIF-- +<?php +if (!extension_loaded('pdo_dblib')) die('skip not loaded'); +require dirname(__FILE__) . '/config.inc'; +?> +--FILE-- +<?php +require dirname(__FILE__) . '/config.inc'; + +$stmt = $db->prepare("select ic1.* from information_schema.columns ic1"); +$stmt->execute(); +var_dump($stmt->getColumnMeta(0)); +$stmt = null; +?> +--EXPECT-- +array(8) { + ["max_length"]=> + int(255) + ["precision"]=> + int(0) + ["scale"]=> + int(0) + ["column_source"]=> + string(13) "TABLE_CATALOG" + ["native_type"]=> + string(4) "char" + ["name"]=> + string(13) "TABLE_CATALOG" + ["len"]=> + int(255) + ["pdo_type"]=> + int(2) +} diff --git a/ext/pdo_dblib/tests/bug_47588.phpt b/ext/pdo_dblib/tests/bug_47588.phpt new file mode 100644 index 0000000..d8f424e --- /dev/null +++ b/ext/pdo_dblib/tests/bug_47588.phpt @@ -0,0 +1,45 @@ +--TEST-- +PDO_DBLIB: Quoted field names +--SKIPIF-- +<?php +if (!extension_loaded('pdo_dblib')) die('skip not loaded'); +require dirname(__FILE__) . '/config.inc'; +?> +--FILE-- +<?php +require dirname(__FILE__) . '/config.inc'; + +$db->query('CREATE TABLE "Test Table" ("My Field" int, "Another Field" varchar(32) not null default \'test_string\')'); +$db->query('INSERT INTO "Test Table" ("My Field") values(1)'); +$db->query('INSERT INTO "Test Table" ("My Field") values(2)'); +$db->query('INSERT INTO "Test Table" ("My Field") values(3)'); +$rs = $db->query('SELECT * FROM "Test Table"'); +var_dump($rs->fetchAll(PDO::FETCH_ASSOC)); +$db->query('DROP TABLE "Test Table"'); +echo "Done.\n"; +?> +--EXPECT-- +array(3) { + [0]=> + array(2) { + ["My Field"]=> + string(1) "1" + ["Another Field"]=> + string(11) "test_string" + } + [1]=> + array(2) { + ["My Field"]=> + string(1) "2" + ["Another Field"]=> + string(11) "test_string" + } + [2]=> + array(2) { + ["My Field"]=> + string(1) "3" + ["Another Field"]=> + string(11) "test_string" + } +} +Done. diff --git a/ext/pdo_dblib/tests/bug_50755.phpt b/ext/pdo_dblib/tests/bug_50755.phpt new file mode 100644 index 0000000..95d1a8b --- /dev/null +++ b/ext/pdo_dblib/tests/bug_50755.phpt @@ -0,0 +1,29 @@ +--TEST-- +PDO_DBLIB: Out of memory on large recordsets +--SKIPIF-- +<?php +if (!extension_loaded('pdo_dblib')) die('skip not loaded'); +require dirname(__FILE__) . '/config.inc'; +?> +--FILE-- +<?php +require dirname(__FILE__) . '/config.inc'; + +/* This should be sufficient to overflow any buffers */ +$stmt = $db->prepare("select * +from information_schema.columns ic1 +cross join information_schema.columns ic2 +cross join information_schema.columns ic3"); + +$x = $stmt->execute(); +$n = 0; +while (($r = $stmt->fetch())) { + $n++; +} +$stmt = null; + +echo "OK\n"; + +?> +--EXPECT-- +OK diff --git a/ext/pdo_dblib/tests/config.inc b/ext/pdo_dblib/tests/config.inc new file mode 100644 index 0000000..5b7b4d4 --- /dev/null +++ b/ext/pdo_dblib/tests/config.inc @@ -0,0 +1,26 @@ +<?php + +if (false !== getenv('PDO_DBLIB_TEST_DSN')) + $dsn = getenv('PDO_DBLIB_TEST_DSN'); +else + $dsn = 'dblib:host=localhost;dbname=test'; + +if (false !== getenv('PDO_DBLIB_TEST_USER')) + $user = getenv('PDO_DBLIB_TEST_USER'); +else + $user = 'php'; + + +if (false !== getenv('PDO_DBLIB_TEST_PASS')) + $pass = getenv('PDO_DBLIB_TEST_PASS'); +else + $pass = 'password'; + +try { + $db = new PDO($dsn, $user, $pass); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); +} catch (PDOException $e) { + die('skip ' . $e->getMessage()); +} +?> |