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
19 changes: 13 additions & 6 deletions lib/Controller/WizardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IRequest;

class WizardController extends Controller {
Expand All @@ -41,19 +41,23 @@ class WizardController extends Controller {
/** @var Defaults */
protected $theming;

/** @var IGroupManager */
protected $groupManager;

/**
* @param string $appName
* @param IRequest $request
* @param IConfig $config
* @param string $userId
* @param Defaults $theming
*/
public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming) {
public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming, IGroupManager $groupManager) {
parent::__construct($appName, $request);

$this->config = $config;
$this->userId = $userId;
$this->theming = $theming;
$this->groupManager = $groupManager;
}

/**
Expand Down Expand Up @@ -81,11 +85,14 @@ public function show() {

$slides = [
$this->staticSlide('page.intro', $data),
$this->staticSlide('page.values', $data),
$this->staticSlide('page.apps', $data),
$this->staticSlide('page.clients', $data),
$this->staticSlide('page.final', $data)
$this->staticSlide('page.values', $data)
];
if ($this->groupManager->isAdmin($this->userId)) {
$slides[] = $this->staticSlide('page.apps', $data);
}
$slides[] = $this->staticSlide('page.clients', $data);
$slides[] = $this->staticSlide('page.final', $data);

return new JSONResponse($slides);
}

Expand Down
31 changes: 29 additions & 2 deletions tests/Controller/WizardControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\AppFramework\Http\JSONResponse;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IRequest;
use Test\TestCase;

Expand All @@ -42,10 +43,13 @@
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);

}

/**
Expand All @@ -58,7 +62,8 @@ protected function getController($user = 'test') {
$this->createMock(IRequest::class),
$this->config,
$user,
\OC::$server->query(Defaults::class)
\OC::$server->query(Defaults::class),
$this->groupManager
);
}

Expand Down Expand Up @@ -87,9 +92,31 @@ public function testDisable($user) {
}


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([
Expand Down