]> granicus.if.org Git - php/commitdiff
- Add new test
authorMarcus Boerger <helly@php.net>
Mon, 21 Feb 2005 18:55:51 +0000 (18:55 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 21 Feb 2005 18:55:51 +0000 (18:55 +0000)
ext/pdo/tests/pdo_010.inc [new file with mode: 0755]
ext/pdo_mysql/tests/pdo_mysql_010.phpt [new file with mode: 0755]
ext/pdo_pgsql/tests/pdo_pgsql_010.phpt [new file with mode: 0755]
ext/pdo_sqlite/tests/pdo_sqlite_010.phpt [new file with mode: 0755]

diff --git a/ext/pdo/tests/pdo_010.inc b/ext/pdo/tests/pdo_010.inc
new file mode 100755 (executable)
index 0000000..c25d935
--- /dev/null
@@ -0,0 +1,53 @@
+<?php # vim:ft=php
+
+require_once('pdo.inc');
+       
+set_sql('create1', 'CREATE TABLE classtypes(id int PRIMARY KEY, name VARCHAR(10) UNIQUE)');
+set_sql('insert1', 'INSERT INTO classtypes VALUES(0, \'stdClass\')'); 
+set_sql('insert2', 'INSERT INTO classtypes VALUES(1, \'Test1\')'); 
+set_sql('insert3', 'INSERT INTO classtypes VALUES(2, \'Test2\')'); 
+set_sql('create2', 'CREATE TABLE test(id int PRIMARY KEY, classtype int, val VARCHAR(10), grp VARCHAR(10))');
+set_sql('insert4', 'INSERT INTO test VALUES(1, 0, \'A\', \'Group1\')'); 
+set_sql('insert5', 'INSERT INTO test VALUES(2, 1, \'B\', \'Group1\')'); 
+set_sql('insert6', 'INSERT INTO test VALUES(3, 2, \'C\', \'Group2\')'); 
+set_sql('insert7', 'INSERT INTO test VALUES(4, 3, \'D\', \'Group2\')'); 
+set_sql('select',  'SELECT classtypes.name, test.grp AS grp, test.id AS id, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id');
+
+$DB->exec($SQL['create1']);
+$DB->exec($SQL['insert1']);
+$DB->exec($SQL['insert2']);
+$DB->exec($SQL['insert3']);
+$DB->exec($SQL['create2']);
+$DB->exec($SQL['insert4']);
+$DB->exec($SQL['insert5']);
+$DB->exec($SQL['insert6']);
+$DB->exec($SQL['insert7']);
+
+class Test1
+{
+       public function __construct()
+       {
+               echo __METHOD__ . "()\n";
+       }
+}
+
+class Test2
+{
+       public function __construct()
+       {
+               echo __METHOD__ . "()\n";
+       }
+}
+
+class Test3
+{
+       public function __construct()
+       {
+               echo __METHOD__ . "()\n";
+       }
+}
+
+var_dump($DB->query($SQL['select'])->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE|PDO_FETCH_GROUP, 'Test3'));
+var_dump($DB->query($SQL['select'])->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE|PDO_FETCH_UNIQUE, 'Test3'));
+
+?>
diff --git a/ext/pdo_mysql/tests/pdo_mysql_010.phpt b/ext/pdo_mysql/tests/pdo_mysql_010.phpt
new file mode 100755 (executable)
index 0000000..03be77c
--- /dev/null
@@ -0,0 +1,76 @@
+--TEST--
+PDO-MySQL: PDO_FETCH_(CLASSTYPE and GROUP/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_010.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(2) {
+  ["Group1"]=>
+  array(2) {
+    [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"
+    }
+  }
+  ["Group2"]=>
+  array(2) {
+    [0]=>
+    object(Test2)#%d (2) {
+      ["id"]=>
+      string(1) "3"
+      ["val"]=>
+      string(1) "C"
+    }
+    [1]=>
+    object(Test3)#%d (2) {
+      ["id"]=>
+      string(1) "4"
+      ["val"]=>
+      string(1) "D"
+    }
+  }
+}
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(2) {
+  ["Group1"]=>
+  object(Test1)#%d (2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  ["Group2"]=>
+  object(Test3)#%d (2) {
+    ["id"]=>
+    string(1) "4"
+    ["val"]=>
+    string(1) "D"
+  }
+}
+===DONE===
diff --git a/ext/pdo_pgsql/tests/pdo_pgsql_010.phpt b/ext/pdo_pgsql/tests/pdo_pgsql_010.phpt
new file mode 100755 (executable)
index 0000000..a52e135
--- /dev/null
@@ -0,0 +1,76 @@
+--TEST--
+PDO-PGSQL: PDO_FETCH_(CLASSTYPE and GROUP/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_010.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(2) {
+  ["Group1"]=>
+  array(2) {
+    [0]=>
+    object(stdClass)#%d (2) {
+      ["id"]=>
+      int(1)
+      ["val"]=>
+      string(1) "A"
+    }
+    [1]=>
+    object(Test1)#%d (2) {
+      ["id"]=>
+      int(2)
+      ["val"]=>
+      string(1) "B"
+    }
+  }
+  ["Group2"]=>
+  array(2) {
+    [0]=>
+    object(Test2)#%d (2) {
+      ["id"]=>
+      int(3)
+      ["val"]=>
+      string(1) "C"
+    }
+    [1]=>
+    object(Test3)#%d (2) {
+      ["id"]=>
+      int(4)
+      ["val"]=>
+      string(1) "D"
+    }
+  }
+}
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(2) {
+  ["Group1"]=>
+  object(Test1)#%d (2) {
+    ["id"]=>
+    int(2)
+    ["val"]=>
+    string(1) "B"
+  }
+  ["Group2"]=>
+  object(Test3)#%d (2) {
+    ["id"]=>
+    int(4)
+    ["val"]=>
+    string(1) "D"
+  }
+}
+===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_010.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_010.phpt
new file mode 100755 (executable)
index 0000000..9872ad2
--- /dev/null
@@ -0,0 +1,76 @@
+--TEST--
+PDO-SQLite: PDO_FETCH_(CLASSTYPE and GROUP/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_010.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(2) {
+  ["Group1"]=>
+  array(2) {
+    [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"
+    }
+  }
+  ["Group2"]=>
+  array(2) {
+    [0]=>
+    object(Test2)#%d (2) {
+      ["id"]=>
+      string(1) "3"
+      ["val"]=>
+      string(1) "C"
+    }
+    [1]=>
+    object(Test3)#%d (2) {
+      ["id"]=>
+      string(1) "4"
+      ["val"]=>
+      string(1) "D"
+    }
+  }
+}
+Test1::__construct()
+Test2::__construct()
+Test3::__construct()
+array(2) {
+  ["Group1"]=>
+  object(Test1)#%d (2) {
+    ["id"]=>
+    string(1) "2"
+    ["val"]=>
+    string(1) "B"
+  }
+  ["Group2"]=>
+  object(Test3)#%d (2) {
+    ["id"]=>
+    string(1) "4"
+    ["val"]=>
+    string(1) "D"
+  }
+}
+===DONE===