12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- 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']],
- ['db.example.org', ['host' => 'db.example.org']],
- ['unix', ['host' => 'unix']],
- ['[::1]', ['host' => '[::1]']],
- ['127.0.0.1:3306', ['host' => '127.0.0.1', 'port' => 3306]],
- ['db.example.org:3306', ['host' => 'db.example.org', 'port' => 3306]],
- ['unix:3306', ['host' => 'unix', 'port' => 3306]],
- ['[::1]:3306', ['host' => '[::1]', 'port' => 3306]],
- ['unix:/socket', ['host' => 'unix', 'unix_socket' => '/socket']],
- ];
- }
-
- public function testSplitHostFromPortAndSocket($host, array $expected) {
-
- $config = $this->createMock(SystemConfig::class);
- $factory = new ConnectionFactory($config);
- $this->assertEquals($expected, self::invokePrivate($factory, 'splitHostFromPortAndSocket', [$host]));
- }
- }
|