summaryrefslogtreecommitdiff
path: root/ext/sybase_ct/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/sybase_ct/tests')
-rw-r--r--ext/sybase_ct/tests/bug22403.phpt88
-rw-r--r--ext/sybase_ct/tests/bug26407.phpt91
-rw-r--r--ext/sybase_ct/tests/bug27843.phpt54
-rw-r--r--ext/sybase_ct/tests/bug28354.phpt46
-rw-r--r--ext/sybase_ct/tests/bug29064.phpt143
-rw-r--r--ext/sybase_ct/tests/bug30312.phpt27
-rw-r--r--ext/sybase_ct/tests/bug6339.phpt24
-rw-r--r--ext/sybase_ct/tests/index.php216
-rw-r--r--ext/sybase_ct/tests/skipif.inc8
-rw-r--r--ext/sybase_ct/tests/test.inc84
-rw-r--r--ext/sybase_ct/tests/test_appname.phpt65
-rw-r--r--ext/sybase_ct/tests/test_connect.phpt19
-rw-r--r--ext/sybase_ct/tests/test_connectionbased_msghandler.phpt27
-rw-r--r--ext/sybase_ct/tests/test_fetch_object.phpt74
-rw-r--r--ext/sybase_ct/tests/test_fields.phpt76
-rw-r--r--ext/sybase_ct/tests/test_long.phpt80
-rw-r--r--ext/sybase_ct/tests/test_msghandler.phpt43
-rw-r--r--ext/sybase_ct/tests/test_msghandler_handled.phpt69
-rw-r--r--ext/sybase_ct/tests/test_query_nostore.phpt98
-rw-r--r--ext/sybase_ct/tests/test_types.phpt87
-rw-r--r--ext/sybase_ct/tests/test_unbuffered_query.phpt57
21 files changed, 0 insertions, 1476 deletions
diff --git a/ext/sybase_ct/tests/bug22403.phpt b/ext/sybase_ct/tests/bug22403.phpt
deleted file mode 100644
index 2088595d33..0000000000
--- a/ext/sybase_ct/tests/bug22403.phpt
+++ /dev/null
@@ -1,88 +0,0 @@
---TEST--
-Sybase-CT bug #22403 (crash when executing a stored procedure without parameters)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- sybase_set_message_handler('sybase_msg_handler');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- // Check if stored procedure already exists
- $sp_name= 'phpt_bug22403';
- var_dump(sybase_select_db('tempdb', $db));
- if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
- echo "Stored procedure {$sp_name} not found, creating\n";
- var_dump(sybase_query('
- create proc '.$sp_name.' (@param int)
- as
- begin
- select @param
- select @param + 1
- return @param
- end
- '));
- } else {
- echo "Stored procedure {$sp_name} found, using\n";
- var_dump(TRUE);
- }
-
- // These don't work
- var_dump(sybase_select_ex($db, 'exec '.$sp_name));
- var_dump(sybase_select_ex($db, 'exec '.$sp_name.' "foo"'));
- var_dump(sybase_select_ex($db, 'exec does_not_exist'));
-
- // These do
- var_dump(sybase_select_ex($db, 'exec '.$sp_name.' NULL'));
- var_dump(sybase_select_ex($db, 'exec '.$sp_name.' 1'));
-
- // Clean up after ourselves
- var_dump(sybase_query('drop proc '.$sp_name));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-Stored procedure %s
-bool(true)
->>> Query: exec %s
-*** Caught Sybase Server Message #201 [Severity 16, state 2] at line 0
- %s
-<<< Return: boolean
-bool(false)
->>> Query: exec %s "foo"
-*** Caught Sybase Server Message #257 [Severity 16, state 1] at line 0
- %s
-<<< Return: boolean
-bool(false)
->>> Query: exec does_not_exist
-*** Caught Sybase Server Message #2812 [Severity 16, state 4] at line 1
- %s
-<<< Return: boolean
-bool(false)
->>> Query: exec %s NULL
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- NULL
- }
-}
->>> Query: exec %s 1
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- int(1)
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug26407.phpt b/ext/sybase_ct/tests/bug26407.phpt
deleted file mode 100644
index c8a2d8f28f..0000000000
--- a/ext/sybase_ct/tests/bug26407.phpt
+++ /dev/null
@@ -1,91 +0,0 @@
---TEST--
-Sybase-CT bug #26407 (Result set fetching broken around transactions)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create temporary table
- $table= 'phpt_bug26407';
- var_dump(sybase_query('create table #'.$table.' ( the_big_answer int )', $db));
-
- // I
- var_dump(sybase_select_ex($db, '
- begin transaction
- -- anything producing a result set here will fail;
- -- however, print or update statements will work
- select "foo"
- commit
- -- anything afterwards will fail, too
- '));
-
- // II
- var_dump(sybase_select_ex($db, '
- begin transaction
- -- no result returned...
- update #'.$table.' set the_big_answer=42
- commit
- '));
-
- // III
- var_dump(sybase_select_ex($db, '
- select "foo"
- begin transaction
- -- do anything, even return a result set
- commit
- select "bar"
- '));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
->>> Query:
- begin transaction
- -- anything producing a result set here will fail;
- -- however, print or update statements will work
- select "foo"
- commit
- -- anything afterwards will fail, too
-
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- string(3) "foo"
- }
-}
->>> Query:
- begin transaction
- -- no result returned...
- update #phpt_bug26407 set the_big_answer=42
- commit
-
-<<< Return: boolean
-bool(true)
->>> Query:
- select "foo"
- begin transaction
- -- do anything, even return a result set
- commit
- select "bar"
-
-
-Notice: sybase_query(): Sybase: Unexpected results, cancelling current in %s/test.inc on line %d
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- string(3) "foo"
- }
-}
diff --git a/ext/sybase_ct/tests/bug27843.phpt b/ext/sybase_ct/tests/bug27843.phpt
deleted file mode 100644
index 2de4dbb2ff..0000000000
--- a/ext/sybase_ct/tests/bug27843.phpt
+++ /dev/null
@@ -1,54 +0,0 @@
---TEST--
-Sybase-CT bug #27843 (notices when query is a stored procedure)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Check if stored procedure already exists
- $sp_name= 'phpt_bug27843';
- var_dump(sybase_select_db('tempdb', $db));
- if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
- echo "Stored procedure {$sp_name} not found, creating\n";
- var_dump(sybase_query('
- create proc '.$sp_name.'
- as
- begin
- select 1
- end
- '));
- } else {
- echo "Stored procedure {$sp_name} found, using\n";
- var_dump(TRUE);
- }
-
- // Execute stored procedure
- var_dump(sybase_select_ex($db, 'exec '.$sp_name));
-
- // Clean up after ourselves
- var_dump(sybase_query('drop proc '.$sp_name, $db));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-Stored procedure %s
-bool(true)
->>> Query: exec phpt_bug27843
-<<< Return: resource
-array(1) {
- [0]=>
- array(1) {
- ["computed"]=>
- int(1)
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug28354.phpt b/ext/sybase_ct/tests/bug28354.phpt
deleted file mode 100644
index 3ef374469a..0000000000
--- a/ext/sybase_ct/tests/bug28354.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Sybase-CT bug #28354 (sybase_free_result crash)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- sybase_set_message_handler('sybase_msg_handler');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- // Check if stored procedure already exists
- $sp_name= 'phpt_bug28354';
- var_dump(sybase_select_db('tempdb', $db));
- if (!sybase_select_single($db, 'select object_id("'.$sp_name.'")')) {
- echo "Stored procedure {$sp_name} not found, creating\n";
- var_dump(sybase_query('
- create proc '.$sp_name.' as begin
- select @@version
- end
- '));
- } else {
- echo "Stored procedure {$sp_name} found, using\n";
- var_dump(TRUE);
- }
-
- $r= sybase_query('exec '.$sp_name, $db);
- $i= 0;
- while ($row= sybase_fetch_row($r)) {
- var_dump($i++, $row[0]);
- }
- sybase_free_result($r);
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-Stored procedure %s
-bool(true)
-int(0)
-string(%d) "%s"
diff --git a/ext/sybase_ct/tests/bug29064.phpt b/ext/sybase_ct/tests/bug29064.phpt
deleted file mode 100644
index 902fe43358..0000000000
--- a/ext/sybase_ct/tests/bug29064.phpt
+++ /dev/null
@@ -1,143 +0,0 @@
---TEST--
-Sybase-CT bug #29064 (Exact numeric/decimal/money datatypes lose precision)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create a temporary table and fill it with test values
- var_dump(sybase_query('
- create table #test (
- test_decimal decimal(38, 6) null,
- test_numeric numeric(38, 12) null,
- test_money money null,
- test_bigint decimal(38, 0) null,
- test_int int null,
- test_smallmoney smallmoney null,
- test_smallint smallint null,
- test_tinyint tinyint null,
- test_real float null,
- test_double float null
- )
- ', $db));
- var_dump(sybase_query('
- insert into #test (
- test_decimal,
- test_numeric,
- test_money,
- test_bigint,
- test_int,
- test_smallmoney,
- test_smallint,
- test_tinyint,
- test_real,
- test_double
- ) values (
- 12345678901234567890123456789012.123456,
- 12345678901234567890123456.123456789012,
- 123456789012345.1234,
- 12345678901234567890123456789012345678,
- 1234567890,
- 123456.1234,
- 12345,
- 123,
- 123456789.12345679,
- 123456789.12345679
- )
- ', $db));
- var_dump(sybase_query('
- insert into #test (
- test_decimal,
- test_numeric,
- test_money,
- test_bigint,
- test_int,
- test_smallmoney,
- test_smallint,
- test_tinyint,
- test_real,
- test_double
- ) values (
- -12345678901234567890123456789012.123456,
- -12345678901234567890123456.123456789012,
- -123456789012345.1234,
- -12345678901234567890123456789012345678,
- -1234567890,
- -123456.1234,
- -12345,
- 255,
- -123456789.12345679,
- -123456789.12345679
- )
- ', $db));
-
- // Select the data
- var_dump(sybase_select_ex($db, 'select * from #test'));
-
- // Clean up and close connection
- var_dump(sybase_query('drop table #test', $db));
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
->>> Query: select * from #test
-<<< Return: resource
-array(2) {
- [0]=>
- array(10) {
- ["test_decimal"]=>
- string(39) "12345678901234567890123456789012.123456"
- ["test_numeric"]=>
- string(39) "12345678901234567890123456.123456789012"
- ["test_money"]=>
- string(18) "123456789012345.12"
- ["test_bigint"]=>
- string(38) "12345678901234567890123456789012345678"
- ["test_int"]=>
- int(1234567890)
- ["test_smallmoney"]=>
- float(123456.12)
- ["test_smallint"]=>
- int(12345)
- ["test_tinyint"]=>
- int(123)
- ["test_real"]=>
- string(16) "123456789.123457"
- ["test_double"]=>
- string(16) "123456789.123457"
- }
- [1]=>
- array(10) {
- ["test_decimal"]=>
- string(40) "-12345678901234567890123456789012.123456"
- ["test_numeric"]=>
- string(40) "-12345678901234567890123456.123456789012"
- ["test_money"]=>
- string(19) "-123456789012345.12"
- ["test_bigint"]=>
- string(39) "-12345678901234567890123456789012345678"
- ["test_int"]=>
- int(-1234567890)
- ["test_smallmoney"]=>
- float(-123456.12)
- ["test_smallint"]=>
- int(-12345)
- ["test_tinyint"]=>
- int(255)
- ["test_real"]=>
- string(17) "-123456789.123457"
- ["test_double"]=>
- string(17) "-123456789.123457"
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/bug30312.phpt b/ext/sybase_ct/tests/bug30312.phpt
deleted file mode 100644
index 55ae9f0809..0000000000
--- a/ext/sybase_ct/tests/bug30312.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Sybase-CT bug #30312 (sybase_unbuffered_query calls)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
- error_reporting(error_reporting() & !E_NOTICE); // Suppress notices
-
- $db= sybase_connect_ex();
-
- $query= sybase_unbuffered_query('select getdate()');
- $array= sybase_fetch_array($query);
- var_dump($array[0]);
-
- $query= sybase_unbuffered_query('select getdate()');
- $array= sybase_fetch_array($query);
- var_dump($array[0]);
-?>
---EXPECTF--
-string(%d) "%s %d %d %d:%d%s"
-string(%d) "%s %d %d %d:%d%s"
diff --git a/ext/sybase_ct/tests/bug6339.phpt b/ext/sybase_ct/tests/bug6339.phpt
deleted file mode 100644
index 3b0a072b4a..0000000000
--- a/ext/sybase_ct/tests/bug6339.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-Sybase-CT bug #6339 (invalid Sybase-link resource)
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // Suppress "Changed database context" warnings
- sybase_min_server_severity(11);
- sybase_connect(HOST, USER, PASSWORD);
- var_dump(sybase_fetch_row(sybase_query('select 1')));
- sybase_close();
-?>
---EXPECTF--
-array(1) {
- [0]=>
- int(1)
-}
diff --git a/ext/sybase_ct/tests/index.php b/ext/sybase_ct/tests/index.php
deleted file mode 100644
index 47202efa3b..0000000000
--- a/ext/sybase_ct/tests/index.php
+++ /dev/null
@@ -1,216 +0,0 @@
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- // {{{ class PHPTExpectancy
- // Abstract base class for expectancies
- class PHPTExpectancy {
- var
- $expected = '';
-
- function PHPTExpectancy($expected) {
- $this->expected= $expected;
- }
-
- function matches($output) { }
- }
- // }}}
-
- // {{{ class PHPTRegexExpectancy
- // Expectancy class for regular expressions
- class PHPTRegexExpectancy extends PHPTExpectancy {
-
- function matches($output) {
- return preg_match('°^'.strtr(preg_quote(rtrim($this->expected), '°'), array(
- '%s' => '(.+)',
- '%d' => '([0-9]+)'
- )).'°', $output);
- }
- }
- // }}}
-
- // {{{ class PHPTTest
- // Represents a single .phpt-style test
- class PHPTTest {
- var
- $name = '',
- $description = '',
- $skipif = '',
- $code = '',
- $expectancy = NULL,
- $output = '';
-
- function &fromFile($filename) {
- $fd= fopen($filename, 'r');
-
- $sections= array();
- $current= NULL;
- while (!feof($fd)) {
- $line= fgets($fd, 0xFFFF);
- if (1 == sscanf($line, '--%[^-]--', $section)) {
- $sections[$section]= '';
- $current= $section;
- continue;
- }
- $sections[$current].= $line;
- }
- fclose($fd);
-
- // Create instance from read data and return it
- $t= &new PHPTTest(); {
- $t->name= substr(realpath($filename), 0, -1);
- $t->description= rtrim($sections['TEST']);
- $t->skipif= $sections['SKIPIF'];
- $t->code= $sections['FILE'];
-
- if (isset($sections['EXPECTF'])) {
- $t->expectancy= &new PHPTRegexExpectancy($sections['EXPECTF']);
- } else {
- // XXX TBI XXX
- }
- }
- return $t;
- }
-
- function onError($errno, $errstr, $errfile, $errline) {
- static $names= array(
- E_NOTICE => 'Notice',
- E_WARNING => 'Warning'
- );
-
- if (!(error_reporting() & $errno)) return;
- printf(
- "\n%s: %s in %s on line %d\n",
- $names[$errno],
- $errstr,
- strstr($errfile, 'eval()\'d code') ? $this->name : $errfile,
- $errline
- );
- }
-
- function run() {
-
- // Precondition check - will die if test needs to be skipped
- eval('?>'.$this->skipif);
-
- set_error_handler(array(&$this, 'onError')); {
- error_reporting(E_ALL);
-
- ob_start();
- eval('?>'.$this->code);
- $this->output= rtrim(ob_get_contents());
- ob_end_clean();
- } restore_error_handler();
-
- return $this->expectancy->matches($this->output);
- }
- }
- // }}}
-
- // {{{ main
- if (isset($_GET['phpinfo'])) {
- phpinfo((int)$_GET['phpinfo']);
-
- echo '<a href="?">Home</a>';
- exit();
- }
-
- echo <<<__
- <html>
- <head>
- <title>PHPT Test</title>
- <style type="text/css">
- body {
- background-color: #ffffff;
- color: #000000;
- font-size: 75%;
- }
- body, td, th, h1, h2 {
- font-family: sans-serif;
- }
- h1 {
- font-size: 150%;
- }
- h2 {
- font-size: 125%;
- }
- .header {
- background: url(?=PHPE9568F34-D428-11d2-A769-00AA001ACF42);
- background-position: right center;
- background-repeat: no-repeat;
- min-height: 70px;
- background-color: #9999cc;
- padding: 4px;
- padding-right: 120px;
- border: 1px solid #000000;
- }
- hr {
- width: 600px;
- background-color: #cccccc;
- border: 0px;
- height: 1px;
- color: #000000;
- }
- </style>
- </head>
- <body>
-__;
-
- $test= basename($_SERVER['QUERY_STRING']);
- if ($test && file_exists($test)) {
- $t= &PHPTTest::fromFile($test);
- echo '<div class="header"><h1>'.basename($t->name), ': ', $t->description.'</h1></div>';
- echo '<a href="?">Back to test suite</a>';
- flush();
-
- // Run the test
- $result= $t->run();
-
- // Evaluate results
- if ($result) {
- echo '<h2>Passed</h2>';
- } else {
- echo '<h2>Failed</h2><hr/>';
-
- echo '<h3>Actual output</h3>';
- echo '<xmp>', $t->output, '</xmp><hr/>';
-
- echo '<h3>Expectancy</h3>';
- echo '<xmp>', $t->expectancy->expected, '</xmp>';
- }
-
- echo '<hr/>';
- exit();
- }
-
- echo '<div class="header"><h1>Test suite</h1></div>';
-
- // phpinfo() links
- echo 'phpinfo(): ';
- foreach (array(
- 1 => 'General',
- 4 => 'Configuration',
- 8 => 'Modules'
- ) as $const => $name) {
- printf('<a href="?phpinfo=%d">%s</a> | ', $const, $name);
- }
- echo '<a href="?phpinfo=-1">(All)</a>';
-
- echo '<h2>Select one to run</h2>';
- echo '<ul>';
- $d= dir(dirname(__FILE__));
- while ($entry= $d->read()) {
- if ('.phpt' != substr($entry, -5)) continue;
- echo '<li><a href="?'.$entry.'">'.$entry.'</a></li>';
- }
- $d->close();
- echo '</ul><hr/>';
-
- echo <<<__
- </body>
- </html>
-__;
- // }}}
-?>
diff --git a/ext/sybase_ct/tests/skipif.inc b/ext/sybase_ct/tests/skipif.inc
deleted file mode 100644
index 3bbc1e8a62..0000000000
--- a/ext/sybase_ct/tests/skipif.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- if (!extension_loaded('sybase_ct')) die('skip Sybase-CT extension not loaded');
-?>
diff --git a/ext/sybase_ct/tests/test.inc b/ext/sybase_ct/tests/test.inc
deleted file mode 100644
index 48aa7d23b3..0000000000
--- a/ext/sybase_ct/tests/test.inc
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- // Change if needed
- define('HOST', '****');
- define('USER', '****');
- define('PASSWORD', '****');
-
- // {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function sybase_msg_handler($msgnumber, $severity, $state, $line, $text) {
- printf(
- "*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d\n '%s'\n",
- $msgnumber,
- $severity,
- $state,
- $line,
- chop($text)
- );
- }
- // }}}
-
- // {{{ public class sybase
- class sybase {
-
- // {{{ public static bool static_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function static_handler($msgnumber, $severity, $state, $line, $text) {
- return sybase_msg_handler($msgnumber, $severity, $state, $line, $text);
- }
- // }}}
-
- // {{{ public bool static_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function handler($msgnumber, $severity, $state, $line, $text) {
- return sybase_msg_handler($msgnumber, $severity, $state, $line, $text);
- }
- // }}}
- }
- // }}}
-
- // {{{ void sybase_set_messagehandler_ex(string handler)
- // Sets the sybase message handler and dumps the result
- function sybase_set_messagehandler_ex($handler) {
- var_dump(sybase_set_message_handler($handler));
- }
-
- // {{{ resource sybase_connect_ex(string charset= NULL, string appname= NULL)
- // Connect to the sybase server using the defines HOST, USER and PASSWORD
- function sybase_connect_ex($charset= NULL, $appname= NULL) {
- sybase_min_server_severity(11); // Suppress "changed database context"
- if (!($db= sybase_connect(HOST, USER, PASSWORD, $charset ? $charset : 'iso_1', $appname))) {
- die('Connect to '.USER.'@'.HOST.' failed (using password: '.(PASSWORD ? 'yes' : 'no').')');
- }
- return $db;
- }
- // }}}
-
- // {{{ void sybase_select_ex(resource dbh, string query)
- // Returns all fetched rows from an SQL query
- function sybase_select_ex($dbh, $query) {
- printf(">>> Query: %s\n", $query);
- $h= sybase_query($query, $dbh);
- printf("<<< Return: %s\n", gettype($h));
- flush();
- if (!is_resource($h)) return $h;
-
- $return= array();
- while ($row= sybase_fetch_assoc($h)) {
- $return[]= $row;
- }
- return $return;
- }
-
- // {{{ mixed sybase_select_single(resource dbh, string query)
- // Fires an SQL query and returns the first value from the first row
- function sybase_select_single($dbh, $query) {
- return array_shift(sybase_fetch_row(sybase_query($query, $dbh)));
- }
- // }}}
-?>
diff --git a/ext/sybase_ct/tests/test_appname.phpt b/ext/sybase_ct/tests/test_appname.phpt
deleted file mode 100644
index c423ff0b52..0000000000
--- a/ext/sybase_ct/tests/test_appname.phpt
+++ /dev/null
@@ -1,65 +0,0 @@
---TEST--
-Sybase-CT application name
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // {{{ bool compare_string(string expect, string actual)
- // Compares expect to a trimmed version of actual
- function compare_string($expect, $actual) {
- $trimmed= rtrim($actual, ' ');
- return (0 == strncmp($expect, $trimmed, strlen($trimmed)));
- }
- // }}}
-
- $program_name= 'phpt_test';
- $hostname= 'php.net';
- ini_set('sybct.hostname', $hostname);
-
- $db= sybase_connect_ex(NULL, $program_name);
- $r= sybase_select_ex($db, '
- select
- hostname,
- program_name
- from
- master..sysprocesses
- where
- program_name = "'.$program_name.'"'
- );
-
- var_dump(
- $r,
- compare_string($program_name, $r[0]['program_name']),
- compare_string($hostname, $r[0]['hostname'])
- );
-
- sybase_close($db);
-?>
---EXPECTF--
->>> Query:
- select
- hostname,
- program_name
- from
- master..sysprocesses
- where
- program_name = "phpt_test"
-<<< Return: resource
-array(1) {
- [0]=>
- array(2) {
- ["hostname"]=>
- string(10) "php.net%s"
- ["program_name"]=>
- string(16) "phpt_test%s"
- }
-}
-bool(true)
-bool(true)
diff --git a/ext/sybase_ct/tests/test_connect.phpt b/ext/sybase_ct/tests/test_connect.phpt
deleted file mode 100644
index e1e3eead38..0000000000
--- a/ext/sybase_ct/tests/test_connect.phpt
+++ /dev/null
@@ -1,19 +0,0 @@
---TEST--
-Sybase-CT connectivity
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
diff --git a/ext/sybase_ct/tests/test_connectionbased_msghandler.phpt b/ext/sybase_ct/tests/test_connectionbased_msghandler.phpt
deleted file mode 100644
index 72e6b3a8dc..0000000000
--- a/ext/sybase_ct/tests/test_connectionbased_msghandler.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-Sybase-CT connection-based server message handler
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
- var_dump(sybase_set_message_handler('sybase_msg_handler', $db));
- var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-bool(true)
->>> Query: select getdate(NULL)
-*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d
- %s
-<<< Return: boolean
-bool(false)
diff --git a/ext/sybase_ct/tests/test_fetch_object.phpt b/ext/sybase_ct/tests/test_fetch_object.phpt
deleted file mode 100644
index aba5ea938d..0000000000
--- a/ext/sybase_ct/tests/test_fetch_object.phpt
+++ /dev/null
@@ -1,74 +0,0 @@
---TEST--
-Sybase-CT sybase_fetch_object
---SKIPIF--
-<?php
- require('skipif.inc');
-?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // {{{ class article
- class article { }
- // }}}
-
- // {{{ resource fetch_object(resource db, [mixed arg= NULL])
- // Fetches a resultset and returns it as an object
- function fetch_object($db, $arg= NULL) {
- return sybase_fetch_object(sybase_query('select
- 1 as "id",
- "Hello" as "caption",
- "timm" as "author",
- getdate() as "lastchange"
- ', $db), $arg);
- }
- // }}}
-
- $db= sybase_connect_ex();
-
- // Test with stdClass
- var_export(fetch_object($db)); echo "\n";
-
- // Test with userland class
- var_export(fetch_object($db, 'article')); echo "\n";
-
- // Test with object
- var_export(fetch_object($db, new article())); echo "\n";
-
- // Test with non-existant class
- var_export(fetch_object($db, '***')); echo "\n";
-
- sybase_close($db);
-?>
---EXPECTF--
-class stdClass {
- %s $id = 1;
- %s $caption = 'Hello';
- %s $author = 'timm';
- %s $lastchange = '%s';
-}
-class article {
- %s $id = 1;
- %s $caption = 'Hello';
- %s $author = 'timm';
- %s $lastchange = '%s';
-}
-class article {
- %s $id = 1;
- %s $caption = 'Hello';
- %s $author = 'timm';
- %s $lastchange = '%s';
-}
-
-Notice: sybase_fetch_object(): Sybase: Class *** has not been declared in %s/test_fetch_object.php on line %d
-class stdClass {
- %s $id = 1;
- %s $caption = 'Hello';
- %s $author = 'timm';
- %s $lastchange = '%s';
-}
diff --git a/ext/sybase_ct/tests/test_fields.phpt b/ext/sybase_ct/tests/test_fields.phpt
deleted file mode 100644
index cda606ab21..0000000000
--- a/ext/sybase_ct/tests/test_fields.phpt
+++ /dev/null
@@ -1,76 +0,0 @@
---TEST--
-Sybase-CT sybase_field_* functions
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Issue a query
- $q= sybase_unbuffered_query('select
- 1 as "id",
- "Hello" as "caption",
- "timm" as "author",
- getdate() as "lastchange"
- ', $db, FALSE);
- var_dump($q);
-
- var_dump(sybase_num_fields($q));
-
- // Go through each field, dumping it
- while ($field= sybase_fetch_field($q)) {
- var_export($field); echo "\n";
- }
-
- // Seek to the second field and fetch it
- var_dump(sybase_field_seek($q, 1));
- var_export(sybase_fetch_field($q)); echo "\n";
-
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct result)
-int(4)
-class stdClass {
- %s $name = 'id';
- %s $max_length = 11;
- %s $column_source = '';
- %s $numeric = 1;
- %s $type = 'int';
-}
-class stdClass {
- %s $name = 'caption';
- %s $max_length = 5;
- %s $column_source = '';
- %s $numeric = 0;
- %s $type = 'string';
-}
-class stdClass {
- %s $name = 'author';
- %s $max_length = 4;
- %s $column_source = '';
- %s $numeric = 0;
- %s $type = 'string';
-}
-class stdClass {
- %s $name = 'lastchange';
- %s $max_length = 29;
- %s $column_source = '';
- %s $numeric = 0;
- %s $type = 'datetime';
-}
-bool(true)
-class stdClass {
- %s $name = 'caption';
- %s $max_length = 5;
- %s $column_source = '';
- %s $numeric = 0;
- %s $type = 'string';
-}
diff --git a/ext/sybase_ct/tests/test_long.phpt b/ext/sybase_ct/tests/test_long.phpt
deleted file mode 100644
index 9f940d8efd..0000000000
--- a/ext/sybase_ct/tests/test_long.phpt
+++ /dev/null
@@ -1,80 +0,0 @@
---TEST--
-Sybase-CT select LONG_MAX / LONG_MIN
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- define('LONG_MAX', is_int(2147483648) ? 9223372036854775807 : 2147483647);
- define('LONG_MIN', -LONG_MAX - 1);
-
- $db= sybase_connect_ex();
- var_dump(sybase_select_db('tempdb', $db));
-
- // Create table and insert some values
- var_dump(sybase_query('create table test_long (value numeric(20, 0))'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MAX - 1).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MAX).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MAX + 1).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MIN + 1).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MIN).')'));
- var_dump(sybase_query('insert test_long values ('.(LONG_MIN - 1).')'));
-
- // Select values
- var_dump(sybase_select_ex($db, 'select value from test_long'));
-
- // Drop table
- var_dump(sybase_query('drop table test_long'));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
->>> Query: select value from test_long
-<<< Return: resource
-array(6) {
- [0]=>
- array(1) {
- ["value"]=>
- int(%s)
- }
- [1]=>
- array(1) {
- ["value"]=>
- int(%s)
- }
- [2]=>
- array(1) {
- ["value"]=>
- float(%s)
- }
- [3]=>
- array(1) {
- ["value"]=>
- int(-%s)
- }
- [4]=>
- array(1) {
- ["value"]=>
- int(-%s)
- }
- [5]=>
- array(1) {
- ["value"]=>
- float(-%s)
- }
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/test_msghandler.phpt b/ext/sybase_ct/tests/test_msghandler.phpt
deleted file mode 100644
index 742dc684ad..0000000000
--- a/ext/sybase_ct/tests/test_msghandler.phpt
+++ /dev/null
@@ -1,43 +0,0 @@
---TEST--
-Sybase-CT server message handler
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- echo 'Nonexistant: '; sybase_set_messagehandler_ex('function_does_not_exist');
- echo 'Static method: '; sybase_set_messagehandler_ex(array('sybase', 'static_handler'));
- echo 'Instance method: '; sybase_set_messagehandler_ex(array(new sybase(), 'handler'));
- echo 'Lambda function: '; sybase_set_messagehandler_ex(create_function('', 'return FALSE;'));
- echo 'Unset: '; sybase_set_messagehandler_ex(NULL);
- echo 'Incorrect type: '; sybase_set_messagehandler_ex(1);
- echo 'Function: '; sybase_set_messagehandler_ex('sybase_msg_handler');
-
- var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
- sybase_close($db);
-?>
---EXPECTF--
-Nonexistant:
-Warning: sybase_set_message_handler(): First argumented is expected to be a valid callback, 'function_does_not_exist' was given in %s/test.inc on line %d
-bool(false)
-Static method: bool(true)
-Instance method: bool(true)
-Lambda function: bool(true)
-Unset: bool(true)
-Incorrect type:
-Warning: sybase_set_message_handler(): First argumented is expected to be either NULL, an array or string, integer given in %s/test.inc on line %d
-bool(false)
-Function: bool(true)
->>> Query: select getdate(NULL)
-*** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d
- %s
-<<< Return: boolean
-bool(false)
diff --git a/ext/sybase_ct/tests/test_msghandler_handled.phpt b/ext/sybase_ct/tests/test_msghandler_handled.phpt
deleted file mode 100644
index c9ccc1ddeb..0000000000
--- a/ext/sybase_ct/tests/test_msghandler_handled.phpt
+++ /dev/null
@@ -1,69 +0,0 @@
---TEST--
-Sybase-CT server message handler
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- // {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
- // Handles server messages
- function user_message_handler($msgnumber, $severity, $state, $line, $text) {
- switch ($msgnumber) {
- case 0: // print message
- printf("!!! %s\n", trim($text));
- return;
-
- case 174: // The function 'GETDATE' requires 0 arguments.
- printf("*** Caught '%s'\n", trim($text));
- return;
- }
- printf("Cannot handle message #%d\n", $msgnumber);
- return FALSE; // Indicate we can't handle this
- }
- // }}}
-
- sybase_set_messagehandler_ex('user_message_handler');
- $db= sybase_connect_ex();
- sybase_min_server_severity(0);
-
- // These are handled
- var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
- var_dump(sybase_select_ex($db, 'print "Hi"'));
-
- // These aren't
- var_dump(sybase_select_ex($db, 'use NULL'));
- var_dump(sybase_select_ex($db, 'select convert(datetime, "notadate")'));
-
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
->>> Query: select getdate(NULL)
-*** Caught 'The function 'GETDATE' requires 0 arguments.'
-<<< Return: boolean
-bool(false)
->>> Query: print "Hi"
-!!! Hi
-<<< Return: boolean
-bool(true)
->>> Query: use NULL
-Cannot handle message #156
-
-Warning: sybase_query(): Sybase: Server message: Incorrect syntax near the keyword 'NULL'.
- (severity 15, procedure N/A) in %s on line %d
-<<< Return: boolean
-bool(false)
->>> Query: select convert(datetime, "notadate")
-Cannot handle message #249
-
-Warning: sybase_query(): Sybase: Server message: Syntax error during explicit conversion of VARCHAR value 'notadate' to a DATETIME field.
- (severity 16, procedure N/A) in %s on line %d
-<<< Return: resource
-array(0) {
-}
diff --git a/ext/sybase_ct/tests/test_query_nostore.phpt b/ext/sybase_ct/tests/test_query_nostore.phpt
deleted file mode 100644
index 9d717ec2fd..0000000000
--- a/ext/sybase_ct/tests/test_query_nostore.phpt
+++ /dev/null
@@ -1,98 +0,0 @@
---TEST--
-Sybase-CT query without storing
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
-
- // Create test table and insert some data
- var_dump(sybase_query('
- create table #test (
- id numeric(10, 0) primary key not null,
- caption varchar(255) not null,
- author varchar(50) not null,
- link varchar(255) null,
- lastchange datetime default getdate() null
- )
- ', $db));
- var_dump(sybase_query('insert into #test (
- id, caption, author
- ) values (
- 1, "Hello", "timm"
- )
- ', $db));
- var_dump(sybase_query('insert into #test (
- id, caption, author, link
- ) values (
- 2, "World", "thekid", "http://thekid.de/"
- )
- ', $db));
- var_dump(sybase_query('insert into #test (
- id, caption, author
- ) values (
- 3, "PHP", "friebe"
- )
- ', $db));
-
- // Fetch data
- $q= sybase_unbuffered_query('select * from #test order by id', $db, FALSE);
- var_dump($q);
- while ($row= sybase_fetch_assoc($q)) {
- var_dump($row);
- }
-
- // Clean up and close connection
- var_dump(sybase_query('drop table #test'));
- sybase_close($db);
-?>
---EXPECTF--
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-resource(%d) of type (sybase-ct result)
-array(5) {
- ["id"]=>
- int(1)
- ["caption"]=>
- string(5) "Hello"
- ["author"]=>
- string(4) "timm"
- ["link"]=>
- NULL
- ["lastchange"]=>
- string(%d) "%s"
-}
-array(5) {
- ["id"]=>
- int(2)
- ["caption"]=>
- string(5) "World"
- ["author"]=>
- string(6) "thekid"
- ["link"]=>
- string(17) "http://thekid.de/"
- ["lastchange"]=>
- string(%d) "%s"
-}
-array(5) {
- ["id"]=>
- int(3)
- ["caption"]=>
- string(3) "PHP"
- ["author"]=>
- string(6) "friebe"
- ["link"]=>
- NULL
- ["lastchange"]=>
- string(%d) "%s"
-}
-bool(true)
diff --git a/ext/sybase_ct/tests/test_types.phpt b/ext/sybase_ct/tests/test_types.phpt
deleted file mode 100644
index 735c02d843..0000000000
--- a/ext/sybase_ct/tests/test_types.phpt
+++ /dev/null
@@ -1,87 +0,0 @@
---TEST--
-Sybase-CT select and types
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- define('LONG_MAX', is_int(2147483648) ? 9223372036854775807 : 2147483647);
- define('LONG_MIN', -LONG_MAX - 1);
-
- $db= sybase_connect_ex();
- var_dump(sybase_select_ex($db, 'select
- 1 as "integer",
- '.(LONG_MIN).' as "integer_min",
- '.(LONG_MIN - 1).' as "integer_min_exceed",
- '.(LONG_MAX).' as "integer_max",
- '.(LONG_MAX + 1).' as "integer_max_exceed",
- 1.0 as "float",
- 12345678901234567890123456789012.123456 as "large_float",
- $22.36 as "money",
- "Binford" as "string",
- convert(datetime, "2004-01-23") as "date",
- NULL as "null",
- convert(bit, 1) as "bit",
- convert(smalldatetime, "2004-01-23") as "smalldate",
- convert(char(10), "char") as "char10"
- '));
-
- sybase_close($db);
-?>
---EXPECTF--
->>> Query: select
- 1 as "integer",
- -%s as "integer_min",
- -%s as "integer_min_exceed",
- %s as "integer_max",
- %s as "integer_max_exceed",
- 1.0 as "float",
- 12345678901234567890123456789012.123456 as "large_float",
- $22.36 as "money",
- "Binford" as "string",
- convert(datetime, "2004-01-23") as "date",
- NULL as "null",
- convert(bit, 1) as "bit",
- convert(smalldatetime, "2004-01-23") as "smalldate",
- convert(char(10), "char") as "char10"
-
-<<< Return: resource
-array(1) {
- [0]=>
- array(%d) {
- ["integer"]=>
- int(1)
- ["integer_min"]=>
- int(-%s)
- ["integer_min_exceed"]=>
- float(-%s)
- ["integer_max"]=>
- int(%s)
- ["integer_max_exceed"]=>
- float(%s)
- ["float"]=>
- float(1)
- ["large_float"]=>
- string(39) "12345678901234567890123456789012.123456"
- ["money"]=>
- float(22.36)
- ["string"]=>
- string(7) "Binford"
- ["date"]=>
- string(19) "Jan 23 2004 12:00AM"
- ["null"]=>
- NULL
- ["bit"]=>
- int(1)
- ["smalldate"]=>
- string(19) "Jan 23 2004 12:00AM"
- ["char10"]=>
- string(10) "char "
- }
-}
diff --git a/ext/sybase_ct/tests/test_unbuffered_query.phpt b/ext/sybase_ct/tests/test_unbuffered_query.phpt
deleted file mode 100644
index 74b10143b2..0000000000
--- a/ext/sybase_ct/tests/test_unbuffered_query.phpt
+++ /dev/null
@@ -1,57 +0,0 @@
---TEST--
-Sybase-CT unbuffered query
---SKIPIF--
-<?php require('skipif.inc'); ?>
---FILE--
-<?php
-/* This file is part of PHP test framework for ext/sybase_ct
- *
- * $Id$
- */
-
- require('test.inc');
-
- $db= sybase_connect_ex();
- var_dump($db);
-
- // Test #1: num_rows
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q);
- $i= 0;
- while ($r= sybase_fetch_assoc($q)) {
- $i++;
- }
- var_dump($i, sybase_num_rows($q), $i == sybase_num_rows($q), $q);
- sybase_free_result($q);
- var_dump($q);
-
- // Test #2: after sybase_free_result, this should be an invalid resource
- var_dump(FALSE == sybase_num_rows($q));
-
- // Test #3: Seeking
- $q= sybase_unbuffered_query('select name from master..systypes', $db);
- var_dump($q);
- $j= 0;
- sybase_data_seek($q, 4);
- while ($r= sybase_fetch_assoc($q)) {
- $j++;
- }
- var_dump($i, $j, $i - $j);
-
- sybase_close($db);
-?>
---EXPECTF--
-resource(%d) of type (sybase-ct link)
-resource(%d) of type (sybase-ct result)
-int(%d)
-int(%d)
-bool(true)
-resource(%d) of type (sybase-ct result)
-resource(%d) of type (Unknown)
-
-Warning: sybase_num_rows(): %d is not a valid Sybase result resource in %s/test_unbuffered_query.php on line %d
-bool(true)
-resource(%d) of type (sybase-ct result)
-int(%d)
-int(%d)
-int(4)