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
This commit is contained in:
nate 2007-11-04 18:05:00 +00:00
parent 5ccea91b91
commit 506cba0dc9
4 changed files with 29 additions and 29 deletions

View file

@ -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();
}

View file

@ -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();
}
/**

View file

@ -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);
}
}