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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2018-04-19 13:49:36 +0300
committerJoas Schilling <coding@schilljs.com>2018-05-09 11:50:56 +0300
commit7bb44214a185c610120789c8014ccef454e7dba5 (patch)
treece2b9fcce3ae5af0c60c8db576014d7f6ca04166 /tests
parent02388a39423ef403f677e810b1f20504693e7714 (diff)
Move regex to a function and add tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/DB/ConnectionFactoryTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/lib/DB/ConnectionFactoryTest.php b/tests/lib/DB/ConnectionFactoryTest.php
new file mode 100644
index 00000000000..6b8545ab071
--- /dev/null
+++ b/tests/lib/DB/ConnectionFactoryTest.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\DB;
+
+use OC\DB\ConnectionFactory;
+use OC\SystemConfig;
+use Test\TestCase;
+
+class ConnectionFactoryTest extends TestCase {
+
+ public function splitHostFromPortAndSocketData() {
+ return [
+ ['127.0.0.1', ['host' => '127.0.0.1']],
+ ['[::1]', ['host' => '[::1]']],
+ ['127.0.0.1:3306', ['host' => '127.0.0.1', 'port' => 3306]],
+ ['[::1]:3306', ['host' => '[::1]', 'port' => 3306]],
+ ['unix:/socket', ['host' => 'unix', 'unix_socket' => '/socket']],
+ ];
+ }
+
+ /**
+ * @dataProvider splitHostFromPortAndSocketData
+ * @param string $host
+ * @param array $expected
+ */
+ public function testSplitHostFromPortAndSocket($host, array $expected) {
+ /** @var SystemConfig $config */
+ $config = $this->createMock(SystemConfig::class);
+ $factory = new ConnectionFactory($config);
+
+ $this->assertEquals($expected, self::invokePrivate($factory, 'splitHostFromPortAndSocket', [$host]));
+ }
+}