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