Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Wroniszewski <jan@industreal.pl>2016-11-11 03:50:50 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2016-11-11 03:50:50 +0300
commit259fc6d7819257033222234bfed7619a0c5282f9 (patch)
treea1f873b9831e5d3d39e02fc689c8ec1d4a9bb757 /tests/PHPUnit
parentdda85d6dbf3ca890543b89c8a491c5e592445b9d (diff)
#10547 Bad regexp in DbHelper.php (#10688)
Diffstat (limited to 'tests/PHPUnit')
-rw-r--r--tests/PHPUnit/Unit/DbHelperTest.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/PHPUnit/Unit/DbHelperTest.php b/tests/PHPUnit/Unit/DbHelperTest.php
new file mode 100644
index 0000000000..fa6957d4ba
--- /dev/null
+++ b/tests/PHPUnit/Unit/DbHelperTest.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Tests\Unit;
+
+use Piwik\DbHelper;
+
+/**
+ * Class DbHelperTest
+ * @package Piwik\Tests\Unit
+ * @group Core
+ * @group Core_Unit
+ */
+class DbHelperTest extends \PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @dataProvider getVariousDbNames
+ * @param string $dbName
+ * @param bool $expectation
+ */
+ public function testCorrectNames($dbName, $expectation)
+ {
+ $this->assertSame(DbHelper::isValidDbname($dbName), $expectation);
+ }
+
+ public function getVariousDbNames()
+ {
+ return array(
+ 'simpleDbName' => array(
+ 'dbName' => 'FirstPiwikDb',
+ 'expectation' => true
+ ),
+ 'containsNumbers' => array(
+ 'dbName' => 'FirstPiw1kDb',
+ 'expectation' => true
+ ),
+ 'startsWithNumber' => array(
+ 'dbName' => '1stPiwikDb',
+ 'expectation' => true
+ ),
+ 'containsAllowedSpecialCharacters' => array(
+ 'dbName' => 'MyPiwikDb-with.More+compleX_N4M3',
+ 'expectation' => true
+ ),
+ 'containsSpace' => array(
+ 'dbName' => '1st PiwikDb',
+ 'expectation' => false
+ ),
+ 'startWithNonAlphaNumericSign' => array(
+ 'dbName' => ';FirstPiwikDb',
+ 'expectation' => false
+ ),
+ );
+ }
+}