Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/firstrunwizard.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2019-03-25 17:23:29 +0300
committerJulius Härtl <jus@bitgrid.net>2019-03-25 17:23:29 +0300
commitf6f1538851b9537fdd728e05449bff58584111c9 (patch)
treecd359ff6ffe6e281da0678f90d4133d4498a485a /tests/Controller
parent18d22c2c6c734ff0bd8c8ec2570c92176567dc91 (diff)
Only load apps page for admins
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'tests/Controller')
-rw-r--r--tests/Controller/WizardControllerTest.php31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/Controller/WizardControllerTest.php b/tests/Controller/WizardControllerTest.php
index 687bfd24..2319471e 100644
--- a/tests/Controller/WizardControllerTest.php
+++ b/tests/Controller/WizardControllerTest.php
@@ -30,6 +30,7 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\Defaults;
use OCP\IConfig;
+use OCP\IGroupManager;
use OCP\IRequest;
use Test\TestCase;
@@ -42,10 +43,13 @@ use Test\TestCase;
class WizardControllerTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
protected $config;
+ private $groupManager;
protected function setUp() {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
+ $this->groupManager = $this->createMock(IGroupManager::class);
+
}
/**
@@ -58,7 +62,8 @@ class WizardControllerTest extends TestCase {
$this->createMock(IRequest::class),
$this->config,
$user,
- \OC::$server->query(Defaults::class)
+ \OC::$server->query(Defaults::class),
+ $this->groupManager
);
}
@@ -87,9 +92,31 @@ class WizardControllerTest extends TestCase {
}
- public function testShow() {
+ public function testShowUser() {
+ $controller = $this->getController();
+
+ $this->config->expects($this->exactly(4))
+ ->method('getSystemValue')
+ ->willReturnMap([
+ ['customclient_desktop', 'https://nextcloud.com/install/#install-clients', 'https://nextcloud.com/install/#install-clients'],
+ ['customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client', 'https://nextcloud.com/install/#install-clients'],
+ ['customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', 'https://nextcloud.com/install/#install-clients'],
+ ['appstoreenabled', true, true]
+ ]);
+
+ $response = $controller->show();
+
+ $this->assertInstanceOf(JSONResponse::class, $response);
+ $this->assertSame(Http::STATUS_OK, $response->getStatus());
+ $this->assertEquals(4, count($response->getData()));
+ }
+
+ public function testShowAdmin() {
$controller = $this->getController();
+ $this->groupManager->expects($this->once())
+ ->method('isAdmin')
+ ->willReturn(true);
$this->config->expects($this->exactly(4))
->method('getSystemValue')
->willReturnMap([