- Add new tests

This commit is contained in:
Marcus Boerger 2005-03-21 00:29:25 +00:00
parent c9108bba25
commit a66e14645c
6 changed files with 322 additions and 0 deletions

26
ext/pdo/tests/pdo_023.inc Executable file
View File

@ -0,0 +1,26 @@
<?php # vim:ft=php
require_once('pdo.inc');
set_sql('create1', 'CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10))');
set_sql('insert1', 'INSERT INTO test VALUES(0, \'A\')');
set_sql('insert2', 'INSERT INTO test VALUES(1, \'B\')');
set_sql('select1', 'SELECT val, id FROM test');
$DB->test();
var_dump($DB);
$DB->query($SQL['create1']);
$DB->query($SQL['insert1']);
$DB->query($SQL['insert2']);
$stmt = $DB->query($SQL['select1']);
var_dump($stmt);
var_dump($stmt->fetchAll(PDO_FETCH_COLUMN|PDO_FETCH_UNIQUE));
$stmt = NULL;
$DB = NULL;
?>

52
ext/pdo/tests/pdo_023_def.inc Executable file
View File

@ -0,0 +1,52 @@
<?php
class PDOStatementX extends PDOStatement
{
public $test1 = 1;
protected function __construct()
{
$this->test2 = 2;
$this->test2 = 22;
echo __METHOD__ . "()\n";
}
function __destruct()
{
echo __METHOD__ . "()\n";
}
}
class PDODatabaseX extends PDO
{
public $test1 = 1;
function __construct($connect)
{
echo __METHOD__ . "()\n";
parent::__construct($connect);
}
function __destruct()
{
echo __METHOD__ . "()\n";
}
function test()
{
$this->test2 = 2;
var_dump($this->test1);
var_dump($this->test2);
$this->test2 = 22;
}
function query($sql)
{
echo __METHOD__ . "()\n";
$stmt = parent::prepare($sql, array(PDO_ATTR_STATEMENT_CLASS=>array('PDOStatementx')));
$stmt->execute();
return $stmt;
}
}
?>

View File

@ -0,0 +1,61 @@
--TEST--
PDO_MySQL: Overloading
--SKIPIF--
<?php # vim:ft=php
require_once('skipif.inc'); ?>
--FILE--
<?php
require_once('connection.inc');
require_once('prepare.inc');
require_once($PDO_TESTS . 'pdo_023_def.inc');
$DB = NULL;
$DB = new PDODatabaseX($CONNECTION);
$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING);
require_once($PDO_TESTS . 'pdo_023.inc');
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
PDODatabaseX::__construct()
int(1)
int(2)
object(PDODatabaseX)#%d (2) {
["test1"]=>
int(1)
["test2"]=>
int(22)
}
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
object(PDOStatementX)#%d (3) {
["test1"]=>
int(1)
["queryString"]=>
string(24) "SELECT val, id FROM test"
["test2"]=>
int(22)
}
array(2) {
["A"]=>
string(1) "0"
["B"]=>
string(1) "1"
}
PDOStatementX::__destruct()
PDODatabaseX::__destruct()
===DONE===

View File

@ -0,0 +1,61 @@
--TEST--
PDO_PGSQL: Overloading
--SKIPIF--
<?php # vim:ft=php
require_once('skipif.inc'); ?>
--FILE--
<?php
require_once('connection.inc');
require_once('prepare.inc');
require_once($PDO_TESTS . 'pdo_023_def.inc');
$DB = NULL;
$DB = new PDODatabaseX($CONNECTION);
$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING);
require_once($PDO_TESTS . 'pdo_023.inc');
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
PDODatabaseX::__construct()
int(1)
int(2)
object(PDODatabaseX)#%d (2) {
["test1"]=>
int(1)
["test2"]=>
int(22)
}
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
object(PDOStatementX)#%d (3) {
["test1"]=>
int(1)
["queryString"]=>
string(24) "SELECT val, id FROM test"
["test2"]=>
int(22)
}
array(2) {
["A"]=>
int(0)
["B"]=>
int(1)
}
PDOStatementX::__destruct()
PDODatabaseX::__destruct()
===DONE===

View File

@ -0,0 +1,61 @@
--TEST--
PDO_SQLite: Overloading
--SKIPIF--
<?php # vim:ft=php
require_once('skipif.inc'); ?>
--FILE--
<?php
require_once('connection.inc');
require_once('prepare.inc');
require_once($PDO_TESTS . 'pdo_023_def.inc');
$DB = NULL;
$DB = new PDODatabaseX('sqlite::memory:');
$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING);
require_once($PDO_TESTS . 'pdo_023.inc');
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
PDODatabaseX::__construct()
int(1)
int(2)
object(PDODatabaseX)#%d (2) {
["test1"]=>
int(1)
["test2"]=>
int(22)
}
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
object(PDOStatementX)#%d (3) {
["test1"]=>
int(1)
["queryString"]=>
string(24) "SELECT val, id FROM test"
["test2"]=>
int(22)
}
array(2) {
["A"]=>
string(1) "0"
["B"]=>
string(1) "1"
}
PDOStatementX::__destruct()
PDODatabaseX::__destruct()
===DONE===

View File

@ -0,0 +1,61 @@
--TEST--
PDO_SQLite2: Overloading
--SKIPIF--
<?php # vim:ft=php
require_once('skipif.inc'); ?>
--FILE--
<?php
require_once('connection.inc');
require_once('prepare.inc');
require_once($PDO_TESTS . 'pdo_023_def.inc');
$DB = NULL;
$DB = new PDODatabaseX($CONNECTION);
$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING);
require_once($PDO_TESTS . 'pdo_023.inc');
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
PDODatabaseX::__construct()
int(1)
int(2)
object(PDODatabaseX)#%d (2) {
["test1"]=>
int(1)
["test2"]=>
int(22)
}
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
PDOStatementX::__destruct()
PDODatabaseX::query()
PDOStatementX::__construct()
object(PDOStatementX)#%d (3) {
["test1"]=>
int(1)
["queryString"]=>
string(24) "SELECT val, id FROM test"
["test2"]=>
int(22)
}
array(2) {
["A"]=>
string(1) "0"
["B"]=>
string(1) "1"
}
PDOStatementX::__destruct()
PDODatabaseX::__destruct()
===DONE===