@@ -24,6 +24,7 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
|
||||
class UserTest extends \Test\TestCase {
|
||||
public function testGroupObjectSerialize() {
|
||||
@@ -35,7 +36,11 @@ class UserTest extends \Test\TestCase {
|
||||
$user->expects($this->any())
|
||||
->method('getDisplayName')
|
||||
->willReturn('myuser displayname');
|
||||
$userRelationalObject = new User($user);
|
||||
$userManager = $this->createMock(IUserManager::class);
|
||||
$userManager->expects($this->any())
|
||||
->method('get')
|
||||
->willReturn($user);
|
||||
$userRelationalObject = new User('myuser', $userManager);
|
||||
$expected = [
|
||||
'uid' => 'myuser',
|
||||
'displayname' => 'myuser displayname',
|
||||
@@ -53,7 +58,11 @@ class UserTest extends \Test\TestCase {
|
||||
$user->expects($this->any())
|
||||
->method('getDisplayName')
|
||||
->willReturn('myuser displayname');
|
||||
$userRelationalObject = new User($user);
|
||||
$userManager = $this->createMock(IUserManager::class);
|
||||
$userManager->expects($this->any())
|
||||
->method('get')
|
||||
->willReturn($user);
|
||||
$userRelationalObject = new User('myuser', $userManager);
|
||||
$expected = [
|
||||
'uid' => 'myuser',
|
||||
'displayname' => 'myuser displayname',
|
||||
|
||||
@@ -37,6 +37,7 @@ use OCP\IConfig;
|
||||
use OCP\IGroup;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Notification\IManager;
|
||||
use OCP\Notification\INotification;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
@@ -219,8 +220,9 @@ class NotificationHelperTest extends \Test\TestCase {
|
||||
'title' => 'MyCardTitle',
|
||||
'duedate' => '2020-12-24'
|
||||
]);
|
||||
$userManager = $this->createMock(IUserManager::class);
|
||||
$card->setAssignedUsers([
|
||||
new User($users[0])
|
||||
new User($users[0]->getUID(), $userManager)
|
||||
]);
|
||||
$this->cardMapper->expects($this->once())
|
||||
->method('findBoardId')
|
||||
@@ -308,8 +310,9 @@ class NotificationHelperTest extends \Test\TestCase {
|
||||
'title' => 'MyCardTitle',
|
||||
'duedate' => '2020-12-24'
|
||||
]);
|
||||
$userManager = $this->createMock(IUserManager::class);
|
||||
$card->setAssignedUsers([
|
||||
new User($users[0])
|
||||
new User($users[0]->getUID(), $userManager)
|
||||
]);
|
||||
$this->cardMapper->expects($this->once())
|
||||
->method('findBoardId')
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\Db\Assignment;
|
||||
use OCA\Deck\Db\AssignmentMapper;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\Card;
|
||||
@@ -168,13 +169,21 @@ class CardServiceTest extends TestCase {
|
||||
->method('find')
|
||||
->with(123)
|
||||
->willReturn($card);
|
||||
$a1 = new Assignment();
|
||||
$a1->setCardId(1337);
|
||||
$a1->setType(0);
|
||||
$a1->setParticipant('user1');
|
||||
$a2 = new Assignment();
|
||||
$a2->setCardId(1337);
|
||||
$a2->setType(0);
|
||||
$a2->setParticipant('user2');
|
||||
$this->assignedUsersMapper->expects($this->any())
|
||||
->method('findAll')
|
||||
->with(1337)
|
||||
->willReturn(['user1', 'user2']);
|
||||
->method('findIn')
|
||||
->with([1337])
|
||||
->willReturn([$a1, $a2]);
|
||||
$cardExpected = new Card();
|
||||
$cardExpected->setId(1337);
|
||||
$cardExpected->setAssignedUsers(['user1', 'user2']);
|
||||
$cardExpected->setAssignedUsers([$a1, $a2]);
|
||||
$cardExpected->setRelatedBoard($boardMock);
|
||||
$cardExpected->setRelatedStack($stackMock);
|
||||
$cardExpected->setLabels([]);
|
||||
|
||||
@@ -83,10 +83,6 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
->method('getUserValue')
|
||||
->willReturn('yes');
|
||||
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByUser')
|
||||
->willReturn($userBoards);
|
||||
|
||||
$this->config->expects($this->once())
|
||||
->method('setUserValue');
|
||||
|
||||
@@ -107,10 +103,6 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
->method('getUserValue')
|
||||
->willReturn('no');
|
||||
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByUser')
|
||||
->willReturn($userBoards);
|
||||
|
||||
$result = $this->service->checkFirstRun($this->userId);
|
||||
$this->assertEquals($result, false);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ use OCP\IUserManager;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class TrelloJsonServiceTest extends \Test\TestCase {
|
||||
private TrelloJsonService $service;
|
||||
/** @var IURLGenerator|MockObject */
|
||||
@@ -57,7 +60,7 @@ class TrelloJsonServiceTest extends \Test\TestCase {
|
||||
}
|
||||
|
||||
public function testValidateUsersWithInvalidUser() {
|
||||
$this->expectErrorMessage('Trello user trello_user not found in property "members" of json data');
|
||||
$this->expectExceptionMessage('Trello user trello_user not found in property "members" of json data');
|
||||
$importService = $this->createMock(BoardImportService::class);
|
||||
$importService
|
||||
->method('getConfig')
|
||||
|
||||
@@ -340,7 +340,7 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
$aclGroup->setParticipant('group1');
|
||||
|
||||
$board = $this->createMock(Board::class);
|
||||
$board->expects($this->once())
|
||||
$board->expects($this->any())
|
||||
->method('__call')
|
||||
->with('getOwner', [])
|
||||
->willReturn('user1');
|
||||
@@ -352,8 +352,8 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
->method('find')
|
||||
->with(123)
|
||||
->willReturn($board);
|
||||
$this->userManager->expects($this->exactly(2))
|
||||
->method('get')
|
||||
$this->userManager->expects($this->any())
|
||||
->method('userExists')
|
||||
->withConsecutive(['user1'], ['user2'])
|
||||
->willReturnOnConsecutiveCalls($user1, $user2);
|
||||
|
||||
@@ -367,9 +367,9 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
->willReturn($group);
|
||||
$users = $this->service->findUsers(123);
|
||||
$this->assertEquals([
|
||||
'user1' => new User($user1),
|
||||
'user2' => new User($user2),
|
||||
'user3' => new User($user3),
|
||||
'user1' => new User($user1->getUID(), $this->userManager),
|
||||
'user2' => new User($user2->getUID(), $this->userManager),
|
||||
'user3' => new User($user3->getUID(), $this->userManager),
|
||||
], $users);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +110,13 @@ class StackServiceTest extends TestCase {
|
||||
public function testFindAll() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$this->stackMapper->expects($this->once())->method('findAll')->willReturn($this->getStacks());
|
||||
$this->cardService->expects($this->atLeastOnce())->method('enrich')->will(
|
||||
$this->cardService->expects($this->atLeastOnce())->method('enrichCards')->will(
|
||||
$this->returnCallback(
|
||||
function ($card) {
|
||||
function ($cards) {
|
||||
foreach ($cards as $card) {
|
||||
$card->setLabels($this->getLabels()[$card->getId()]);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
$this->cardMapper->expects($this->any())->method('findAll')->willReturn($this->getCards(222));
|
||||
|
||||
Reference in New Issue
Block a user