From: Michael Wallner Date: Tue, 14 May 2013 11:50:22 +0000 (+0200) Subject: moar tests X-Git-Tag: v0.4.0~5 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0bce4e6693c3077acc32f833442769cc7de121ef;p=m6w6%2Fext-pq moar tests --- diff --git a/package.xml b/package.xml index c686d58..741cddc 100644 --- a/package.xml +++ b/package.xml @@ -102,6 +102,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -109,6 +110,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + diff --git a/src/php_pq_params.c b/src/php_pq_params.c index 0c8278e..ec91582 100644 --- a/src/php_pq_params.c +++ b/src/php_pq_params.c @@ -137,6 +137,7 @@ static int apply_to_param_from_array(void *p TSRMLS_DC, int argc, va_list argv, if (*zparam != *((zval **) p)) { zval_ptr_dtor(zparam); } + efree(tmp); break; } } diff --git a/tests/conv001.phpt b/tests/conv001.phpt index 3020945..7340c49 100644 --- a/tests/conv001.phpt +++ b/tests/conv001.phpt @@ -83,7 +83,7 @@ $c->setConverter(new HStoreConverter($t)); $c->setConverter(new IntVectorConverter($t)); $c->setConverter(new JSONConverter($t)); -$r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js", +$r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js, \$5 as ia, \$6 as ta, \$7 as ba, \$8 as da", array( // hstore array( @@ -107,13 +107,22 @@ $r = $c->execParams("SELECT \$1 as hs, \$2 as iv, \$3 as oids, \$4 as js", "c" => 3, ), "str" => "äüö" - ) + ), + // arrays + array(array(array(1,2,3))), + array(array("a\"","b}",null)), + array(true,false), + array(1.1,2.2) ), array( $t["hstore"]->oid, $t["int2vector"]->oid, $t["oidvector"]->oid, - $t["json"]->oid + $t["json"]->oid, + $t["_int4"]->oid, + $t["_text"]->oid, + $t["_bool"]->oid, + $t["_float8"]->oid ) ); @@ -125,7 +134,7 @@ Done Test array(1) { [0]=> - array(4) { + array(%d) { [0]=> array(3) { ["k1"]=> @@ -175,6 +184,47 @@ array(1) { ["str"]=> string(6) "äüö" } + [4]=> + array(1) { + [0]=> + array(1) { + [0]=> + array(3) { + [0]=> + int(1) + [1]=> + int(2) + [2]=> + int(3) + } + } + } + [5]=> + array(1) { + [0]=> + array(3) { + [0]=> + string(2) "a"" + [1]=> + string(2) "b}" + [2]=> + NULL + } + } + [6]=> + array(2) { + [0]=> + bool(true) + [1]=> + bool(false) + } + [7]=> + array(2) { + [0]=> + float(1.1) + [1]=> + float(2.2) + } } } Done diff --git a/tests/info002.phpt b/tests/info002.phpt new file mode 100644 index 0000000..0299df9 --- /dev/null +++ b/tests/info002.phpt @@ -0,0 +1,24 @@ +--TEST-- +ext info +--SKIPIF-- + +--FILE-- +info(); +?> +Done +--EXPECTF-- +Test + +pq + +PQ Support => enabled +Extension Version => %s + +Used Library => Version +libpq => %s +Done diff --git a/tests/lob001.phpt b/tests/lob001.phpt index 7f91f64..990d6f0 100644 --- a/tests/lob001.phpt +++ b/tests/lob001.phpt @@ -12,6 +12,9 @@ $c = new pq\Connection(PQ_DSN); $t = $c->startTransaction(); $lob = $t->createLOB(); + +var_dump($lob->transaction === $t); + $lob->write(file_get_contents(__FILE__)); var_dump($lob->tell()); @@ -31,7 +34,8 @@ $t->unlinkLOB($lob->oid); DONE --EXPECTF-- Test -int(451) +bool(true) +int(489) bool(true) string(5) "%c?php" DONE diff --git a/tests/res001.phpt b/tests/res001.phpt new file mode 100644 index 0000000..89e0512 --- /dev/null +++ b/tests/res001.phpt @@ -0,0 +1,86 @@ +--TEST-- +empty result +--SKIPIF-- + +--FILE-- + +Done +--EXPECTF-- +Test + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d + +Warning: pq\Result not initialized in %s on line %d +object(pq\Result)#%d (7) { + ["status"]=> + NULL + ["statusMessage"]=> + NULL + ["errorMessage"]=> + NULL + ["numRows"]=> + int(0) + ["numCols"]=> + int(0) + ["affectedRows"]=> + int(0) + ["fetchType"]=> + int(0) +} +array(8) { + ["dummy"]=> + int(2) + ["status"]=> + NULL + ["statusMessage"]=> + NULL + ["errorMessage"]=> + NULL + ["numRows"]=> + int(0) + ["numCols"]=> + int(0) + ["affectedRows"]=> + int(0) + ["fetchType"]=> + int(0) +} +Done