From: Pradeep Nayak Date: Mon, 8 Feb 2016 14:59:59 +0000 (+0530) Subject: --CRM-16617, added unit test X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fd542660fede6c89ad660d643a9a510e64ea0605;p=civicrm-core.git --CRM-16617, added unit test --- diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index 9fae687224..9e9b66b76c 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -224,4 +224,28 @@ class CRM_Core_DAOTest extends CiviUnitTestCase { $this->assertTrue($exception_thrown); } + /** + * requireValidDBName() method (to check valid database name) + */ + public function testRequireValidDBName() { + $databases = array( + 'testdb' => TRUE, + 'test_db' => TRUE, + 'TEST_db' => TRUE, + '123testdb' => TRUE, + 'test12db34' => TRUE, + 'test_12_db34' => TRUE, + 'test-db' => FALSE, + 'test;db' => FALSE, + 'test*&db' => FALSE, + 'testdb;Delete test' => FALSE, + '123456' => FALSE, + 'test#$%^&*' => FALSE, + ); + $testDetails = array(); + foreach ($databases as $database => $val) { + $this->assertEquals(CRM_Core_DAO::requireValidDBName($database, $testDetails), $val); + } + } + }