Make user id from occ command available in the service

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-12-19 21:54:53 +01:00
committed by Backportbot
parent 12fb5f0a1f
commit 7bf903f586
3 changed files with 11 additions and 23 deletions

View File

@@ -88,13 +88,8 @@ class UserExport extends Command {
$userId = $input->getArgument('user-id'); $userId = $input->getArgument('user-id');
$groups = $this->groupManager->getUserGroupIds( $this->boardService->setUserId($userId);
$this->userManager->get($userId) $boards = $this->boardService->findAll();
);
$boards = $this->boardService->findAll([
'user' => $userId,
'groups' => $groups
]);
$data = []; $data = [];
foreach ($boards as $board) { foreach ($boards as $board) {

View File

@@ -98,6 +98,15 @@ class BoardService {
$this->userId = $userId; $this->userId = $userId;
} }
/**
* Set a different user than the current one, e.g. when no user is available in occ
*
* @param string $userId
*/
public function setUserId(string $userId): void {
$this->userId = $userId;
}
/** /**
* @return array * @return array
*/ */

View File

@@ -89,28 +89,12 @@ class UserExportTest extends \Test\TestCase {
$input->expects($this->once())->method('getArgument')->with('user-id')->willReturn('admin'); $input->expects($this->once())->method('getArgument')->with('user-id')->willReturn('admin');
$output = $this->createMock(OutputInterface::class); $output = $this->createMock(OutputInterface::class);
$user = $this->createMock(IUser::class);
$this->userManager->expects($this->once())
->method('get')
->with('admin')
->willReturn($user);
$groups = [];
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
->willReturn($groups);
$boards = [ $boards = [
$this->getBoard(1), $this->getBoard(1),
$this->getBoard(2), $this->getBoard(2),
]; ];
$this->boardService->expects($this->once()) $this->boardService->expects($this->once())
->method('findAll') ->method('findAll')
->with([
'user' => 'admin',
'groups' => $groups
])
->willReturn($boards); ->willReturn($boards);
$this->boardMapper->expects($this->exactly(count($boards))) $this->boardMapper->expects($this->exactly(count($boards)))
->method('find') ->method('find')