From: Marcus Boerger Date: Sat, 19 Feb 2005 21:50:46 +0000 (+0000) Subject: - Update/Add tests X-Git-Tag: RELEASE_0_3~333 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fee3962b09dcee3daf625e305d8fccff750159c;p=php - Update/Add tests --- diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt index 0a3dfbf089..86c9ce8636 100755 --- a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt @@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_ASSOC)); ===DONE=== --EXPECT-- -array(4) { +array(3) { [0]=> array(2) { ["id"]=> @@ -42,12 +42,5 @@ array(4) { ["val"]=> string(1) "C" } - [3]=> - array(2) { - ["id"]=> - string(1) "4" - ["val"]=> - string(1) "D" - } } ===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt index 187085a9f6..227f738df7 100755 --- a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt @@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_NUM)); ===DONE=== --EXPECT-- -array(4) { +array(3) { [0]=> array(2) { [0]=> @@ -42,12 +42,5 @@ array(4) { [1]=> string(1) "C" } - [3]=> - array(2) { - [0]=> - string(1) "4" - [1]=> - string(1) "D" - } } ===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt index 82d9b37e1a..e7cffae940 100755 --- a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt +++ b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt @@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_BOTH)); ===DONE=== --EXPECT-- -array(4) { +array(3) { [0]=> array(4) { ["id"]=> @@ -54,16 +54,5 @@ array(4) { [1]=> string(1) "C" } - [3]=> - array(4) { - ["id"]=> - string(1) "4" - [0]=> - string(1) "4" - ["val"]=> - string(1) "D" - [1]=> - string(1) "D" - } } ===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt new file mode 100755 index 0000000000..2e6e93d920 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt @@ -0,0 +1,46 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_OBJ +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, "A")'); +$db->exec('INSERT INTO test VALUES(2, "B")'); +$db->exec('INSERT INTO test VALUES(3, "C")'); + +$stmt = $db->query('SELECT * FROM test'); + +var_dump($stmt->fetchAll(PDO_FETCH_OBJ)); +?> +===DONE=== + +--EXPECTF-- +array(3) { + [0]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt new file mode 100755 index 0000000000..9ea9e2b00b --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt @@ -0,0 +1,122 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_CLASS +--SKIPIF-- + +--FILE-- +exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, "A")'); +$db->exec('INSERT INTO test VALUES(2, "B")'); +$db->exec('INSERT INTO test VALUES(3, "C")'); + +class TestBase +{ + public $id; + public $val; +} + +class TestDerived extends TestBase +{ + protected $p1; + protected $p2; + + public function __construct($p1, $p2) + { + $this->p1 = $p1; + $this->p2 = $p2; + } +} + +var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS)); +var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestBase')); +var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestDerived', array(1,2))); +?> +===DONE=== + +--EXPECTF-- +array(3) { + [0]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(stdClass)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +array(3) { + [0]=> + object(TestBase)#%d (2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(TestBase)#%d (2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(TestBase)#%d (2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +array(3) { + [0]=> + object(TestDerived)#%d (4) { + ["p1:protected"]=> + int(1) + ["p2:protected"]=> + int(2) + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + object(TestDerived)#%d (4) { + ["p1:protected"]=> + int(1) + ["p2:protected"]=> + int(2) + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + object(TestDerived)#%d (4) { + ["p1:protected"]=> + int(1) + ["p2:protected"]=> + int(2) + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } +} +===DONE===