mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
- Update/Add tests
This commit is contained in:
parent
41674da59f
commit
1fee3962b0
5 changed files with 171 additions and 28 deletions
|
@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_ASSOC));
|
|||
===DONE===
|
||||
<?php exit(0); ?>
|
||||
--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===
|
||||
|
|
|
@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_NUM));
|
|||
===DONE===
|
||||
<?php exit(0); ?>
|
||||
--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===
|
||||
|
|
|
@ -20,7 +20,7 @@ var_dump($stmt->fetchAll(PDO_FETCH_BOTH));
|
|||
===DONE===
|
||||
<?php exit(0); ?>
|
||||
--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===
|
||||
|
|
46
ext/pdo_sqlite/tests/pdo_sqlite_004.phpt
Executable file
46
ext/pdo_sqlite/tests/pdo_sqlite_004.phpt
Executable file
|
@ -0,0 +1,46 @@
|
|||
--TEST--
|
||||
PDO-SQLite: PDO_FETCH_OBJ
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$db =new pdo('sqlite::memory:');
|
||||
|
||||
$db->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===
|
||||
<?php exit(0); ?>
|
||||
--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===
|
122
ext/pdo_sqlite/tests/pdo_sqlite_005.phpt
Executable file
122
ext/pdo_sqlite/tests/pdo_sqlite_005.phpt
Executable file
|
@ -0,0 +1,122 @@
|
|||
--TEST--
|
||||
PDO-SQLite: PDO_FETCH_CLASS
|
||||
--SKIPIF--
|
||||
<?php # vim:ft=php
|
||||
if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$db =new pdo('sqlite::memory:');
|
||||
|
||||
$db->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===
|
||||
<?php exit(0); ?>
|
||||
--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===
|
Loading…
Add table
Add a link
Reference in a new issue