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
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-08-15 22:55:09 +0300
committerLukas Reschke <lukas@statuscode.ch>2016-08-15 22:55:09 +0300
commit6c6338b81072ba58b662d2f03cab6cfdbfdf4a18 (patch)
tree7e5bf139a601f03dc7c458d7ef84881e63b5ee20 /tests/Settings
parent7ffb7b0d846241c8cc6b45a3c85b2374c6d026ae (diff)
parent2061d40ba292d2b906132dfcd261e4c631d9854b (diff)
Merge branch 'master' into implement_712
Diffstat (limited to 'tests/Settings')
-rw-r--r--tests/Settings/Controller/AuthSettingsControllerTest.php1
-rw-r--r--tests/Settings/Controller/CheckSetupControllerTest.php86
2 files changed, 27 insertions, 60 deletions
diff --git a/tests/Settings/Controller/AuthSettingsControllerTest.php b/tests/Settings/Controller/AuthSettingsControllerTest.php
index 1705cb5ddf1..b57aea0930c 100644
--- a/tests/Settings/Controller/AuthSettingsControllerTest.php
+++ b/tests/Settings/Controller/AuthSettingsControllerTest.php
@@ -91,6 +91,7 @@ class AuthSettingsControllerTest extends TestCase {
'lastActivity' => null,
'type' => null,
'canDelete' => false,
+ 'current' => true,
],
[
'id' => 200,
diff --git a/tests/Settings/Controller/CheckSetupControllerTest.php b/tests/Settings/Controller/CheckSetupControllerTest.php
index 770d5a4934e..e4f66b5d879 100644
--- a/tests/Settings/Controller/CheckSetupControllerTest.php
+++ b/tests/Settings/Controller/CheckSetupControllerTest.php
@@ -37,24 +37,11 @@ use Test\TestCase;
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
*
* @package Tests\Settings\Controller
*/
class CheckSetupControllerTest extends TestCase {
- /** @var int */
- public static $version_compare;
-
/** @var CheckSetupController */
private $checkSetupController;
/** @var IRequest */
@@ -111,7 +98,7 @@ class CheckSetupControllerTest extends TestCase {
$this->checker,
$this->logger
])
- ->setMethods(['getCurlVersion'])->getMock();
+ ->setMethods(['getCurlVersion', 'isPhpOutdated'])->getMock();
}
public function testIsInternetConnectionWorkingDisabledViaConfig() {
@@ -136,12 +123,8 @@ class CheckSetupControllerTest extends TestCase {
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
->disableOriginalConstructor()->getMock();
- $client->expects($this->at(0))
- ->method('get')
- ->with('https://www.owncloud.org/', []);
- $client->expects($this->at(1))
- ->method('get')
- ->with('http://www.owncloud.org/', []);
+ $client->expects($this->any())
+ ->method('get');
$this->clientService->expects($this->once())
->method('newClient')
@@ -156,7 +139,7 @@ class CheckSetupControllerTest extends TestCase {
);
}
- public function testIsInternetConnectionHttpsFail() {
+ public function testIsInternetConnectionFail() {
$this->config->expects($this->once())
->method('getSystemValue')
->with('has_internet_connection', true)
@@ -164,12 +147,11 @@ class CheckSetupControllerTest extends TestCase {
$client = $this->getMockBuilder('\OCP\Http\Client\IClient')
->disableOriginalConstructor()->getMock();
- $client->expects($this->at(0))
+ $client->expects($this->any())
->method('get')
- ->with('https://www.owncloud.org/', [])
->will($this->throwException(new \Exception()));
- $this->clientService->expects($this->once())
+ $this->clientService->expects($this->exactly(3))
->method('newClient')
->will($this->returnValue($client));
@@ -181,33 +163,6 @@ class CheckSetupControllerTest extends TestCase {
);
}
- public function testIsInternetConnectionHttpFail() {
- $this->config->expects($this->once())
- ->method('getSystemValue')
- ->with('has_internet_connection', true)
- ->will($this->returnValue(true));
-
- $client = $this->getMockBuilder('\OCP\Http\Client\IClient')
- ->disableOriginalConstructor()->getMock();
- $client->expects($this->at(0))
- ->method('get')
- ->with('https://www.owncloud.org/', []);
- $client->expects($this->at(1))
- ->method('get')
- ->with('http://www.owncloud.org/', [])
- ->will($this->throwException(new \Exception()));
-
- $this->clientService->expects($this->once())
- ->method('newClient')
- ->will($this->returnValue($client));
-
- $this->assertFalse(
- self::invokePrivate(
- $this->checkSetupController,
- 'isInternetConnectionWorking'
- )
- );
- }
public function testIsMemcacheConfiguredFalse() {
$this->config->expects($this->once())
@@ -238,7 +193,10 @@ class CheckSetupControllerTest extends TestCase {
}
public function testIsPhpSupportedFalse() {
- self::$version_compare = -1;
+ $this->checkSetupController
+ ->expects($this->once())
+ ->method('isPhpOutdated')
+ ->willReturn(true);
$this->assertEquals(
['eol' => true, 'version' => PHP_VERSION],
@@ -247,7 +205,10 @@ class CheckSetupControllerTest extends TestCase {
}
public function testIsPhpSupportedTrue() {
- self::$version_compare = 0;
+ $this->checkSetupController
+ ->expects($this->exactly(2))
+ ->method('isPhpOutdated')
+ ->willReturn(false);
$this->assertEquals(
['eol' => false, 'version' => PHP_VERSION],
@@ -255,8 +216,6 @@ class CheckSetupControllerTest extends TestCase {
);
- self::$version_compare = 1;
-
$this->assertEquals(
['eol' => false, 'version' => PHP_VERSION],
self::invokePrivate($this->checkSetupController, 'isPhpSupported')
@@ -323,13 +282,17 @@ class CheckSetupControllerTest extends TestCase {
->disableOriginalConstructor()->getMock();
$client->expects($this->at(0))
->method('get')
- ->with('https://www.owncloud.org/', []);
+ ->with('http://www.nextcloud.com/', [])
+ ->will($this->throwException(new \Exception()));
$client->expects($this->at(1))
->method('get')
- ->with('http://www.owncloud.org/', [])
+ ->with('http://www.google.com/', [])
->will($this->throwException(new \Exception()));
-
- $this->clientService->expects($this->once())
+ $client->expects($this->at(2))
+ ->method('get')
+ ->with('http://www.github.com/', [])
+ ->will($this->throwException(new \Exception()));
+ $this->clientService->expects($this->exactly(3))
->method('newClient')
->will($this->returnValue($client));
$this->urlGenerator->expects($this->at(0))
@@ -340,7 +303,10 @@ class CheckSetupControllerTest extends TestCase {
->method('linkToDocs')
->with('admin-security')
->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))
->method('linkToDocs')
->with('admin-reverse-proxy')