2014-10-27 11:51:26 +00:00
|
|
|
<?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;
|
|
|
|
|
2014-11-10 21:59:50 +00:00
|
|
|
class Test_OC_Setup extends \Test\TestCase {
|
2014-10-27 11:51:26 +00:00
|
|
|
|
|
|
|
/** @var IConfig */
|
|
|
|
protected $config;
|
2015-02-21 19:51:50 +00:00
|
|
|
/** @var \OC\Setup */
|
2014-10-27 11:51:26 +00:00
|
|
|
protected $setupClass;
|
|
|
|
|
2014-11-10 21:59:50 +00:00
|
|
|
protected function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2014-10-27 11:51:26 +00:00
|
|
|
$this->config = $this->getMock('\OCP\IConfig');
|
2015-02-21 19:51:50 +00:00
|
|
|
$this->setupClass = $this->getMock('\OC\Setup', ['class_exists', 'is_callable'], [$this->config]);
|
2014-10-27 11:51:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2015-01-08 11:05:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is actual more an integration test whether the version parameter in the .htaccess
|
|
|
|
* was updated as well when the version has been incremented.
|
|
|
|
* If it hasn't this test will fail.
|
|
|
|
*/
|
|
|
|
public function testHtaccessIsCurrent() {
|
|
|
|
$result = Test_Helper::invokePrivate(
|
|
|
|
$this->setupClass,
|
|
|
|
'isCurrentHtaccess'
|
|
|
|
);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
2015-02-21 19:51:50 +00:00
|
|
|
}
|