Add change database helper
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -26,6 +26,7 @@ class BoardTest extends TestCase {
|
||||
'labels' => array(),
|
||||
'permissions' => [],
|
||||
'deletedAt' => 0,
|
||||
'lastModified' => 0,
|
||||
'acl' => array(),
|
||||
'archived' => false,
|
||||
'users' => ['user1', 'user2'],
|
||||
@@ -43,6 +44,7 @@ class BoardTest extends TestCase {
|
||||
'labels' => array("foo", "bar"),
|
||||
'permissions' => [],
|
||||
'deletedAt' => 0,
|
||||
'lastModified' => 0,
|
||||
'acl' => array(),
|
||||
'archived' => false,
|
||||
'users' => [],
|
||||
@@ -67,10 +69,11 @@ class BoardTest extends TestCase {
|
||||
'labels' => array(),
|
||||
'permissions' => [],
|
||||
'deletedAt' => 0,
|
||||
'lastModified' => 0,
|
||||
'acl' => array(),
|
||||
'archived' => false,
|
||||
'shared' => 1,
|
||||
'users' => [],
|
||||
], $board->jsonSerialize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ class StackTest extends \Test\TestCase {
|
||||
'title' => "My Stack",
|
||||
'order' => 1,
|
||||
'boardId' => 1,
|
||||
'deletedAt' => 0
|
||||
'deletedAt' => 0,
|
||||
'lastModified' => 0,
|
||||
], $board->jsonSerialize());
|
||||
}
|
||||
public function testJsonSerializeWithCards() {
|
||||
@@ -52,7 +53,8 @@ class StackTest extends \Test\TestCase {
|
||||
'order' => 1,
|
||||
'boardId' => 1,
|
||||
'cards' => array("foo", "bar"),
|
||||
'deletedAt' => 0
|
||||
'deletedAt' => 0,
|
||||
'lastModified' => 0,
|
||||
], $board->jsonSerialize());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use OCA\Deck\Db\Acl;
|
||||
use OCA\Deck\Db\Attachment;
|
||||
use OCA\Deck\Db\AttachmentMapper;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\InvalidAttachmentType;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
@@ -73,6 +74,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
private $cache;
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
|
||||
/**
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
@@ -99,8 +102,9 @@ class AttachmentServiceTest extends TestCase {
|
||||
->willReturn($this->appContainer);
|
||||
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||
|
||||
$this->attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $this->application, $this->cacheFactory, $this->userId, $this->l10n, $this->activityManager);
|
||||
$this->attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->changeHelper, $this->permissionService, $this->application, $this->cacheFactory, $this->userId, $this->l10n, $this->activityManager);
|
||||
}
|
||||
|
||||
public function testRegisterAttachmentService() {
|
||||
@@ -112,7 +116,7 @@ class AttachmentServiceTest extends TestCase {
|
||||
$application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($appContainer);
|
||||
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $application, $this->cacheFactory, $this->userId, $this->l10n, $this->activityManager);
|
||||
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->changeHelper, $this->permissionService, $application, $this->cacheFactory, $this->userId, $this->l10n, $this->activityManager);
|
||||
$attachmentService->registerAttachmentService('custom', MyAttachmentService::class);
|
||||
$this->assertEquals($fileServiceMock, $attachmentService->getService('deck_file'));
|
||||
$this->assertEquals(MyAttachmentService::class, get_class($attachmentService->getService('custom')));
|
||||
@@ -130,7 +134,7 @@ class AttachmentServiceTest extends TestCase {
|
||||
$application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($appContainer);
|
||||
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $application, $this->cacheFactory, $this->userId, $this->l10n, $this->activityManager);
|
||||
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->changeHelper, $this->permissionService, $application, $this->cacheFactory, $this->userId, $this->l10n, $this->activityManager);
|
||||
$attachmentService->registerAttachmentService('custom', MyAttachmentService::class);
|
||||
$attachmentService->getService('deck_file_invalid');
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ use OCA\Deck\Db\AssignedUsers;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use OCA\Deck\Notification\NotificationHelper;
|
||||
use OCP\IUser;
|
||||
@@ -62,7 +63,8 @@ class BoardServiceTest extends TestCase {
|
||||
private $groupManager;
|
||||
/** @var ActivityManager */
|
||||
private $activityManager;
|
||||
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
private $userId = 'admin';
|
||||
|
||||
public function setUp() {
|
||||
@@ -77,6 +79,7 @@ class BoardServiceTest extends TestCase {
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->groupManager = $this->createMock(IGroupManager::class);
|
||||
$this->activityManager = $this->createMock(ActivityManager::class);
|
||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||
|
||||
$this->service = new BoardService(
|
||||
$this->boardMapper,
|
||||
@@ -89,6 +92,7 @@ class BoardServiceTest extends TestCase {
|
||||
$this->userManager,
|
||||
$this->groupManager,
|
||||
$this->activityManager,
|
||||
$this->changeHelper,
|
||||
$this->userId
|
||||
);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ use OCA\Deck\Db\AssignedUsers;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
@@ -69,6 +70,8 @@ class CardServiceTest extends TestCase {
|
||||
private $commentsManager;
|
||||
/** @var ICommentsManager|MockObject */
|
||||
private $userManager;
|
||||
/** @var ChangeHelper|MockObject */
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
@@ -84,6 +87,7 @@ class CardServiceTest extends TestCase {
|
||||
$this->activityManager = $this->createMock(ActivityManager::class);
|
||||
$this->commentsManager = $this->createMock(ICommentsManager::class);
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||
$this->cardService = new CardService(
|
||||
$this->cardMapper,
|
||||
$this->stackMapper,
|
||||
@@ -97,6 +101,7 @@ class CardServiceTest extends TestCase {
|
||||
$this->activityManager,
|
||||
$this->commentsManager,
|
||||
$this->userManager,
|
||||
$this->changeHelper,
|
||||
'user1'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use Test\TestCase;
|
||||
@@ -38,6 +39,8 @@ class LabelServiceTest extends TestCase {
|
||||
private $labelService;
|
||||
/** @var BoardService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $boardService;
|
||||
/** @var ChangeHelper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
@@ -46,10 +49,12 @@ class LabelServiceTest extends TestCase {
|
||||
$this->permissionService = $this->getMockBuilder(PermissionService::class)
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$this->boardService = $this->createMock(BoardService::class);
|
||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||
$this->labelService = new LabelService(
|
||||
$this->labelMapper,
|
||||
$this->permissionService,
|
||||
$this->boardService
|
||||
$this->boardService,
|
||||
$this->changeHelper
|
||||
);
|
||||
}
|
||||
|
||||
@@ -95,13 +100,15 @@ class LabelServiceTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
$label = new Label();
|
||||
$label->setId(1);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('find')
|
||||
->willReturn(new Label());
|
||||
->willReturn($label);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('delete')
|
||||
->willReturn(1);
|
||||
$this->assertEquals(1, $this->labelService->delete(123));
|
||||
->willReturn($label);
|
||||
$this->assertEquals($label, $this->labelService->delete(1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use OCA\Deck\Db\Stack;
|
||||
@@ -66,6 +67,8 @@ class StackServiceTest extends TestCase {
|
||||
private $cardService;
|
||||
/** @var ActivityManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $activityManager;
|
||||
/** @var ChangeHelper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
@@ -79,6 +82,7 @@ class StackServiceTest extends TestCase {
|
||||
$this->attachmentService = $this->createMock(AttachmentService::class);
|
||||
$this->labelMapper = $this->createMock(LabelMapper::class);
|
||||
$this->activityManager = $this->createMock(ActivityManager::class);
|
||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||
|
||||
$this->stackService = new StackService(
|
||||
$this->stackMapper,
|
||||
@@ -90,7 +94,8 @@ class StackServiceTest extends TestCase {
|
||||
$this->cardService,
|
||||
$this->assignedUsersMapper,
|
||||
$this->attachmentService,
|
||||
$this->activityManager
|
||||
$this->activityManager,
|
||||
$this->changeHelper
|
||||
);
|
||||
}
|
||||
|
||||
@@ -185,6 +190,7 @@ class StackServiceTest extends TestCase {
|
||||
$stackToBeDeleted->setId(1);
|
||||
$this->stackMapper->expects($this->once())->method('find')->willReturn($stackToBeDeleted);
|
||||
$this->stackMapper->expects($this->once())->method('update')->willReturn($stackToBeDeleted);
|
||||
$this->cardMapper->expects($this->once())->method('findAll')->willReturn([]);
|
||||
$this->stackService->delete(123);
|
||||
$this->assertTrue($stackToBeDeleted->getDeletedAt() <= time(), "deletedAt is in the past");
|
||||
$this->assertTrue($stackToBeDeleted->getDeletedAt() > 0, "deletedAt is set");
|
||||
|
||||
Reference in New Issue
Block a user