cvs: pear /MDB2/tests MDB2_function_testcase.php

From: Date: Tue, 12 Feb 2008 23:13:54 +0000
Subject: cvs: pear /MDB2/tests MDB2_function_testcase.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-50995@lists.php.net to get a copy of this message
quipo Tue Feb 12 23:13:54 2008 UTC Modified files: /pear/MDB2/tests MDB2_function_testcase.php Log: test REPLACE() http://cvs.php.net/viewvc.cgi/pear/MDB2/tests/MDB2_function_testcase.php?r1=1.22&r2=1.23&diff_format=u Index: pear/MDB2/tests/MDB2_function_testcase.php diff -u pear/MDB2/tests/MDB2_function_testcase.php:1.22 pear/MDB2/tests/MDB2_function_testcase.php:1.23 --- pear/MDB2/tests/MDB2_function_testcase.php:1.22 Sat Aug 11 16:36:11 2007 +++ pear/MDB2/tests/MDB2_function_testcase.php Tue Feb 12 23:13:54 2008 @@ -41,7 +41,7 @@ // | Author: Lorenzo Alberton <l dot alberton at quipo dot it> | // +----------------------------------------------------------------------+ // -// $Id: MDB2_function_testcase.php,v 1.22 2007/08/11 16:36:11 quipo Exp $ +// $Id: MDB2_function_testcase.php,v 1.23 2008/02/12 23:13:54 quipo Exp $ class MDB2_Function_TestCase extends MDB2_TestCase { @@ -245,5 +245,37 @@ $this->assertEquals(3, $len, 'Error: incorrect length for "foo" string: '.$len); } } + + /** + * Test replace() + */ + function testReplace() + { + if (!$this->methodExists($this->db->function, 'replace')) { + return; + } + + $string = $this->db->quote('so what'); + $search = $this->db->quote('o'); + $replace = $this->db->quote('ay'); + $replace_clause = $this->db->function->replace($string, $search, $replace); + $this->db->pushErrorHandling(PEAR_ERROR_RETURN); + $this->db->expectError(MDB2_ERROR_UNSUPPORTED); + $replace_clause = $this->db->function->replace($string, $search, $replace); + $this->db->popExpect(); + $this->db->popErrorHandling(); + if (PEAR::isError($replace_clause) && $replace_clause->getCode() == MDB2_ERROR_UNSUPPORTED) { + return; + } + + $functionTable_clause = $this->db->function->functionTable(); + $query = 'SELECT '.$replace_clause . $functionTable_clause; + $result = $this->db->queryOne($query, 'text'); + if (PEAR::isError($result)) { + $this->assertFalse(true, 'Error getting replaced value:'. $result->getMessage()); + } else { + $this->assertEquals('say what', $result, 'Error: could not get replace string: '.$result); + } + } } ?> \ No newline at end of file

« previous php.pear.cvs (#50995) next »