Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/Controller/WizardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@ public function disable() {
* @return JsonResponse
*/
public function show() {
$appStore = $this->config->getSystemValue('appstoreenabled', true);

$data = [
'desktop' => $this->config->getSystemValue('customclient_desktop', $this->theming->getSyncClientUrl()),
'android' => $this->config->getSystemValue('customclient_android', $this->theming->getAndroidClientUrl()),
'ios' => $this->config->getSystemValue('customclient_ios', $this->theming->getiOSClientUrl()),
'appStore' => $this->config->getSystemValue('appstoreenabled', true),
'appStore' => $appStore,
'useTLS' => $this->request->getServerProtocol() === 'https',
'macOSProfile' => \OCP\Util::linkToRemote('dav') . 'provisioning/apple-provisioning.mobileconfig',
];

$slides = [
$this->staticSlide('page.values', $data)
];
if ($this->groupManager->isAdmin($this->userId)) {
if ($appStore && $this->groupManager->isAdmin($this->userId)) {
$slides[] = $this->staticSlide('page.apps', $data);
}
$slides[] = $this->staticSlide('page.clients', $data);
Expand Down
32 changes: 25 additions & 7 deletions tests/Controller/WizardControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,28 +108,46 @@ public function testShowUser() {

$this->assertInstanceOf(JSONResponse::class, $response);
$this->assertSame(Http::STATUS_OK, $response->getStatus());
$this->assertEquals(3, count($response->getData()));
$this->assertCount(3, $response->getData());
}

public function testShowAdmin() {
/**
* @dataProvider dataShowAdmin
* @param bool $appstoreEnabled
* @param int $expectedSlidesCount
*/
public function testShowAdmin(bool $appstoreEnabled, int $expectedSlidesCount): void {
$controller = $this->getController();

$this->groupManager->expects($this->once())
->method('isAdmin')
->willReturn(true);
if ($appstoreEnabled) {
$this->groupManager->expects($this->once())
->method('isAdmin')
->willReturn(true);
} else {
$this->groupManager->expects($this->never())
->method('isAdmin');
}

$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]
['appstoreenabled', true, $appstoreEnabled]
]);

$response = $controller->show();

$this->assertInstanceOf(JSONResponse::class, $response);
$this->assertSame(Http::STATUS_OK, $response->getStatus());
$this->assertEquals(4, count($response->getData()));
$this->assertCount($expectedSlidesCount, $response->getData());
}

public function dataShowAdmin(): array {
return [
'app store enabled' => [true, 4],
'app store disabled' => [false, 3]
];
}
}