mirror of https://github.com/nextcloud/server.git
Make supported DBs configurable within config.php
This commit will make the supported DBs for installation configurable within config.php. By default the following databases are tested: "sqlite", "mysql", "pgsql". The reason behind this is that there might be instances where we want to prevent SQLite to be used by mistake. To test this play around with the new configuration parameter "supportedDatabases".remotes/origin/fix-10825
parent
25a4b5a935
commit
233c49f4b9
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
use OCP\IConfig;
|
||||
|
||||
class Test_OC_Setup extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/** @var IConfig */
|
||||
protected $config;
|
||||
/** @var \OC_Setup */
|
||||
protected $setupClass;
|
||||
|
||||
public function setUp() {
|
||||
$this->config = $this->getMock('\OCP\IConfig');
|
||||
$this->setupClass = $this->getMock('\OC_Setup', array('class_exists', 'is_callable'), array($this->config));
|
||||
}
|
||||
|
||||
public function testGetSupportedDatabasesWithOneWorking() {
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getSystemValue')
|
||||
->will($this->returnValue(
|
||||
array('sqlite', 'mysql', 'oci')
|
||||
));
|
||||
$this->setupClass
|
||||
->expects($this->once())
|
||||
->method('class_exists')
|
||||
->will($this->returnValue(true));
|
||||
$this->setupClass
|
||||
->expects($this->exactly(2))
|
||||
->method('is_callable')
|
||||
->will($this->returnValue(false));
|
||||
$result = $this->setupClass->getSupportedDatabases();
|
||||
$expectedResult = array(
|
||||
'sqlite' => 'SQLite'
|
||||
);
|
||||
|
||||
$this->assertSame($expectedResult, $result);
|
||||
}
|
||||
|
||||
public function testGetSupportedDatabasesWithNoWorking() {
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getSystemValue')
|
||||
->will($this->returnValue(
|
||||
array('sqlite', 'mysql', 'oci', 'pgsql')
|
||||
));
|
||||
$this->setupClass
|
||||
->expects($this->once())
|
||||
->method('class_exists')
|
||||
->will($this->returnValue(false));
|
||||
$this->setupClass
|
||||
->expects($this->exactly(3))
|
||||
->method('is_callable')
|
||||
->will($this->returnValue(false));
|
||||
$result = $this->setupClass->getSupportedDatabases();
|
||||
|
||||
$this->assertSame(array(), $result);
|
||||
}
|
||||
|
||||
public function testGetSupportedDatabasesWitAllWorking() {
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getSystemValue')
|
||||
->will($this->returnValue(
|
||||
array('sqlite', 'mysql', 'pgsql', 'oci', 'mssql')
|
||||
));
|
||||
$this->setupClass
|
||||
->expects($this->once())
|
||||
->method('class_exists')
|
||||
->will($this->returnValue(true));
|
||||
$this->setupClass
|
||||
->expects($this->exactly(4))
|
||||
->method('is_callable')
|
||||
->will($this->returnValue(true));
|
||||
$result = $this->setupClass->getSupportedDatabases();
|
||||
$expectedResult = array(
|
||||
'sqlite' => 'SQLite',
|
||||
'mysql' => 'MySQL/MariaDB',
|
||||
'pgsql' => 'PostgreSQL',
|
||||
'oci' => 'Oracle',
|
||||
'mssql' => 'MS SQL'
|
||||
);
|
||||
$this->assertSame($expectedResult, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage Supported databases are not properly configured.
|
||||
*/
|
||||
public function testGetSupportedDatabaseException() {
|
||||
$this->config
|
||||
->expects($this->once())
|
||||
->method('getSystemValue')
|
||||
->will($this->returnValue('NotAnArray'));
|
||||
$this->setupClass->getSupportedDatabases();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue