@@ -32,6 +32,8 @@ use OCA\Deck\Db\AttachmentMapper;
|
||||
use OCA\Deck\Db\CardMapper;
|
||||
use OCA\Deck\Db\ChangeHelper;
|
||||
use OCA\Deck\InvalidAttachmentType;
|
||||
use OCA\Deck\NoPermissionException;
|
||||
use OCA\Deck\NotFoundException;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\IAppContainer;
|
||||
use OCP\ICache;
|
||||
@@ -80,7 +82,7 @@ class AttachmentServiceTest extends TestCase {
|
||||
/**
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->attachmentServiceImpl = $this->createMock(IAttachmentService::class);
|
||||
@@ -122,10 +124,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
$this->assertEquals(MyAttachmentService::class, get_class($attachmentService->getService('custom')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\Deck\InvalidAttachmentType
|
||||
*/
|
||||
public function testRegisterAttachmentServiceNotExisting() {
|
||||
$this->expectException(InvalidAttachmentType::class);
|
||||
$application = $this->createMock(Application::class);
|
||||
$appContainer = $this->createMock(IAppContainer::class);
|
||||
$fileServiceMock = $this->createMock(FileService::class);
|
||||
@@ -251,10 +251,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
$this->assertEquals($response, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\Deck\NotFoundException
|
||||
*/
|
||||
public function testDisplayInvalid() {
|
||||
$this->expectException(NotFoundException::class);
|
||||
$attachment = $this->createAttachment('deck_file', 'filename');
|
||||
$response = new Response();
|
||||
$this->mockPermission(Acl::PERMISSION_READ);
|
||||
@@ -357,10 +355,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\Deck\NoPermissionException
|
||||
*/
|
||||
public function testRestoreNotAllowed() {
|
||||
$this->expectException(NoPermissionException::class);
|
||||
$attachment = $this->createAttachment('deck_file', 'file_name.jpg');
|
||||
$expected = $this->createAttachment('deck_file', 'file_name.jpg');
|
||||
$this->mockPermission(Acl::PERMISSION_EDIT);
|
||||
|
||||
@@ -73,7 +73,7 @@ class BoardServiceTest extends TestCase {
|
||||
private $eventDispatcher;
|
||||
private $userId = 'admin';
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->l10n = $this->createMock(L10N::class);
|
||||
$this->aclMapper = $this->createMock(AclMapper::class);
|
||||
@@ -178,10 +178,8 @@ class BoardServiceTest extends TestCase {
|
||||
$this->assertCount(4, $b->getLabels());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\Deck\NoPermissionException
|
||||
*/
|
||||
public function testCreateDenied() {
|
||||
$this->expectException(\OCA\Deck\NoPermissionException::class);
|
||||
$board = new Board();
|
||||
$board->setTitle('MyBoard');
|
||||
$board->setOwner('admin');
|
||||
|
||||
@@ -76,7 +76,7 @@ class CardServiceTest extends TestCase {
|
||||
/** @var ChangeHelper|MockObject */
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->cardMapper = $this->createMock(CardMapper::class);
|
||||
$this->stackMapper = $this->createMock(StackMapper::class);
|
||||
|
||||
@@ -36,9 +36,9 @@ use OCP\IL10N;
|
||||
use \Test\TestCase;
|
||||
|
||||
class DefaultBoardServiceTest extends TestCase {
|
||||
|
||||
|
||||
/** @var DefaultBoardService */
|
||||
private $service;
|
||||
private $service;
|
||||
|
||||
/** @var BoardService */
|
||||
private $boardService;
|
||||
@@ -50,16 +50,16 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
private $cardService;
|
||||
|
||||
/** @var BoardMapper */
|
||||
private $boardMapper;
|
||||
private $boardMapper;
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
private $l10n;
|
||||
|
||||
private $userId = 'admin';
|
||||
|
||||
public function setUp() {
|
||||
private $userId = 'admin';
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->boardMapper = $this->createMock(BoardMapper::class);
|
||||
$this->boardService = $this->createMock(BoardService::class);
|
||||
@@ -76,7 +76,7 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
$this->stackService,
|
||||
$this->cardService,
|
||||
$this->config
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
public function testCheckFirstRunCaseTrue() {
|
||||
@@ -86,13 +86,13 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
$this->config->expects($this->once())
|
||||
->method('getUserValue')
|
||||
->willReturn('yes');
|
||||
|
||||
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByUser')
|
||||
->willReturn($userBoards);
|
||||
|
||||
$this->config->expects($this->once())
|
||||
->method('setUserValue');
|
||||
->method('setUserValue');
|
||||
|
||||
$result = $this->service->checkFirstRun($this->userId, $appName);
|
||||
$this->assertEquals($result, true);
|
||||
@@ -119,11 +119,11 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
$this->assertEquals($result, false);
|
||||
}
|
||||
|
||||
public function testCreateDefaultBoard() {
|
||||
$title = 'Personal';
|
||||
public function testCreateDefaultBoard() {
|
||||
$title = 'Personal';
|
||||
$color = '000000';
|
||||
$boardId = 5;
|
||||
|
||||
|
||||
$board = new Board();
|
||||
$board->setId($boardId);
|
||||
$board->setTitle($title);
|
||||
@@ -137,12 +137,12 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
->method('t')
|
||||
->willReturnCallback(function($text) { return $text; });
|
||||
|
||||
$stackToDoId = '123';
|
||||
$stackToDoId = '123';
|
||||
$stackToDo = $this->assembleTestStack('To do', $stackToDoId, $boardId);
|
||||
|
||||
$stackDoingId = '124';
|
||||
|
||||
$stackDoingId = '124';
|
||||
$stackDoing = $this->assembleTestStack('Doing', $stackDoingId, $boardId);
|
||||
|
||||
|
||||
$stackDoneId = '125';
|
||||
$stackDone = $this->assembleTestStack('Done', $stackDoneId, $boardId);
|
||||
$this->stackService->expects($this->exactly(3))
|
||||
@@ -153,7 +153,7 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
[$this->l10n->t('Done'), $boardId, 1]
|
||||
)
|
||||
->willReturnOnConsecutiveCalls($stackToDo, $stackDoing, $stackDone);
|
||||
|
||||
|
||||
$cardExampleTask3 = $this->assembleTestCard('Example Task 3', $stackToDoId, $this->userId);
|
||||
$cardExampleTask2 = $this->assembleTestCard('Example Task 2', $stackDoingId, $this->userId);
|
||||
$cardExampleTask1 = $this->assembleTestCard('Example Task 1', $stackDoneId, $this->userId);
|
||||
@@ -172,8 +172,8 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
$this->assertEquals($result->getOwner(), $this->userId);
|
||||
$this->assertEquals($result->getColor(), $color);
|
||||
}
|
||||
|
||||
private function assembleTestStack($title, $id, $boardId) {
|
||||
|
||||
private function assembleTestStack($title, $id, $boardId) {
|
||||
$stack = new Stack();
|
||||
$stack->setId($id);
|
||||
$stack->setTitle($title);
|
||||
@@ -193,4 +193,4 @@ class DefaultBoardServiceTest extends TestCase {
|
||||
|
||||
return $card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class FileServiceTest extends TestCase {
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
$this->appData = $this->createMock(IAppData::class);
|
||||
@@ -161,10 +161,8 @@ class FileServiceTest extends TestCase {
|
||||
$this->assertEquals($expected, $this->fileService->extendData($attachment));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testCreateEmpty() {
|
||||
$this->expectException(\Exception::class);
|
||||
$attachment = $this->getAttachment();
|
||||
$this->l10n->expects($this->any())
|
||||
->method('t')
|
||||
@@ -173,10 +171,8 @@ class FileServiceTest extends TestCase {
|
||||
$this->fileService->create($attachment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testCreateError() {
|
||||
$this->expectException(\Exception::class);
|
||||
$attachment = $this->getAttachment();
|
||||
$this->mockGetUploadedFileError(UPLOAD_ERR_INI_SIZE);
|
||||
$this->l10n->expects($this->any())
|
||||
@@ -221,11 +217,10 @@ class FileServiceTest extends TestCase {
|
||||
$this->fileService->create($attachment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedExceptionMessage File already exists.
|
||||
*/
|
||||
public function testCreateExists() {
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('File already exists.');
|
||||
|
||||
$attachment = $this->getAttachment();
|
||||
$this->mockGetUploadedFile();
|
||||
$folder = $this->mockGetFolder(123);
|
||||
@@ -336,4 +331,4 @@ class FileServiceTest extends TestCase {
|
||||
$this->fileService->markAsDeleted($attachment);
|
||||
$this->assertGreaterThan(0, $attachment->getDeletedAt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class LabelServiceTest extends TestCase {
|
||||
/** @var ChangeHelper|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $changeHelper;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->labelMapper = $this->getMockBuilder(LabelMapper::class)
|
||||
->disableOriginalConstructor()->getMock();
|
||||
|
||||
@@ -60,7 +60,7 @@ class PermissionServiceTest extends \Test\TestCase {
|
||||
/** @var string */
|
||||
private $userId = 'admin';
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->logger = $this->request = $this->createMock(ILogger::class);
|
||||
$this->aclMapper = $this->createMock(AclMapper::class);
|
||||
|
||||
@@ -73,7 +73,7 @@ class StackServiceTest extends TestCase {
|
||||
/** @var EventDispatcherInterface */
|
||||
private $eventDispatcher;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->stackMapper = $this->createMock(StackMapper::class);
|
||||
$this->cardMapper = $this->createMock(CardMapper::class);
|
||||
|
||||
Reference in New Issue
Block a user