Fix CheckSetupController tests
This commit is contained in:
parent
ab9a8ce952
commit
81467f7c4e
|
@ -206,6 +206,18 @@ class CheckSetupController extends Controller {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the version is outdated
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isPhpOutdated() {
|
||||||
|
if (version_compare(PHP_VERSION, '5.5.0') === -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the php version is still supported (at time of release)
|
* Whether the php version is still supported (at time of release)
|
||||||
* according to: https://secure.php.net/supported-versions.php
|
* according to: https://secure.php.net/supported-versions.php
|
||||||
|
@ -213,14 +225,7 @@ class CheckSetupController extends Controller {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function isPhpSupported() {
|
private function isPhpSupported() {
|
||||||
$eol = false;
|
return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
|
||||||
|
|
||||||
//PHP 5.4 is EOL on 14 Sep 2015
|
|
||||||
if (version_compare(PHP_VERSION, '5.5.0') === -1) {
|
|
||||||
$eol = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['eol' => $eol, 'version' => PHP_VERSION];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,25 +35,12 @@ use OC_Util;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
use OC\IntegrityCheck\Checker;
|
use OC\IntegrityCheck\Checker;
|
||||||
|
|
||||||
/**
|
|
||||||
* Mock version_compare
|
|
||||||
* @param string $version1
|
|
||||||
* @param string $version2
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
function version_compare($version1, $version2) {
|
|
||||||
return CheckSetupControllerTest::$version_compare;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CheckSetupControllerTest
|
* Class CheckSetupControllerTest
|
||||||
*
|
*
|
||||||
* @package Tests\Settings\Controller
|
* @package Tests\Settings\Controller
|
||||||
*/
|
*/
|
||||||
class CheckSetupControllerTest extends TestCase {
|
class CheckSetupControllerTest extends TestCase {
|
||||||
/** @var int */
|
|
||||||
public static $version_compare;
|
|
||||||
|
|
||||||
/** @var CheckSetupController */
|
/** @var CheckSetupController */
|
||||||
private $checkSetupController;
|
private $checkSetupController;
|
||||||
/** @var IRequest */
|
/** @var IRequest */
|
||||||
|
@ -106,7 +93,7 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
$this->l10n,
|
$this->l10n,
|
||||||
$this->checker,
|
$this->checker,
|
||||||
])
|
])
|
||||||
->setMethods(['getCurlVersion'])->getMock();
|
->setMethods(['getCurlVersion', 'isPhpOutdated'])->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsInternetConnectionWorkingDisabledViaConfig() {
|
public function testIsInternetConnectionWorkingDisabledViaConfig() {
|
||||||
|
@ -233,7 +220,11 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsPhpSupportedFalse() {
|
public function testIsPhpSupportedFalse() {
|
||||||
self::$version_compare = -1;
|
$this->checkSetupController
|
||||||
|
->expects($this->once())
|
||||||
|
->method('isPhpOutdated')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
['eol' => true, 'version' => PHP_VERSION],
|
['eol' => true, 'version' => PHP_VERSION],
|
||||||
|
@ -242,16 +233,15 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsPhpSupportedTrue() {
|
public function testIsPhpSupportedTrue() {
|
||||||
self::$version_compare = 0;
|
$this->checkSetupController
|
||||||
|
->expects($this->exactly(2))
|
||||||
|
->method('isPhpOutdated')
|
||||||
|
->willReturn(false);
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
['eol' => false, 'version' => PHP_VERSION],
|
['eol' => false, 'version' => PHP_VERSION],
|
||||||
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
self::$version_compare = 1;
|
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
['eol' => false, 'version' => PHP_VERSION],
|
['eol' => false, 'version' => PHP_VERSION],
|
||||||
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
|
||||||
|
@ -335,7 +325,10 @@ class CheckSetupControllerTest extends TestCase {
|
||||||
->method('linkToDocs')
|
->method('linkToDocs')
|
||||||
->with('admin-security')
|
->with('admin-security')
|
||||||
->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
|
->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
|
||||||
self::$version_compare = -1;
|
$this->checkSetupController
|
||||||
|
->expects($this->once())
|
||||||
|
->method('isPhpOutdated')
|
||||||
|
->willReturn(true);
|
||||||
$this->urlGenerator->expects($this->at(2))
|
$this->urlGenerator->expects($this->at(2))
|
||||||
->method('linkToDocs')
|
->method('linkToDocs')
|
||||||
->with('admin-reverse-proxy')
|
->with('admin-reverse-proxy')
|
||||||
|
|
Loading…
Reference in New Issue