Move default board creation to Application and cleanup code
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -94,7 +94,7 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
$this->config->expects($this->once())
|
||||
->method('setUserValue');
|
||||
|
||||
$result = $this->service->checkFirstRun($this->userId, $appName);
|
||||
$result = $this->service->checkFirstRun($this->userId);
|
||||
$this->assertEquals($result, true);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
->method('findAllByUser')
|
||||
->willReturn($userBoards);
|
||||
|
||||
$result = $this->service->checkFirstRun($this->userId, $appName);
|
||||
$result = $this->service->checkFirstRun($this->userId);
|
||||
$this->assertEquals($result, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,69 +45,25 @@ class PageControllerTest extends \Test\TestCase {
|
||||
public function setUp(): void {
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
$this->defaultBoardService = $this->createMock(DefaultBoardService::class);
|
||||
$this->permissionService = $this->createMock(PermissionService::class);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
|
||||
$this->controller = new PageController(
|
||||
'deck', $this->request, $this->defaultBoardService, $this->permissionService, $this->l10n, $this->userId
|
||||
'deck', $this->request, $this->permissionService, $this->l10n, $this->userId
|
||||
);
|
||||
}
|
||||
|
||||
public function testIndexOnFirstRun() {
|
||||
public function testIndex() {
|
||||
|
||||
$board = new Board();
|
||||
$board->setTitle('Personal');
|
||||
$board->setOwner($this->userId);
|
||||
$board->setColor('317CCC');
|
||||
|
||||
$this->defaultBoardService->expects($this->once())
|
||||
->method('checkFirstRun')
|
||||
->willReturn(true);
|
||||
|
||||
$this->permissionService->expects($this->any())
|
||||
->method('canCreate')
|
||||
->willReturn(true);
|
||||
|
||||
$this->defaultBoardService->expects($this->once())
|
||||
->method('createDefaultBoard')
|
||||
->willReturn($board);
|
||||
|
||||
$response = $this->controller->index();
|
||||
$this->assertEquals('main', $response->getTemplateName());
|
||||
}
|
||||
|
||||
public function testIndexOnFirstRunNoCreate() {
|
||||
|
||||
$board = new Board();
|
||||
$board->setTitle('Personal');
|
||||
$board->setOwner($this->userId);
|
||||
$board->setColor('317CCC');
|
||||
|
||||
$this->defaultBoardService->expects($this->once())
|
||||
->method('checkFirstRun')
|
||||
->willReturn(true);
|
||||
|
||||
$this->permissionService->expects($this->any())
|
||||
->method('canCreate')
|
||||
->willReturn(false);
|
||||
|
||||
$this->defaultBoardService->expects($this->never())
|
||||
->method('createDefaultBoard')
|
||||
->willReturn($board);
|
||||
|
||||
$response = $this->controller->index();
|
||||
$this->assertEquals('main', $response->getTemplateName());
|
||||
}
|
||||
|
||||
public function testIndexOnSecondRun() {
|
||||
|
||||
$this->config->setUserValue($this->userId, 'deck', 'firstRun', 'no');
|
||||
|
||||
$this->defaultBoardService->expects($this->once())
|
||||
->method('checkFirstRun')
|
||||
->willReturn(false);
|
||||
|
||||
$response = $this->controller->index();
|
||||
$this->assertEquals('main', $response->getTemplateName());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user