@@ -23,30 +23,18 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\BadRequestException;
|
||||
use OCA\Deck\Db\AclMapper;
|
||||
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;
|
||||
use OCA\Deck\NotFoundException;
|
||||
use OCA\Deck\Notification\NotificationHelper;
|
||||
use OCA\Deck\StatusException;
|
||||
use OCP\Activity\IEvent;
|
||||
use OCP\Comments\ICommentsManager;
|
||||
use OCP\EventDispatcher\ABroadcastedEvent;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
class AssignmentServiceTest extends TestCase {
|
||||
@@ -231,6 +219,4 @@ class AssignmentServiceTest extends TestCase {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$actual = $this->assignmentService->unassignUser(123, 'user');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\AppInfo\Application;
|
||||
use OCA\Deck\Db\Acl;
|
||||
@@ -44,13 +43,20 @@ use Test\TestCase;
|
||||
|
||||
/** @internal Just for testing the service registration */
|
||||
class MyAttachmentService {
|
||||
public function extendData(Attachment $attachment) {}
|
||||
public function display(Attachment $attachment) {}
|
||||
public function create(Attachment $attachment) {}
|
||||
public function update(Attachment $attachment) {}
|
||||
public function delete(Attachment $attachment) {}
|
||||
public function allowUndo() {}
|
||||
public function markAsDeleted(Attachment $attachment) {}
|
||||
public function extendData(Attachment $attachment) {
|
||||
}
|
||||
public function display(Attachment $attachment) {
|
||||
}
|
||||
public function create(Attachment $attachment) {
|
||||
}
|
||||
public function update(Attachment $attachment) {
|
||||
}
|
||||
public function delete(Attachment $attachment) {
|
||||
}
|
||||
public function allowUndo() {
|
||||
}
|
||||
public function markAsDeleted(Attachment $attachment) {
|
||||
}
|
||||
}
|
||||
|
||||
class AttachmentServiceTest extends TestCase {
|
||||
@@ -106,10 +112,10 @@ class AttachmentServiceTest extends TestCase {
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||
|
||||
$this->attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->changeHelper, $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() {
|
||||
public function testRegisterAttachmentService() {
|
||||
$application = $this->createMock(Application::class);
|
||||
$appContainer = $this->createMock(IAppContainer::class);
|
||||
$fileServiceMock = $this->createMock(FileService::class);
|
||||
@@ -227,7 +233,9 @@ class AttachmentServiceTest extends TestCase {
|
||||
->willReturn($attachment);
|
||||
$this->attachmentServiceImpl->expects($this->once())
|
||||
->method('extendData')
|
||||
->willReturnCallback(function($a) { $a->setExtendedData(['mime' => 'image/jpeg']); });
|
||||
->willReturnCallback(function ($a) {
|
||||
$a->setExtendedData(['mime' => 'image/jpeg']);
|
||||
});
|
||||
|
||||
$actual = $this->attachmentService->create(123, 'deck_file', 'file_name.jpg');
|
||||
|
||||
@@ -282,7 +290,9 @@ class AttachmentServiceTest extends TestCase {
|
||||
->willReturn($attachment);
|
||||
$this->attachmentServiceImpl->expects($this->once())
|
||||
->method('extendData')
|
||||
->willReturnCallback(function($a) { $a->setExtendedData(['mime' => 'image/jpeg']); });
|
||||
->willReturnCallback(function ($a) {
|
||||
$a->setExtendedData(['mime' => 'image/jpeg']);
|
||||
});
|
||||
|
||||
$actual = $this->attachmentService->update(123, 1, 'file_name.jpg');
|
||||
|
||||
@@ -326,7 +336,9 @@ class AttachmentServiceTest extends TestCase {
|
||||
->willReturn(true);
|
||||
$this->attachmentServiceImpl->expects($this->once())
|
||||
->method('markAsDeleted')
|
||||
->willReturnCallback(function($a) { $a->setDeletedAt(23); });
|
||||
->willReturnCallback(function ($a) {
|
||||
$a->setDeletedAt(23);
|
||||
});
|
||||
$this->attachmentMapper->expects($this->once())
|
||||
->method('update')
|
||||
->willReturn($attachment);
|
||||
@@ -370,5 +382,4 @@ class AttachmentServiceTest extends TestCase {
|
||||
->willReturn(false);
|
||||
$actual = $this->attachmentService->restore(123, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -162,9 +162,9 @@ class BoardServiceTest extends TestCase {
|
||||
|
||||
public function testCreate() {
|
||||
$board = new Board();
|
||||
$board->setTitle('MyBoard');
|
||||
$board->setOwner('admin');
|
||||
$board->setColor('00ff00');
|
||||
$board->setTitle('MyBoard');
|
||||
$board->setOwner('admin');
|
||||
$board->setColor('00ff00');
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('insert')
|
||||
->willReturn($board);
|
||||
@@ -247,7 +247,7 @@ class BoardServiceTest extends TestCase {
|
||||
$acl->setPermissionEdit(true);
|
||||
$acl->setPermissionShare(true);
|
||||
$acl->setPermissionManage(true);
|
||||
$acl->resolveRelation('participant', function($participant) use (&$user) {
|
||||
$acl->resolveRelation('participant', function ($participant) use (&$user) {
|
||||
return null;
|
||||
});
|
||||
$this->notificationHelper->expects($this->once())
|
||||
@@ -333,7 +333,7 @@ class BoardServiceTest extends TestCase {
|
||||
$acl->setPermissionEdit($resultingAcl[0]);
|
||||
$acl->setPermissionShare($resultingAcl[1]);
|
||||
$acl->setPermissionManage($resultingAcl[2]);
|
||||
$acl->resolveRelation('participant', function($participant) use (&$user) {
|
||||
$acl->resolveRelation('participant', function ($participant) use (&$user) {
|
||||
return null;
|
||||
});
|
||||
$this->notificationHelper->expects($this->once())
|
||||
@@ -373,7 +373,6 @@ class BoardServiceTest extends TestCase {
|
||||
$this->assertFalse($result->getPermissionEdit());
|
||||
$this->assertFalse($result->getPermissionShare());
|
||||
$this->assertFalse($result->getPermissionManage());
|
||||
|
||||
}
|
||||
|
||||
public function testDeleteAcl() {
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\BadRequestException;
|
||||
use OCA\Deck\Db\AssignedUsers;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
@@ -34,13 +31,10 @@ use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\StackMapper;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
use OCA\Deck\NotFoundException;
|
||||
use OCA\Deck\Notification\NotificationHelper;
|
||||
use OCA\Deck\StatusException;
|
||||
use OCP\Activity\IEvent;
|
||||
use OCP\Comments\ICommentsManager;
|
||||
use OCP\EventDispatcher\ABroadcastedEvent;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
@@ -81,7 +75,7 @@ class CardServiceTest extends TestCase {
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
parent::setUp();
|
||||
$this->cardMapper = $this->createMock(CardMapper::class);
|
||||
$this->stackMapper = $this->createMock(StackMapper::class);
|
||||
$this->boardMapper = $this->createMock(BoardMapper::class);
|
||||
@@ -184,7 +178,9 @@ class CardServiceTest extends TestCase {
|
||||
$card->setTitle('title');
|
||||
$card->setArchived(false);
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function($c) { return $c; });
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function ($c) {
|
||||
return $c;
|
||||
});
|
||||
$actual = $this->cardService->update(123, 'newtitle', 234, 'text', 999, 'foo', 'admin', '2017-01-01 00:00:00', null);
|
||||
$this->assertEquals('newtitle', $actual->getTitle());
|
||||
$this->assertEquals(234, $actual->getStackId());
|
||||
@@ -209,7 +205,9 @@ class CardServiceTest extends TestCase {
|
||||
$card->setTitle('title');
|
||||
$card->setArchived(false);
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function($c) { return $c; });
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function ($c) {
|
||||
return $c;
|
||||
});
|
||||
$actual = $this->cardService->rename(123, 'newtitle');
|
||||
$this->assertEquals('newtitle', $actual->getTitle());
|
||||
}
|
||||
@@ -224,31 +222,31 @@ class CardServiceTest extends TestCase {
|
||||
$this->cardService->rename(123, 'newtitle');
|
||||
}
|
||||
|
||||
public function dataReorder() {
|
||||
return [
|
||||
[0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]],
|
||||
[0, 9, [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]],
|
||||
[1, 3, [0, 2, 3, 1, 4, 5, 6, 7, 8, 9]]
|
||||
];
|
||||
}
|
||||
/** @dataProvider dataReorder */
|
||||
public function testReorder($cardId, $newPosition, $order) {
|
||||
$cards = $this->getCards();
|
||||
$cardsTmp = [];
|
||||
$this->cardMapper->expects($this->once())->method('findAll')->willReturn($cards);
|
||||
$card = new Card();
|
||||
$card->setStackId(123);
|
||||
public function dataReorder() {
|
||||
return [
|
||||
[0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]],
|
||||
[0, 9, [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]],
|
||||
[1, 3, [0, 2, 3, 1, 4, 5, 6, 7, 8, 9]]
|
||||
];
|
||||
}
|
||||
/** @dataProvider dataReorder */
|
||||
public function testReorder($cardId, $newPosition, $order) {
|
||||
$cards = $this->getCards();
|
||||
$cardsTmp = [];
|
||||
$this->cardMapper->expects($this->once())->method('findAll')->willReturn($cards);
|
||||
$card = new Card();
|
||||
$card->setStackId(123);
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$result = $this->cardService->reorder($cardId, 123, $newPosition);
|
||||
foreach ($result as $card) {
|
||||
$actual[$card->getOrder()] = $card->getId();
|
||||
}
|
||||
$this->assertEquals($order, $actual);
|
||||
}
|
||||
$result = $this->cardService->reorder($cardId, 123, $newPosition);
|
||||
foreach ($result as $card) {
|
||||
$actual[$card->getOrder()] = $card->getId();
|
||||
}
|
||||
$this->assertEquals($order, $actual);
|
||||
}
|
||||
|
||||
private function getCards() {
|
||||
$cards = [];
|
||||
for($i=0; $i<10; $i++) {
|
||||
for ($i=0; $i<10; $i++) {
|
||||
$cards[$i] = new Card();
|
||||
$cards[$i]->setTitle($i);
|
||||
$cards[$i]->setOrder($i);
|
||||
@@ -257,35 +255,37 @@ class CardServiceTest extends TestCase {
|
||||
return $cards;
|
||||
}
|
||||
|
||||
public function testReorderArchived() {
|
||||
$card = new Card();
|
||||
$card->setTitle('title');
|
||||
$card->setArchived(true);
|
||||
public function testReorderArchived() {
|
||||
$card = new Card();
|
||||
$card->setTitle('title');
|
||||
$card->setArchived(true);
|
||||
$card->setStackId(123);
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->never())->method('update')->willReturnCallback(function($c) { return $c; });
|
||||
$this->expectException(StatusException::class);
|
||||
$actual = $this->cardService->reorder(123, 234, 1);
|
||||
}
|
||||
public function testArchive() {
|
||||
$card = new Card();
|
||||
$this->assertFalse($card->getArchived());
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function($c) {
|
||||
return $c;
|
||||
});
|
||||
$this->assertTrue($this->cardService->archive(123)->getArchived());
|
||||
}
|
||||
public function testUnarchive() {
|
||||
$card = new Card();
|
||||
$card->setArchived(true);
|
||||
$this->assertTrue($card->getArchived());
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function($c) {
|
||||
return $c;
|
||||
});
|
||||
$this->assertFalse($this->cardService->unarchive(123)->getArchived());
|
||||
}
|
||||
$this->cardMapper->expects($this->never())->method('update')->willReturnCallback(function ($c) {
|
||||
return $c;
|
||||
});
|
||||
$this->expectException(StatusException::class);
|
||||
$actual = $this->cardService->reorder(123, 234, 1);
|
||||
}
|
||||
public function testArchive() {
|
||||
$card = new Card();
|
||||
$this->assertFalse($card->getArchived());
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function ($c) {
|
||||
return $c;
|
||||
});
|
||||
$this->assertTrue($this->cardService->archive(123)->getArchived());
|
||||
}
|
||||
public function testUnarchive() {
|
||||
$card = new Card();
|
||||
$card->setArchived(true);
|
||||
$this->assertTrue($card->getArchived());
|
||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function ($c) {
|
||||
return $c;
|
||||
});
|
||||
$this->assertFalse($this->cardService->unarchive(123)->getArchived());
|
||||
}
|
||||
|
||||
public function testAssignLabel() {
|
||||
$card = new Card();
|
||||
@@ -320,5 +320,4 @@ class CardServiceTest extends TestCase {
|
||||
$this->expectException(StatusException::class);
|
||||
$this->cardService->removeLabel(123, 999);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,10 +27,6 @@ use OCA\Deck\Db\Card;
|
||||
use OCA\Deck\Db\Board;
|
||||
use OCA\Deck\Db\Stack;
|
||||
use OCA\Deck\Db\BoardMapper;
|
||||
use OCA\Deck\Service\DefaultBoardService;
|
||||
use OCA\Deck\Service\BoardService;
|
||||
use OCA\Deck\Service\StackService;
|
||||
use OCA\Deck\Service\CardService;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use \Test\TestCase;
|
||||
@@ -135,7 +131,9 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
|
||||
$this->l10n->expects($this->any())
|
||||
->method('t')
|
||||
->willReturnCallback(function($text) { return $text; });
|
||||
->willReturnCallback(function ($text) {
|
||||
return $text;
|
||||
});
|
||||
|
||||
$stackToDoId = '123';
|
||||
$stackToDo = $this->assembleTestStack('To do', $stackToDoId, $boardId);
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Db\Attachment;
|
||||
use OCA\Deck\Db\AttachmentMapper;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
@@ -69,9 +68,9 @@ class FileServiceTest extends TestCase {
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->attachmentMapper = $this->createMock(AttachmentMapper::class);
|
||||
$this->fileService = new FileService($this->l10n, $this->appData, $this->request, $this->logger, $this->rootFolder, $this->config, $this->attachmentMapper);
|
||||
}
|
||||
}
|
||||
|
||||
public function mockGetFolder($cardId) {
|
||||
public function mockGetFolder($cardId) {
|
||||
$folder = $this->createMock(ISimpleFolder::class);
|
||||
$this->appData->expects($this->once())
|
||||
->method('getFolder')
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\Db\Label;
|
||||
use OCA\Deck\Db\LabelMapper;
|
||||
@@ -31,84 +30,83 @@ use Test\TestCase;
|
||||
|
||||
class LabelServiceTest extends TestCase {
|
||||
|
||||
/** @var LabelMapper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $labelMapper;
|
||||
/** @var PermissionService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $permissionService;
|
||||
/** @var LabelService */
|
||||
private $labelService;
|
||||
/** @var LabelMapper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $labelMapper;
|
||||
/** @var PermissionService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $permissionService;
|
||||
/** @var LabelService */
|
||||
private $labelService;
|
||||
/** @var BoardService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $boardService;
|
||||
/** @var ChangeHelper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp(): void {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->labelMapper = $this->getMockBuilder(LabelMapper::class)
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$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->labelMapper = $this->getMockBuilder(LabelMapper::class)
|
||||
->disableOriginalConstructor()->getMock();
|
||||
$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->changeHelper
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function testFind() {
|
||||
$this->labelMapper->expects($this->once())->method('find')->willReturn(true);
|
||||
$this->assertTrue($this->labelService->find(123));
|
||||
}
|
||||
public function testFind() {
|
||||
$this->labelMapper->expects($this->once())->method('find')->willReturn(true);
|
||||
$this->assertTrue($this->labelService->find(123));
|
||||
}
|
||||
|
||||
public function testCreate() {
|
||||
$label = new Label();
|
||||
$label->setTitle('Label title');
|
||||
$label->setBoardId(123);
|
||||
$label->setColor('00ff00');
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('insert')
|
||||
->willReturn($label);
|
||||
$b = $this->labelService->create('Label title', '00ff00', 123);
|
||||
public function testCreate() {
|
||||
$label = new Label();
|
||||
$label->setTitle('Label title');
|
||||
$label->setBoardId(123);
|
||||
$label->setColor('00ff00');
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('insert')
|
||||
->willReturn($label);
|
||||
$b = $this->labelService->create('Label title', '00ff00', 123);
|
||||
|
||||
$this->assertEquals($b->getTitle(), 'Label title');
|
||||
$this->assertEquals($b->getBoardId(), 123);
|
||||
$this->assertEquals($b->getColor(), '00ff00');
|
||||
}
|
||||
$this->assertEquals($b->getTitle(), 'Label title');
|
||||
$this->assertEquals($b->getBoardId(), 123);
|
||||
$this->assertEquals($b->getColor(), '00ff00');
|
||||
}
|
||||
|
||||
|
||||
public function testUpdate() {
|
||||
$label = new Label();
|
||||
$label->setTitle('Title');
|
||||
$label->setBoardId(123);
|
||||
$label->setColor('00ff00');
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('find')
|
||||
->with(1)
|
||||
->willReturn($label);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('update')
|
||||
->with($label)
|
||||
->willReturn($label);
|
||||
$b = $this->labelService->update(1, 'NewTitle', 'ffffff');
|
||||
public function testUpdate() {
|
||||
$label = new Label();
|
||||
$label->setTitle('Title');
|
||||
$label->setBoardId(123);
|
||||
$label->setColor('00ff00');
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('find')
|
||||
->with(1)
|
||||
->willReturn($label);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('update')
|
||||
->with($label)
|
||||
->willReturn($label);
|
||||
$b = $this->labelService->update(1, 'NewTitle', 'ffffff');
|
||||
|
||||
$this->assertEquals($b->getTitle(), 'NewTitle');
|
||||
$this->assertEquals($b->getBoardId(), 123);
|
||||
$this->assertEquals($b->getColor(), 'ffffff');
|
||||
}
|
||||
$this->assertEquals($b->getTitle(), 'NewTitle');
|
||||
$this->assertEquals($b->getBoardId(), 123);
|
||||
$this->assertEquals($b->getColor(), 'ffffff');
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
public function testDelete() {
|
||||
$label = new Label();
|
||||
$label->setId(1);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('find')
|
||||
->willReturn($label);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('delete')
|
||||
->willReturn($label);
|
||||
$this->assertEquals($label, $this->labelService->delete(1));
|
||||
}
|
||||
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('find')
|
||||
->willReturn($label);
|
||||
$this->labelMapper->expects($this->once())
|
||||
->method('delete')
|
||||
->willReturn($label);
|
||||
$this->assertEquals($label, $this->labelService->delete(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,15 +43,15 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
|
||||
/** @var PermissionService*/
|
||||
private $service;
|
||||
/** @var ILogger */
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
/** @var AclMapper */
|
||||
private $aclMapper;
|
||||
/** @var BoardMapper */
|
||||
private $boardMapper;
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
/** @var IGroupManager */
|
||||
/** @var BoardMapper */
|
||||
private $boardMapper;
|
||||
/** @var IUserManager */
|
||||
private $userManager;
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
/** @var IManager */
|
||||
private $shareManager;
|
||||
@@ -176,135 +176,133 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
$this->assertEquals($canEdit, $this->service->userCan($acls, Acl::PERMISSION_EDIT));
|
||||
$this->assertEquals($canShare, $this->service->userCan($acls, Acl::PERMISSION_SHARE));
|
||||
$this->assertEquals($canManage, $this->service->userCan($acls, Acl::PERMISSION_MANAGE));
|
||||
}
|
||||
}
|
||||
|
||||
public function testUserCanFail() {
|
||||
$this->assertFalse($this->service->userCan([], Acl::PERMISSION_EDIT));
|
||||
}
|
||||
|
||||
public function dataCheckPermission() {
|
||||
return [
|
||||
// see getAcls() for set permissions
|
||||
[1, Acl::PERMISSION_READ, true],
|
||||
[1, Acl::PERMISSION_EDIT, false],
|
||||
[1, Acl::PERMISSION_MANAGE, false],
|
||||
[1, Acl::PERMISSION_SHARE, false],
|
||||
public function dataCheckPermission() {
|
||||
return [
|
||||
// see getAcls() for set permissions
|
||||
[1, Acl::PERMISSION_READ, true],
|
||||
[1, Acl::PERMISSION_EDIT, false],
|
||||
[1, Acl::PERMISSION_MANAGE, false],
|
||||
[1, Acl::PERMISSION_SHARE, false],
|
||||
|
||||
[2, Acl::PERMISSION_READ, true],
|
||||
[2, Acl::PERMISSION_EDIT, true],
|
||||
[2, Acl::PERMISSION_MANAGE, false],
|
||||
[2, Acl::PERMISSION_SHARE, false],
|
||||
[2, Acl::PERMISSION_READ, true],
|
||||
[2, Acl::PERMISSION_EDIT, true],
|
||||
[2, Acl::PERMISSION_MANAGE, false],
|
||||
[2, Acl::PERMISSION_SHARE, false],
|
||||
|
||||
[3, Acl::PERMISSION_READ, true],
|
||||
[3, Acl::PERMISSION_EDIT, false],
|
||||
[3, Acl::PERMISSION_MANAGE, true],
|
||||
[3, Acl::PERMISSION_SHARE, false],
|
||||
[3, Acl::PERMISSION_READ, true],
|
||||
[3, Acl::PERMISSION_EDIT, false],
|
||||
[3, Acl::PERMISSION_MANAGE, true],
|
||||
[3, Acl::PERMISSION_SHARE, false],
|
||||
|
||||
[4, Acl::PERMISSION_READ, true],
|
||||
[4, Acl::PERMISSION_EDIT, false],
|
||||
[4, Acl::PERMISSION_MANAGE, false],
|
||||
[4, Acl::PERMISSION_SHARE, true],
|
||||
[4, Acl::PERMISSION_READ, true],
|
||||
[4, Acl::PERMISSION_EDIT, false],
|
||||
[4, Acl::PERMISSION_MANAGE, false],
|
||||
[4, Acl::PERMISSION_SHARE, true],
|
||||
|
||||
[null, Acl::PERMISSION_READ, false],
|
||||
[6, Acl::PERMISSION_READ, false],
|
||||
[null, Acl::PERMISSION_READ, false],
|
||||
[6, Acl::PERMISSION_READ, false],
|
||||
|
||||
[1, Acl::PERMISSION_READ, true, 'admin'],
|
||||
[1, Acl::PERMISSION_EDIT, true, 'admin'],
|
||||
[1, Acl::PERMISSION_MANAGE, true, 'admin'],
|
||||
[1, Acl::PERMISSION_SHARE, true, 'admin'],
|
||||
];
|
||||
}
|
||||
[1, Acl::PERMISSION_READ, true, 'admin'],
|
||||
[1, Acl::PERMISSION_EDIT, true, 'admin'],
|
||||
[1, Acl::PERMISSION_MANAGE, true, 'admin'],
|
||||
[1, Acl::PERMISSION_SHARE, true, 'admin'],
|
||||
];
|
||||
}
|
||||
|
||||
/** @dataProvider dataCheckPermission */
|
||||
public function testCheckPermission($boardId, $permission, $result, $owner='foo') {
|
||||
// Setup mapper
|
||||
$mapper = $this->getMockBuilder(IPermissionMapper::class)->getMock();
|
||||
// Setup mapper
|
||||
$mapper = $this->getMockBuilder(IPermissionMapper::class)->getMock();
|
||||
|
||||
// board owner
|
||||
$mapper->expects($this->once())->method('findBoardId')->willReturn($boardId);
|
||||
$board = new Board();
|
||||
$board->setId($boardId);
|
||||
$board->setOwner($owner);
|
||||
$this->boardMapper->expects($this->any())->method('find')->willReturn($board);
|
||||
// board owner
|
||||
$mapper->expects($this->once())->method('findBoardId')->willReturn($boardId);
|
||||
$board = new Board();
|
||||
$board->setId($boardId);
|
||||
$board->setOwner($owner);
|
||||
$this->boardMapper->expects($this->any())->method('find')->willReturn($board);
|
||||
|
||||
// acl check
|
||||
$acls = $this->getAcls($boardId);
|
||||
$this->aclMapper->expects($this->any())->method('findAll')->willReturn($acls);
|
||||
// acl check
|
||||
$acls = $this->getAcls($boardId);
|
||||
$this->aclMapper->expects($this->any())->method('findAll')->willReturn($acls);
|
||||
|
||||
$this->shareManager->expects($this->any())
|
||||
$this->shareManager->expects($this->any())
|
||||
->method('sharingDisabledForUser')
|
||||
->willReturn(false);
|
||||
|
||||
if($result) {
|
||||
$actual = $this->service->checkPermission($mapper, 1234, $permission);
|
||||
$this->assertTrue($actual);
|
||||
} else {
|
||||
$this->expectException(NoPermissionException::class);
|
||||
$this->service->checkPermission($mapper, 1234, $permission);
|
||||
}
|
||||
if ($result) {
|
||||
$actual = $this->service->checkPermission($mapper, 1234, $permission);
|
||||
$this->assertTrue($actual);
|
||||
} else {
|
||||
$this->expectException(NoPermissionException::class);
|
||||
$this->service->checkPermission($mapper, 1234, $permission);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** @dataProvider dataCheckPermission */
|
||||
public function testCheckPermissionWithoutMapper($boardId, $permission, $result, $owner='foo') {
|
||||
$mapper = null;
|
||||
$board = new Board();
|
||||
$board->setId($boardId);
|
||||
$board->setOwner($owner);
|
||||
if($boardId === null) {
|
||||
$this->boardMapper->expects($this->any())->method('find')->willThrowException(new DoesNotExistException('not found'));
|
||||
} else {
|
||||
$this->boardMapper->expects($this->any())->method('find')->willReturn($board);
|
||||
}
|
||||
$acls = $this->getAcls($boardId);
|
||||
$this->aclMapper->expects($this->any())->method('findAll')->willReturn($acls);
|
||||
/** @dataProvider dataCheckPermission */
|
||||
public function testCheckPermissionWithoutMapper($boardId, $permission, $result, $owner='foo') {
|
||||
$mapper = null;
|
||||
$board = new Board();
|
||||
$board->setId($boardId);
|
||||
$board->setOwner($owner);
|
||||
if ($boardId === null) {
|
||||
$this->boardMapper->expects($this->any())->method('find')->willThrowException(new DoesNotExistException('not found'));
|
||||
} else {
|
||||
$this->boardMapper->expects($this->any())->method('find')->willReturn($board);
|
||||
}
|
||||
$acls = $this->getAcls($boardId);
|
||||
$this->aclMapper->expects($this->any())->method('findAll')->willReturn($acls);
|
||||
|
||||
|
||||
if($result) {
|
||||
$actual = $this->service->checkPermission($mapper, 1234, $permission);
|
||||
$this->assertTrue($actual);
|
||||
} else {
|
||||
$this->expectException(NoPermissionException::class);
|
||||
$this->service->checkPermission($mapper, 1234, $permission);
|
||||
}
|
||||
if ($result) {
|
||||
$actual = $this->service->checkPermission($mapper, 1234, $permission);
|
||||
$this->assertTrue($actual);
|
||||
} else {
|
||||
$this->expectException(NoPermissionException::class);
|
||||
$this->service->checkPermission($mapper, 1234, $permission);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function testCheckPermissionNotFound() {
|
||||
$mapper = $this->getMockBuilder(IPermissionMapper::class)->getMock();
|
||||
$mapper->expects($this->once())->method('findBoardId')->willThrowException(new NoPermissionException(null));
|
||||
public function testCheckPermissionNotFound() {
|
||||
$mapper = $this->getMockBuilder(IPermissionMapper::class)->getMock();
|
||||
$mapper->expects($this->once())->method('findBoardId')->willThrowException(new NoPermissionException(null));
|
||||
$this->expectException(NoPermissionException::class);
|
||||
$this->service->checkPermission($mapper, 1234, Acl::PERMISSION_READ);
|
||||
}
|
||||
$this->service->checkPermission($mapper, 1234, Acl::PERMISSION_READ);
|
||||
}
|
||||
|
||||
private function generateAcl($boardId, $type, $participant, $edit, $manage, $share) {
|
||||
$acl = new Acl();
|
||||
$acl->setParticipant($participant);
|
||||
$acl->setBoardId($boardId);
|
||||
$acl->setType($type);
|
||||
$acl->setPermissionEdit($edit);
|
||||
$acl->setPermissionShare($share);
|
||||
$acl->setPermissionManage($manage);
|
||||
return $acl;
|
||||
}
|
||||
private function generateAcl($boardId, $type, $participant, $edit, $manage, $share) {
|
||||
$acl = new Acl();
|
||||
$acl->setParticipant($participant);
|
||||
$acl->setBoardId($boardId);
|
||||
$acl->setType($type);
|
||||
$acl->setPermissionEdit($edit);
|
||||
$acl->setPermissionShare($share);
|
||||
$acl->setPermissionManage($manage);
|
||||
return $acl;
|
||||
}
|
||||
|
||||
private function getAcls($boardId) {
|
||||
$acls = [
|
||||
$this->generateAcl(1, 'user', 'admin', false, false, false),
|
||||
$this->generateAcl(2, 'user', 'admin', true, false, false),
|
||||
$this->generateAcl(3, 'user', 'admin', false, true, false),
|
||||
$this->generateAcl(4, 'user', 'admin', false, false, true),
|
||||
$this->generateAcl(5, 'group', 'admin', false, false, false),
|
||||
$this->generateAcl(6, 'user', 'foo', false, false, false)
|
||||
];
|
||||
$result = [];
|
||||
foreach ($acls as $acl) {
|
||||
if($acl->getBoardId() === $boardId) {
|
||||
$result[] = $acl;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
private function getAcls($boardId) {
|
||||
$acls = [
|
||||
$this->generateAcl(1, 'user', 'admin', false, false, false),
|
||||
$this->generateAcl(2, 'user', 'admin', true, false, false),
|
||||
$this->generateAcl(3, 'user', 'admin', false, true, false),
|
||||
$this->generateAcl(4, 'user', 'admin', false, false, true),
|
||||
$this->generateAcl(5, 'group', 'admin', false, false, false),
|
||||
$this->generateAcl(6, 'user', 'foo', false, false, false)
|
||||
];
|
||||
$result = [];
|
||||
foreach ($acls as $acl) {
|
||||
if ($acl->getBoardId() === $boardId) {
|
||||
$result[] = $acl;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function testFindUsersFail() {
|
||||
$this->boardMapper->expects($this->once())
|
||||
@@ -374,5 +372,4 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
'user3' => new User($user3),
|
||||
], $users);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace OCA\Deck\Service;
|
||||
|
||||
|
||||
|
||||
use OCA\Deck\Activity\ActivityManager;
|
||||
use OCA\Deck\Db\AssignedUsersMapper;
|
||||
use OCA\Deck\Db\Card;
|
||||
@@ -46,17 +44,17 @@ use \Test\TestCase;
|
||||
*/
|
||||
class StackServiceTest extends TestCase {
|
||||
|
||||
/** @var StackService */
|
||||
/** @var StackService */
|
||||
private $stackService;
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|StackMapper */
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|StackMapper */
|
||||
private $stackMapper;
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|CardMapper */
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|CardMapper */
|
||||
private $cardMapper;
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|BoardMapper */
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|BoardMapper */
|
||||
private $boardMapper;
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|LabelMapper */
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|LabelMapper */
|
||||
private $labelMapper;
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|PermissionService */
|
||||
/** @var \PHPUnit\Framework\MockObject\MockObject|PermissionService */
|
||||
private $permissionService;
|
||||
/** @var AssignedUsersMapper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $assignedUsersMapper;
|
||||
@@ -105,89 +103,89 @@ 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->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->returnCallback(
|
||||
function($card) {
|
||||
function ($card) {
|
||||
$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));
|
||||
|
||||
|
||||
$actual = $this->stackService->findAll(123);
|
||||
for($stackId=0; $stackId<3; $stackId++) {
|
||||
for ($cardId=0;$cardId<10;$cardId++) {
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getId(), $cardId);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getStackId(), 222);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getLabels(), $this->getLabels()[$cardId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$actual = $this->stackService->findAll(123);
|
||||
for ($stackId=0; $stackId<3; $stackId++) {
|
||||
for ($cardId=0;$cardId<10;$cardId++) {
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getId(), $cardId);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getStackId(), 222);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getLabels(), $this->getLabels()[$cardId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testFindAllArchived() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$this->stackMapper->expects($this->once())->method('findAll')->willReturn($this->getStacks());
|
||||
$this->labelMapper->expects($this->once())->method('getAssignedLabelsForBoard')->willReturn($this->getLabels());
|
||||
$this->cardMapper->expects($this->any())->method('findAllArchived')->willReturn($this->getCards(222));
|
||||
public function testFindAllArchived() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$this->stackMapper->expects($this->once())->method('findAll')->willReturn($this->getStacks());
|
||||
$this->labelMapper->expects($this->once())->method('getAssignedLabelsForBoard')->willReturn($this->getLabels());
|
||||
$this->cardMapper->expects($this->any())->method('findAllArchived')->willReturn($this->getCards(222));
|
||||
|
||||
$actual = $this->stackService->findAllArchived(123);
|
||||
for($stackId=0; $stackId<3; $stackId++) {
|
||||
for ($cardId=0;$cardId<10;$cardId++) {
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getId(), $cardId);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getStackId(), 222);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getLabels(), $this->getLabels()[$cardId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$actual = $this->stackService->findAllArchived(123);
|
||||
for ($stackId=0; $stackId<3; $stackId++) {
|
||||
for ($cardId=0;$cardId<10;$cardId++) {
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getId(), $cardId);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getStackId(), 222);
|
||||
$this->assertEquals($actual[0]->getCards()[$cardId]->getLabels(), $this->getLabels()[$cardId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getLabels() {
|
||||
for ($i=0;$i<10;$i++) {
|
||||
$label1 = new Label();
|
||||
$label1->setTitle('Important');
|
||||
$label1->setCardId(1);
|
||||
$label2 = new Label();
|
||||
$label2->setTitle('Maybe');
|
||||
$label2->setCardId(2);
|
||||
$labels[$i] = [
|
||||
$label1,
|
||||
$label2
|
||||
];
|
||||
}
|
||||
return $labels;
|
||||
}
|
||||
private function getStacks() {
|
||||
$s1 = new Stack();
|
||||
$s1->setId(222);
|
||||
$s1->setBoardId(1);
|
||||
$s2 = new Stack();
|
||||
$s2->setId(223);
|
||||
$s1->setBoardId(1);
|
||||
return [$s1, $s2];
|
||||
}
|
||||
private function getCards($stackId=0) {
|
||||
$cards = [];
|
||||
for ($i=0;$i<10;$i++) {
|
||||
$cards[$i] = new Card();
|
||||
$cards[$i]->setId($i);
|
||||
$cards[$i]->setStackId($stackId);
|
||||
}
|
||||
return $cards;
|
||||
}
|
||||
private function getLabels() {
|
||||
for ($i=0;$i<10;$i++) {
|
||||
$label1 = new Label();
|
||||
$label1->setTitle('Important');
|
||||
$label1->setCardId(1);
|
||||
$label2 = new Label();
|
||||
$label2->setTitle('Maybe');
|
||||
$label2->setCardId(2);
|
||||
$labels[$i] = [
|
||||
$label1,
|
||||
$label2
|
||||
];
|
||||
}
|
||||
return $labels;
|
||||
}
|
||||
private function getStacks() {
|
||||
$s1 = new Stack();
|
||||
$s1->setId(222);
|
||||
$s1->setBoardId(1);
|
||||
$s2 = new Stack();
|
||||
$s2->setId(223);
|
||||
$s1->setBoardId(1);
|
||||
return [$s1, $s2];
|
||||
}
|
||||
private function getCards($stackId=0) {
|
||||
$cards = [];
|
||||
for ($i=0;$i<10;$i++) {
|
||||
$cards[$i] = new Card();
|
||||
$cards[$i]->setId($i);
|
||||
$cards[$i]->setStackId($stackId);
|
||||
}
|
||||
return $cards;
|
||||
}
|
||||
|
||||
public function testCreate() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$stack = new Stack();
|
||||
$stack->setId(123);
|
||||
$stack->setTitle('Foo');
|
||||
$stack->setBoardId(2);
|
||||
$stack->setOrder(1);
|
||||
$this->stackMapper->expects($this->once())->method('insert')->willReturn($stack);
|
||||
$result = $this->stackService->create('Foo', 2, 1);
|
||||
$this->assertEquals($stack, $result);
|
||||
}
|
||||
public function testCreate() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$stack = new Stack();
|
||||
$stack->setId(123);
|
||||
$stack->setTitle('Foo');
|
||||
$stack->setBoardId(2);
|
||||
$stack->setOrder(1);
|
||||
$this->stackMapper->expects($this->once())->method('insert')->willReturn($stack);
|
||||
$result = $this->stackService->create('Foo', 2, 1);
|
||||
$this->assertEquals($stack, $result);
|
||||
}
|
||||
|
||||
public function testDelete() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
@@ -199,26 +197,25 @@ class StackServiceTest extends TestCase {
|
||||
$this->stackService->delete(123);
|
||||
$this->assertTrue($stackToBeDeleted->getDeletedAt() <= time(), "deletedAt is in the past");
|
||||
$this->assertTrue($stackToBeDeleted->getDeletedAt() > 0, "deletedAt is set");
|
||||
|
||||
}
|
||||
|
||||
public function testUpdate() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$stack = new Stack();
|
||||
$this->stackMapper->expects($this->once())->method('find')->willReturn($stack);
|
||||
$this->stackMapper->expects($this->once())->method('update')->willReturn($stack);
|
||||
$stack->setId(123);
|
||||
$stack->setTitle('Foo');
|
||||
$stack->setBoardId(2);
|
||||
$stack->setOrder(1);
|
||||
$result = $this->stackService->update(123, 'Foo', 2, 1, null);
|
||||
$this->assertEquals($stack, $result);
|
||||
}
|
||||
public function testUpdate() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$stack = new Stack();
|
||||
$this->stackMapper->expects($this->once())->method('find')->willReturn($stack);
|
||||
$this->stackMapper->expects($this->once())->method('update')->willReturn($stack);
|
||||
$stack->setId(123);
|
||||
$stack->setTitle('Foo');
|
||||
$stack->setBoardId(2);
|
||||
$stack->setOrder(1);
|
||||
$result = $this->stackService->update(123, 'Foo', 2, 1, null);
|
||||
$this->assertEquals($stack, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
public function testReorder() {
|
||||
public function testReorder() {
|
||||
$this->permissionService->expects($this->once())->method('checkPermission');
|
||||
$a = $this->createStack(1, 0);
|
||||
$b = $this->createStack(2, 1);
|
||||
@@ -245,5 +242,4 @@ class StackServiceTest extends TestCase {
|
||||
$stack->setOrder($order);
|
||||
return $stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user