From 506cba0dc9d094ce148ea144972a7871885b9a67 Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 4 Nov 2007 18:05:00 +0000 Subject: [PATCH] Removing dependency on default database connection from all test cases git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5944 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/sanitize.php | 2 +- .../model/datasources/dbo/dbo_mssql.test.php | 10 ++--- .../model/datasources/dbo/dbo_mysql.test.php | 7 +--- cake/tests/cases/libs/sanitize.test.php | 39 +++++++++++-------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/cake/libs/sanitize.php b/cake/libs/sanitize.php index 32f4fc441..7d42070ee 100644 --- a/cake/libs/sanitize.php +++ b/cake/libs/sanitize.php @@ -35,7 +35,7 @@ * @package cake * @subpackage cake.cake.libs */ -class Sanitize{ +class Sanitize { /** * Removes any non-alphanumeric characters. * diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php index 222d2f652..60ba9b7db 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php @@ -72,7 +72,7 @@ } function schema() { - return array( + $this->_schema = array( 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), @@ -92,6 +92,7 @@ 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) ); + return $this->_schema; } } @@ -101,7 +102,7 @@ * @package cake.tests * @subpackage cake.tests.cases.libs.model.datasources.dbo */ -class DboMssqlTest extends UnitTestCase { +class DboMssqlTest extends CakeTestCase { /** * The Dbo instance to be tested * @@ -115,10 +116,7 @@ class DboMssqlTest extends UnitTestCase { * @access public */ function setUp() { - require_once APP . 'config' . DS . 'database.php'; - $config = new DATABASE_CONFIG(); - $this->db =& new DboMssqlTestDb($config->default, false); - $this->db->fullDebug = false; + $this->_initDb(); $this->model = new MssqlTestModel(); } diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index 6c1c76a51..eae564eeb 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -100,7 +100,7 @@ class MysqlTestModel extends Model { * @package cake.tests * @subpackage cake.tests.cases.libs.model.datasources.dbo */ -class DboMysqlTest extends UnitTestCase { +class DboMysqlTest extends CakeTestCase { /** * The Dbo instance to be tested * @@ -126,10 +126,7 @@ class DboMysqlTest extends UnitTestCase { * @access public */ function setUp() { - require_once APP . 'config' . DS . 'database.php'; - $config = new DATABASE_CONFIG(); - $this->Db =& new DboMysqlTestDb($config->default); - $this->Db->fullDebug = false; + $this->_initDb(); $this->model = new MysqlTestModel(); } /** diff --git a/cake/tests/cases/libs/sanitize.test.php b/cake/tests/cases/libs/sanitize.test.php index 4fe1c5105..c5f731016 100644 --- a/cake/tests/cases/libs/sanitize.test.php +++ b/cake/tests/cases/libs/sanitize.test.php @@ -33,68 +33,73 @@ uses('sanitize'); * @package cake.tests * @subpackage cake.tests.cases.libs */ -class SanitizeTest extends UnitTestCase { +class SanitizeTest extends CakeTestCase { + + function startTest($method) { + parent::startTest($method); + $this->_initDb(); + } function testEscapeAlphaNumeric() { - $resultAlpha = Sanitize::escape('abc', 'default'); + $resultAlpha = Sanitize::escape('abc', 'test_suite'); $this->assertEqual($resultAlpha, 'abc'); - $resultNumeric = Sanitize::escape('123', 'default'); + $resultNumeric = Sanitize::escape('123', 'test_suite'); $this->assertEqual($resultNumeric, '123'); - $resultNumeric = Sanitize::escape(1234, 'default'); + $resultNumeric = Sanitize::escape(1234, 'test_suite'); $this->assertEqual($resultNumeric, 1234); - $resultNumeric = Sanitize::escape(1234.23, 'default'); + $resultNumeric = Sanitize::escape(1234.23, 'test_suite'); $this->assertEqual($resultNumeric, 1234.23); - $resultNumeric = Sanitize::escape('#1234.23', 'default'); + $resultNumeric = Sanitize::escape('#1234.23', 'test_suite'); $this->assertEqual($resultNumeric, '#1234.23'); - $resultNull = Sanitize::escape(null, 'default'); + $resultNull = Sanitize::escape(null, 'test_suite'); $this->assertEqual($resultNull, null); - $resultNull = Sanitize::escape(false, 'default'); + $resultNull = Sanitize::escape(false, 'test_suite'); $this->assertEqual($resultNull, false); - $resultNull = Sanitize::escape(true, 'default'); + $resultNull = Sanitize::escape(true, 'test_suite'); $this->assertEqual($resultNull, true); } function testClean() { $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" 'other' ;.$ symbol.another line'; - $result = Sanitize::clean($string); + $result = Sanitize::clean($string, array('connection' => 'test_suite')); $this->assertEqual($result, $expected); $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; - $expected = 'test & ' . Sanitize::escape('"quote"') . ' ' . Sanitize::escape('\'other\'') . ' ;.$ symbol.another line'; - $result = Sanitize::clean($string, array('encode' => false)); + $expected = 'test & ' . Sanitize::escape('"quote"', 'test_suite') . ' ' . Sanitize::escape('\'other\'', 'test_suite') . ' ;.$ symbol.another line'; + $result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ $ symbol.another line'; - $result = Sanitize::clean($string, array('encode' => false, 'escape' => false)); + $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ \\$ symbol.another line'; - $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false)); + $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; - $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false)); + $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); $array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line')); $expected = array(array('test & "quote" 'other' ;.$ symbol.another line')); - $result = Sanitize::clean($array); + $result = Sanitize::clean($array, array('connection' => 'test_suite')); $this->assertEqual($result, $expected); $array = array(array('test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line')); $expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line')); - $result = Sanitize::clean($array, array('encode' => false, 'escape' => false)); + $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test_suite')); $this->assertEqual($result, $expected); } }