From 45b8252d0e5f1ea70e8b700c1d287d5749e576ff Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 8 Feb 2016 20:29:59 +0530 Subject: [PATCH] --CRM-16617, added unit test --- tests/phpunit/CRM/Core/DAOTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index fd4cce327c..6d8c061416 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -223,4 +223,29 @@ 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); + } + } + } -- 2.25.1