fixed more unit tests.
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
committed by
Julius Härtl
parent
e0049cf07b
commit
e8c53d71aa
@@ -33,6 +33,8 @@ use OCA\Deck\Db\BoardMapper;
|
|||||||
use OCA\Deck\Db\LabelMapper;
|
use OCA\Deck\Db\LabelMapper;
|
||||||
use OCA\Deck\Notification\NotificationHelper;
|
use OCA\Deck\Notification\NotificationHelper;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
|
use OCP\IUserManager;
|
||||||
|
use OCP\IGroupManager;
|
||||||
use \Test\TestCase;
|
use \Test\TestCase;
|
||||||
|
|
||||||
class BoardServiceTest extends TestCase {
|
class BoardServiceTest extends TestCase {
|
||||||
@@ -53,8 +55,12 @@ class BoardServiceTest extends TestCase {
|
|||||||
private $notificationHelper;
|
private $notificationHelper;
|
||||||
/** @var AssignedUsersMapper */
|
/** @var AssignedUsersMapper */
|
||||||
private $assignedUsersMapper;
|
private $assignedUsersMapper;
|
||||||
|
/** @var IUserManager */
|
||||||
|
private $userManager;
|
||||||
|
/** @var IUserManager */
|
||||||
|
private $groupManager;
|
||||||
|
|
||||||
private $userId = 'admin';
|
private $userId = 'admin';
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -65,6 +71,8 @@ class BoardServiceTest extends TestCase {
|
|||||||
$this->permissionService = $this->createMock(PermissionService::class);
|
$this->permissionService = $this->createMock(PermissionService::class);
|
||||||
$this->notificationHelper = $this->createMock(NotificationHelper::class);
|
$this->notificationHelper = $this->createMock(NotificationHelper::class);
|
||||||
$this->assignedUsersMapper = $this->createMock(AssignedUsersMapper::class);
|
$this->assignedUsersMapper = $this->createMock(AssignedUsersMapper::class);
|
||||||
|
$this->userManager = $this->createMock(IUserManager::class);
|
||||||
|
$this->groupManager = $this->createMock(IGroupManager::class);
|
||||||
|
|
||||||
$this->service = new BoardService(
|
$this->service = new BoardService(
|
||||||
$this->boardMapper,
|
$this->boardMapper,
|
||||||
@@ -73,11 +81,14 @@ class BoardServiceTest extends TestCase {
|
|||||||
$this->aclMapper,
|
$this->aclMapper,
|
||||||
$this->permissionService,
|
$this->permissionService,
|
||||||
$this->notificationHelper,
|
$this->notificationHelper,
|
||||||
$this->assignedUsersMapper
|
$this->assignedUsersMapper,
|
||||||
|
$this->userManager,
|
||||||
|
$this->groupManager,
|
||||||
|
$this->userId
|
||||||
);
|
);
|
||||||
|
|
||||||
$user = $this->createMock(IUser::class);
|
$user = $this->createMock(IUser::class);
|
||||||
$user->method('getUID')->willReturn('admin');
|
$user->method('getUID')->willReturn('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFindAll() {
|
public function testFindAll() {
|
||||||
@@ -94,12 +105,12 @@ class BoardServiceTest extends TestCase {
|
|||||||
$this->boardMapper->expects($this->once())
|
$this->boardMapper->expects($this->once())
|
||||||
->method('findAllByGroups')
|
->method('findAllByGroups')
|
||||||
->with('admin', ['a', 'b', 'c'])
|
->with('admin', ['a', 'b', 'c'])
|
||||||
->willReturn([$b2, $b3]);
|
->willReturn([$b2, $b3]);
|
||||||
$userinfo = [
|
$userinfo = [
|
||||||
'user' => 'admin',
|
'user' => 'admin',
|
||||||
'groups' => ['a', 'b', 'c']
|
'groups' => ['a', 'b', 'c']
|
||||||
];
|
];
|
||||||
$result = $this->service->findAll($userinfo);
|
$result = $this->service->findAll();
|
||||||
sort($result);
|
sort($result);
|
||||||
$this->assertEquals([$b1, $b2, $b3], $result);
|
$this->assertEquals([$b1, $b2, $b3], $result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,8 +336,8 @@ class CardServiceTest extends TestCase {
|
|||||||
->method('find')
|
->method('find')
|
||||||
->with(123)
|
->with(123)
|
||||||
->willReturn($assignments);
|
->willReturn($assignments);
|
||||||
$actual = $this->cardService->unassignUser(123, 'user');
|
$this->expectException(NotFoundException::class);
|
||||||
$this->assertEquals($assignment, $actual);
|
$actual = $this->cardService->unassignUser(123, 'user');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user