diff options
author | Marcus Boerger <helly@php.net> | 2005-02-20 18:23:12 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2005-02-20 18:23:12 +0000 |
commit | 776144866c59c538c055483147ec79038bea2517 (patch) | |
tree | eb9378ddaa36ce75b776e55f70c0167fea90ea73 /ext/pdo_mysql/tests | |
parent | 37e2d03763e8a167c75061ff170517147c2bd227 (diff) | |
download | php-git-776144866c59c538c055483147ec79038bea2517.tar.gz |
- Add tests
Diffstat (limited to 'ext/pdo_mysql/tests')
-rwxr-xr-x | ext/pdo_mysql/tests/connection.inc | 12 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_001.phpt | 41 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_002.phpt | 41 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_003.phpt | 53 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_004.phpt | 41 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_005.phpt | 120 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_006.phpt | 64 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_007.phpt | 52 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_008.phpt | 30 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/pdo_mysql_009.phpt | 89 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/prepare.inc | 14 | ||||
-rwxr-xr-x | ext/pdo_mysql/tests/skipif.inc | 12 |
12 files changed, 569 insertions, 0 deletions
diff --git a/ext/pdo_mysql/tests/connection.inc b/ext/pdo_mysql/tests/connection.inc new file mode 100755 index 0000000000..2e1a80f359 --- /dev/null +++ b/ext/pdo_mysql/tests/connection.inc @@ -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 index 0000000000..1228d23ad3 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_001.phpt @@ -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 index 0000000000..3d1265efa6 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_002.phpt @@ -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 index 0000000000..3e393358a5 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_003.phpt @@ -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 index 0000000000..9ab0ee1482 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_004.phpt @@ -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 index 0000000000..13593bb5c6 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_005.phpt @@ -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 index 0000000000..08403b12a2 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_006.phpt @@ -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 index 0000000000..abd0d1d169 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_007.phpt @@ -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 index 0000000000..fc9427d3d0 --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_008.phpt @@ -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 index 0000000000..b1a0e1193b --- /dev/null +++ b/ext/pdo_mysql/tests/pdo_mysql_009.phpt @@ -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 index 0000000000..8b8f7a5106 --- /dev/null +++ b/ext/pdo_mysql/tests/prepare.inc @@ -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 index 0000000000..4cf041d0b1 --- /dev/null +++ b/ext/pdo_mysql/tests/skipif.inc @@ -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 |