]> granicus.if.org Git - php/commitdiff
- Add tests
authorMarcus Boerger <helly@php.net>
Sun, 20 Feb 2005 18:23:12 +0000 (18:23 +0000)
committerMarcus Boerger <helly@php.net>
Sun, 20 Feb 2005 18:23:12 +0000 (18:23 +0000)
12 files changed:
ext/pdo_mysql/tests/connection.inc [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_001.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_002.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_003.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_004.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_005.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_006.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_007.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_008.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_009.phpt [new file with mode: 0755]
ext/pdo_mysql/tests/prepare.inc [new file with mode: 0755]
ext/pdo_mysql/tests/skipif.inc [new file with mode: 0755]

diff --git a/ext/pdo_mysql/tests/connection.inc b/ext/pdo_mysql/tests/connection.inc
new file mode 100755 (executable)
index 0000000..2e1a80f
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+$HOST = 'localhost';
+$USER = 'root';
+$PASSWD = '';
+$DBNAME = 'test';
+
+$CONNECTION = "mysql:host=$HOST;dbname=$DBNAME";
+
+$PDO_TESTS = dirname(__FILE__) . '/../../pdo/tests/';
+
+?>
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/pdo_mysql_001.phpt b/ext/pdo_mysql/tests/pdo_mysql_001.phpt
new file mode 100755 (executable)
index 0000000..1228d23
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_ASSOC
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_001.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(3) {
+  [0]=>
+  array(2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(2) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_002.phpt b/ext/pdo_mysql/tests/pdo_mysql_002.phpt
new file mode 100755 (executable)
index 0000000..3d1265e
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_NUM
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_002.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(3) {
+  [0]=>
+  array(2) {
+    [0]=>
+    string(1) "1"
+    [1]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(2) {
+    [0]=>
+    string(1) "2"
+    [1]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(2) {
+    [0]=>
+    string(1) "3"
+    [1]=>
+    string(1) "C"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_003.phpt b/ext/pdo_mysql/tests/pdo_mysql_003.phpt
new file mode 100755 (executable)
index 0000000..3e39335
--- /dev/null
@@ -0,0 +1,53 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_BOTH
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_003.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+array(3) {
+  [0]=>
+  array(4) {
+    ["id"]=>
+    string(1) "1"
+    [0]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+    [1]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(4) {
+    ["id"]=>
+    string(1) "2"
+    [0]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+    [1]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(4) {
+    ["id"]=>
+    string(1) "3"
+    [0]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+    [1]=>
+    string(1) "C"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_004.phpt b/ext/pdo_mysql/tests/pdo_mysql_004.phpt
new file mode 100755 (executable)
index 0000000..9ab0ee1
--- /dev/null
@@ -0,0 +1,41 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_OBJ
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_004.inc');
+
+?>
+===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===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_005.phpt b/ext/pdo_mysql/tests/pdo_mysql_005.phpt
new file mode 100755 (executable)
index 0000000..13593bb
--- /dev/null
@@ -0,0 +1,120 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_CLASS
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_005.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(3) {
+  [0]=>
+  object(stdClass)#%d (3) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+    ["val2"]=>
+    string(2) "AA"
+  }
+  [1]=>
+  object(stdClass)#%d (3) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+    ["val2"]=>
+    string(2) "BB"
+  }
+  [2]=>
+  object(stdClass)#%d (3) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+    ["val2"]=>
+    string(2) "CC"
+  }
+}
+array(3) {
+  [0]=>
+  object(TestBase)#%d (3) {
+    ["id"]=>
+    string(1) "1"
+    ["val:protected"]=>
+    string(1) "A"
+    ["val2:private"]=>
+    string(2) "AA"
+  }
+  [1]=>
+  object(TestBase)#%d (3) {
+    ["id"]=>
+    string(1) "2"
+    ["val:protected"]=>
+    string(1) "B"
+    ["val2:private"]=>
+    string(2) "BB"
+  }
+  [2]=>
+  object(TestBase)#%d (3) {
+    ["id"]=>
+    string(1) "3"
+    ["val:protected"]=>
+    string(1) "C"
+    ["val2:private"]=>
+    string(2) "CC"
+  }
+}
+TestDerived::__construct(0,1)
+TestDerived::__construct(1,2)
+TestDerived::__construct(2,3)
+array(3) {
+  [0]=>
+  object(TestDerived)#%d (5) {
+    ["row:protected"]=>
+    int(0)
+    ["id"]=>
+    string(1) "1"
+    ["val:protected"]=>
+    string(1) "A"
+    ["val2:private"]=>
+    NULL
+    ["val2"]=>
+    string(2) "AA"
+  }
+  [1]=>
+  object(TestDerived)#%d (5) {
+    ["row:protected"]=>
+    int(1)
+    ["id"]=>
+    string(1) "2"
+    ["val:protected"]=>
+    string(1) "B"
+    ["val2:private"]=>
+    NULL
+    ["val2"]=>
+    string(2) "BB"
+  }
+  [2]=>
+  object(TestDerived)#%d (5) {
+    ["row:protected"]=>
+    int(2)
+    ["id"]=>
+    string(1) "3"
+    ["val:protected"]=>
+    string(1) "C"
+    ["val2:private"]=>
+    NULL
+    ["val2"]=>
+    string(2) "CC"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_006.phpt b/ext/pdo_mysql/tests/pdo_mysql_006.phpt
new file mode 100755 (executable)
index 0000000..08403b1
--- /dev/null
@@ -0,0 +1,64 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_GROUP
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_006.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(2) {
+  ["A"]=>
+  array(2) {
+    [0]=>
+    array(1) {
+      [0]=>
+      string(1) "1"
+    }
+    [1]=>
+    array(1) {
+      [0]=>
+      string(1) "2"
+    }
+  }
+  ["C"]=>
+  array(1) {
+    [0]=>
+    array(1) {
+      [0]=>
+      string(1) "3"
+    }
+  }
+}
+array(2) {
+  ["A"]=>
+  array(2) {
+    [0]=>
+    array(1) {
+      ["id"]=>
+      string(1) "1"
+    }
+    [1]=>
+    array(1) {
+      ["id"]=>
+      string(1) "2"
+    }
+  }
+  ["C"]=>
+  array(1) {
+    [0]=>
+    array(1) {
+      ["id"]=>
+      string(1) "3"
+    }
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_007.phpt b/ext/pdo_mysql/tests/pdo_mysql_007.phpt
new file mode 100755 (executable)
index 0000000..abd0d1d
--- /dev/null
@@ -0,0 +1,52 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_UNIQUE
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_007.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(3) {
+  ["A"]=>
+  array(1) {
+    [0]=>
+    string(1) "A"
+  }
+  ["B"]=>
+  array(1) {
+    [0]=>
+    string(1) "A"
+  }
+  ["C"]=>
+  array(1) {
+    [0]=>
+    string(1) "C"
+  }
+}
+array(3) {
+  ["A"]=>
+  array(1) {
+    ["val"]=>
+    string(1) "A"
+  }
+  ["B"]=>
+  array(1) {
+    ["val"]=>
+    string(1) "A"
+  }
+  ["C"]=>
+  array(1) {
+    ["val"]=>
+    string(1) "C"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_008.phpt b/ext/pdo_mysql/tests/pdo_mysql_008.phpt
new file mode 100755 (executable)
index 0000000..fc9427d
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_UNIQUE conflict
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_008.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(2) {
+  ["A"]=>
+  array(1) {
+    [0]=>
+    string(1) "B"
+  }
+  ["C"]=>
+  array(1) {
+    [0]=>
+    string(1) "C"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/pdo_mysql_009.phpt b/ext/pdo_mysql/tests/pdo_mysql_009.phpt
new file mode 100755 (executable)
index 0000000..b1a0e11
--- /dev/null
@@ -0,0 +1,89 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_CLASSTYPE
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_009.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+array(4) {
+  [0]=>
+  array(3) {
+    [0]=>
+    string(8) "stdClass"
+    [1]=>
+    string(1) "1"
+    [2]=>
+    string(1) "A"
+  }
+  [1]=>
+  array(3) {
+    [0]=>
+    string(5) "Test1"
+    [1]=>
+    string(1) "2"
+    [2]=>
+    string(1) "B"
+  }
+  [2]=>
+  array(3) {
+    [0]=>
+    string(5) "Test2"
+    [1]=>
+    string(1) "3"
+    [2]=>
+    string(1) "C"
+  }
+  [3]=>
+  array(3) {
+    [0]=>
+    NULL
+    [1]=>
+    string(1) "4"
+    [2]=>
+    string(1) "D"
+  }
+}
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(4) {
+  [0]=>
+  object(stdClass)#%d (2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(1) "A"
+  }
+  [1]=>
+  object(Test1)#%d (2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  [2]=>
+  object(Test2)#%d (2) {
+    ["id"]=>
+    string(1) "3"
+    ["val"]=>
+    string(1) "C"
+  }
+  [3]=>
+  object(Test3)#%d (2) {
+    ["id"]=>
+    string(1) "4"
+    ["val"]=>
+    string(1) "D"
+  }
+}
+===DONE===
diff --git a/ext/pdo_mysql/tests/prepare.inc b/ext/pdo_mysql/tests/prepare.inc
new file mode 100755 (executable)
index 0000000..8b8f7a5
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+require_once('connection.inc');
+
+$SQL = array();
+
+$DB = new pdo($CONNECTION, $USER, $PASSWD);
+
+foreach(array('test','classtypes') as $name)
+{
+       $DB->query('DROP TABLE IF EXISTS '.$name);
+}
+
+?>
\ No newline at end of file
diff --git a/ext/pdo_mysql/tests/skipif.inc b/ext/pdo_mysql/tests/skipif.inc
new file mode 100755 (executable)
index 0000000..4cf041d
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+if (!extension_loaded('pdo_mysql')) die('skip');
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+if (!$DB) {
+       die('skip cannot open db');
+}
+
+?>
\ No newline at end of file