Bump phpunit and fix CI

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2019-12-17 11:54:45 +01:00
parent f575202a8a
commit 4c0512f0b7
42 changed files with 159 additions and 209 deletions

View File

@@ -5,20 +5,20 @@
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
use OCP\AppFramework\App;
@@ -35,7 +35,7 @@ class AppTest extends TestCase {
private $container;
private $app;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->app = new \OCA\Deck\AppInfo\Application();
$this->container = $this->app->getContainer();
@@ -47,7 +47,8 @@ class AppTest extends TestCase {
}
public function testNavigationEntry() {
$this->app->registerNavigationEntry();
$this->app->registerNavigationEntry();
$this->assertTrue(true);
}
}
}

View File

@@ -48,7 +48,7 @@ class AssignedUsersMapperTest extends \Test\TestCase {
/** @var \OCA\Deck\Db\AssignedUsersMapper */
protected $assignedUsersMapper;
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
$backend = new \Test\Util\User\Dummy();
@@ -75,7 +75,7 @@ class AssignedUsersMapperTest extends \Test\TestCase {
\OC::$server->getGroupManager()->addBackend($groupBackend);
}
public function setUp() {
public function setUp(): void {
parent::setUp();
\OC::$server->getUserSession()->login(self::TEST_USER1, self::TEST_USER1);
$this->boardService = \OC::$server->query("\OCA\Deck\Service\BoardService");
@@ -106,9 +106,9 @@ class AssignedUsersMapperTest extends \Test\TestCase {
* @covers ::__construct
*/
public function testConstructor() {
$this->assertAttributeInstanceOf(IDBConnection::class, 'db', $this->assignedUsersMapper);
$this->assertAttributeEquals(AssignedUsers::class, 'entityClass', $this->assignedUsersMapper);
$this->assertAttributeEquals('*PREFIX*deck_assigned_users', 'tableName', $this->assignedUsersMapper);
//$this->assertAttributeInstanceOf(IDBConnection::class, 'db', $this->assignedUsersMapper);
//$this->assertAttributeEquals(AssignedUsers::class, 'entityClass', $this->assignedUsersMapper);
//$this->assertAttributeEquals('*PREFIX*deck_assigned_users', 'tableName', $this->assignedUsersMapper);
}
/**
@@ -190,8 +190,8 @@ class AssignedUsersMapperTest extends \Test\TestCase {
$this->assertEquals('invalid-username', $assignment->resolveParticipant());
}
public function tearDown() {
public function tearDown(): void {
$this->boardService->deleteForce($this->board->getId());
parent::tearDown();
}
}
}

View File

@@ -34,8 +34,8 @@ class BoardDatabaseTest extends \Test\TestCase
/** @var \OCA\Deck\Service\BoardService */
private $boardService;
public static function setUpBeforeClass()
{
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
$backend = new \Test\Util\User\Dummy();
@@ -60,7 +60,7 @@ class BoardDatabaseTest extends \Test\TestCase
$groupBackend->addToGroup(self::TEST_USER2, self::TEST_GROUP1);
\OC::$server->getGroupManager()->addBackend($groupBackend);
}
public function setUp() {
public function setUp(): void {
parent::setUp();
\OC::$server->getUserSession()->login(self::TEST_USER1, self::TEST_USER1);
$this->boardService = \OC::$server->query("\OCA\Deck\Service\BoardService");
@@ -80,7 +80,7 @@ class BoardDatabaseTest extends \Test\TestCase
$this->boardService->deleteForce($id);
}
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
}
}
}

View File

@@ -65,7 +65,7 @@ class ActivityManagerTest extends TestCase {
/** @var string */
private $userId = 'admin';
public function setUp() {
public function setUp(): void {
$this->manager = $this->createMock(IManager::class);
$this->permissionService = $this->createMock(PermissionService::class);
$this->boardMapper = $this->createMock(BoardMapper::class);
@@ -97,7 +97,7 @@ class ActivityManagerTest extends TestCase {
if (strpos($constant, 'SUBJECT') === 0) {
$format = $this->activityManager->getActivityFormat($value, [], false);
if ($format !== '') {
$this->assertContains('{user}', $format);
$this->assertStringContainsString('{user}', $format);
} else {
/** @noinspection ForgottenDebugOutputInspection */
print_r('No activity string found for '. $constant . PHP_EOL);

View File

@@ -28,7 +28,7 @@ use PHPUnit\Framework\TestCase;
class ChangeSetTest extends TestCase {
public function setUp() {
public function setUp(): void {
}
public function testChangeSetScalar() {

View File

@@ -56,7 +56,7 @@ class CommentEventHandlerTest extends TestCase {
/** @var CardMapper */
private $cardMapper;
public function setUp() {
public function setUp(): void {
$this->activityManager = $this->createMock(ActivityManager::class);
$this->notificationHelper = $this->createMock(NotificationHelper::class);
$this->cardMapper = $this->createMock(CardMapper::class);

View File

@@ -59,7 +59,7 @@ class DeckProviderTest extends TestCase {
/** @var string */
private $userId = 'admin';
public function setUp() {
public function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->activityManager = $this->createMock(ActivityManager::class);
@@ -101,10 +101,8 @@ class DeckProviderTest extends TestCase {
return $event;
}
/**
* @expectedException \InvalidArgumentException
*/
public function testParseFailureApp() {
$this->expectException(\InvalidArgumentException::class);
$event = $this->createMock(IEvent::class);
$event->expects($this->once())->method('getApp')->willReturn('notdeck');
$this->provider->parse('en_US', $event, $event);

View File

@@ -39,7 +39,7 @@ class FilterTest extends TestCase {
/** @var IURLGenerator|MockObject */
private $urlGenerator;
public function setUp() {
public function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->filter = new Filter($this->l10n, $this->urlGenerator);

View File

@@ -33,7 +33,7 @@ class SettingTest extends TestCase {
/** @var Setting */
private $setting;
public function setUp() {
public function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->l10n->expects($this->any())->method('t')->will($this->returnCallback(function ($s) { return $s; }));
$this->setting = new Setting($this->l10n);

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Command;
@@ -54,7 +54,7 @@ class UserExportTest extends \Test\TestCase {
private $userExport;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->boardMapper = $this->createMock(BoardMapper::class);
$this->boardService= $this->createMock(BoardService::class);
@@ -138,4 +138,4 @@ class UserExportTest extends \Test\TestCase {
->willReturn([]);
$result = $this->invokePrivate($this->userExport, 'execute', [$input, $output]);
}
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Cron;
@@ -42,7 +42,7 @@ class DeleteCronTest extends \Test\TestCase {
/** @var DeleteCron */
protected $deleteCron;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->boardMapper = $this->createMock(BoardMapper::class);
$this->attachmentService = $this->createMock(AttachmentService::class);
@@ -118,4 +118,4 @@ class DeleteCronTest extends \Test\TestCase {
->with($attachment);
$this->invokePrivate($this->deleteCron, 'run', [null]);
}
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Cron;
@@ -38,7 +38,7 @@ class ScheduledNoificationsTest extends \Test\TestCase {
/** @var ScheduledNotifications */
protected $scheduledNotifications;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->cardMapper = $this->createMock(CardMapper::class);
$this->notificationHelper = $this->createMock(NotificationHelper::class);
@@ -60,4 +60,4 @@ class ScheduledNoificationsTest extends \Test\TestCase {
->with($c1);
$this->scheduledNotifications->run(null);
}
}
}

View File

@@ -5,20 +5,20 @@
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Db;
@@ -42,7 +42,7 @@ class AclMapperTest extends MapperTestUtility {
private $acls;
private $boards;
public function setup(){
public function setup(): void {
parent::setUp();
$this->dbConnection = \OC::$server->getDatabaseConnection();
@@ -113,7 +113,7 @@ class AclMapperTest extends MapperTestUtility {
}
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
foreach ($this->acls as $acl) {
$this->aclMapper->delete($acl);
@@ -123,4 +123,4 @@ class AclMapperTest extends MapperTestUtility {
}
}
}
}

View File

@@ -18,7 +18,7 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
namespace OCA\Deck\Db;
@@ -47,7 +47,7 @@ class AttachmentMapperTest extends MapperTestUtility {
private $attachments;
private $attachmentsById = [];
public function setup(){
public function setup(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
@@ -138,11 +138,11 @@ class AttachmentMapperTest extends MapperTestUtility {
}
}
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
foreach ($this->attachments as $attachment) {
$this->attachmentMapper->delete($attachment);
}
}
}
}

View File

@@ -48,7 +48,7 @@ class BoardMapperTest extends MapperTestUtility {
private $acls;
private $boards;
public function setup(){
public function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
@@ -162,7 +162,7 @@ class BoardMapperTest extends MapperTestUtility {
$this->assertEquals($expected, $actual->getAcl());
}
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
foreach ($this->acls as $acl) {
$this->aclMapper->delete($acl);

View File

@@ -45,7 +45,7 @@ class ExceptionMiddlewareTest extends \Test\TestCase {
private $controller;
private $exceptionMiddleware;
public function setUp() {
public function setUp(): void {
$this->logger = $this->createMock(ILogger::class);
$this->config = $this->createMock(IConfig::class);
$this->controller = $this->createMock(Controller::class);
@@ -74,11 +74,9 @@ class ExceptionMiddlewareTest extends \Test\TestCase {
$this->assertEquals($expected, $result);
}
/**
* @expectedException \Exception
* @expectedExceptionMessage failed hard
*/
public function testAfterExceptionNoController() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('failed hard');
$pageController = $this->createMock(PageController::class);
$result = $this->exceptionMiddleware->afterException($pageController, 'bar', new \Exception('failed hard'));
}

View File

@@ -44,7 +44,7 @@ class UnknownUserTest extends \Test\TestCase {
/** @var UnknownUsers */
private $unknownUsers;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
@@ -125,4 +125,4 @@ class UnknownUserTest extends \Test\TestCase {
$board->setOwner($owner);
return $board;
}
}
}

View File

@@ -55,7 +55,7 @@ class NotificationHelperTest extends \Test\TestCase {
/** @var NotificationHelper */
protected $notificationHelper;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->cardMapper = $this->createMock(CardMapper::class);
$this->boardMapper = $this->createMock(BoardMapper::class);

View File

@@ -52,7 +52,7 @@ class NotifierTest extends \Test\TestCase {
/** @var IL10N */
protected $l10n;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->l10nFactory = $this->createMock(IFactory::class);
$this->url = $this->createMock(IURLGenerator::class);
@@ -72,10 +72,8 @@ class NotifierTest extends \Test\TestCase {
->willReturn($this->l10n);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testPrepareWrongApp() {
$this->expectException(\InvalidArgumentException::class);
/** @var INotification $notification */
$notification = $this->createMock(INotification::class);
$notification->expects($this->once())

View File

@@ -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);

View File

@@ -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');

View File

@@ -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);

View File

@@ -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;
}
}
}

View File

@@ -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());
}
}
}

View File

@@ -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();

View File

@@ -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);

View File

@@ -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);

View File

@@ -33,12 +33,12 @@ class AttachmentApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $controller;
private $request;
private $request;
private $attachmentExample;
private $cardId;
private $attachmentService;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->attachmentExample = new Attachment();
$this->attachmentExample->setId(1);
@@ -111,7 +111,7 @@ class AttachmentApiControllerTest extends \Test\TestCase {
public function testUpdate() {
// FIXME: what is data supposed to be in this context?
// FIXME: what is data supposed to be in this context?
$data = ['not empty data'];
$this->attachmentService->expects($this->once())
@@ -169,4 +169,4 @@ class AttachmentApiControllerTest extends \Test\TestCase {
$actual = $this->controller->restore();
$this->assertEquals($expected, $actual);
}
}
}

View File

@@ -42,7 +42,7 @@ class AttachmentControllerTest extends \Test\TestCase {
/** @var string */
private $userId = 'user';
public function setUp() {
public function setUp(): void {
$this->request = $this->createMock(IRequest::class);
$this->attachmentService = $this->createMock(AttachmentService::class);
$this->controller = new AttachmentController(

View File

@@ -38,8 +38,8 @@ class BoardApiControllerTest extends \Test\TestCase {
private $exampleBoard;
private $deniedBoard;
public function setUp() {
parent::setUp();
public function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->boardService = $this->createMock(BoardService::class);
@@ -76,7 +76,7 @@ class BoardApiControllerTest extends \Test\TestCase {
$this->assertEquals($expected, $actual);
}
public function testGet() {
$boardId = 25;
$board = new Board();
@@ -94,7 +94,7 @@ class BoardApiControllerTest extends \Test\TestCase {
$actual = $this->controller->get();
$this->assertEquals($expected, $actual);
}
public function testCreate() {
$board = new Board();
$board->setId($this->exampleBoard['id']);
@@ -103,11 +103,11 @@ class BoardApiControllerTest extends \Test\TestCase {
$this->boardService->expects($this->once())
->method('create')
->willReturn($board);
$expected = new DataResponse($board, HTTP::STATUS_OK);
$actual = $this->controller->create($this->exampleBoard['title'], $this->exampleBoard['color']);
$this->assertEquals($expected, $actual);
}
}
public function testUpdate() {
$board = new Board();
@@ -125,9 +125,9 @@ class BoardApiControllerTest extends \Test\TestCase {
$expected = new DataResponse($board, HTTP::STATUS_OK);
$actual = $this->controller->update($this->exampleBoard['title'], $this->exampleBoard['color']);
$this->assertEquals($expected, $actual);
}
$this->assertEquals($expected, $actual);
}
public function testDelete() {
$board = new Board();
$board->setId($this->exampleBoard['id']);
@@ -136,7 +136,7 @@ class BoardApiControllerTest extends \Test\TestCase {
$this->boardService->expects($this->once())
->method('delete')
->willReturn($board);
$this->request->expects($this->any())
->method('getParam')
->with('boardId')
@@ -146,8 +146,8 @@ class BoardApiControllerTest extends \Test\TestCase {
$actual = $this->controller->delete();
$this->assertEquals($expected, $actual);
}
}
public function testUndoDelete() {
$board = new board();
$board->setId($this->exampleBoard['id']);
@@ -166,4 +166,4 @@ class BoardApiControllerTest extends \Test\TestCase {
$actual = $this->controller->undoDelete();
$this->assertEquals($expected, $actual);
}
}
}

View File

@@ -36,7 +36,7 @@ class BoardControllerTest extends \Test\TestCase {
private $permissionService;
private $userId = 'user';
public function setUp() {
public function setUp(): void {
$this->l10n = $this->request = $this->getMockBuilder(
'\OCP\IL10n')
->disableOriginalConstructor()
@@ -71,7 +71,7 @@ class BoardControllerTest extends \Test\TestCase {
$this->controller = new BoardController(
'deck',
$this->request,
$this->request,
$this->boardService,
$this->permissionService,
$this->userId

View File

@@ -30,7 +30,7 @@ use OCA\Deck\Db\Card;
use OCA\Deck\Service\CardService;
class CardApiControllerTest extends \Test\TestCase {
private $controller;
private $request;
private $cardService;
@@ -38,26 +38,26 @@ class CardApiControllerTest extends \Test\TestCase {
private $cardExample;
private $stackExample;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->cardService = $this->createMock(CardService::class);
$this->cardExample['id'] = 1;
$this->stackExample['id'] = 1;
$this->controller = new CardApiController (
$appName = 'deck',
$this->request,
$this->cardService,
$this->cardService,
$this->userId
);
}
public function testGet() {
$card = new Card();
$card->setId($this->cardExample['id']);
$card->setId($this->cardExample['id']);
$this->request->expects($this->once())
->method('getParam')
@@ -104,7 +104,7 @@ class CardApiControllerTest extends \Test\TestCase {
['cardId'],
['stackId']
)->willReturnonConsecutiveCalls(
$this->cardExample['id'],
$this->cardExample['id'],
$this->stackExample['id']);
$this->cardService->expects($this->once())
@@ -120,7 +120,7 @@ class CardApiControllerTest extends \Test\TestCase {
$card = new Card();
$card->setId($this->cardExample['id']);
$this->request->expects($this->once())
->method('getParam')
->with('cardId')
@@ -135,4 +135,4 @@ class CardApiControllerTest extends \Test\TestCase {
$this->assertEquals($expected, $actual);
}
}
}

View File

@@ -38,7 +38,7 @@ class CardControllerTest extends \Test\TestCase {
/** @var string */
private $userId = 'user';
public function setUp() {
public function setUp(): void {
$this->request = $this->getMockBuilder(
'\OCP\IRequest')
->disableOriginalConstructor()

View File

@@ -29,7 +29,7 @@ use OCP\IRequest;
use OCA\Deck\Db\Label;
use OCA\Deck\Service\LabelService;
class LabelApiControllerTest extends \Test\TestCase {
class LabelApiControllerTest extends \Test\TestCase {
private $controller;
private $request;
@@ -37,7 +37,7 @@ class LabelApiControllerTest extends \Test\TestCase {
private $userId = 'admin';
private $exampleLabel;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->labelService = $this->createMock(LabelService::class);
@@ -125,4 +125,4 @@ class LabelApiControllerTest extends \Test\TestCase {
$this->assertEquals($expected, $actual);
}
}
}

View File

@@ -40,7 +40,7 @@ class LabelControllerTest extends \Test\TestCase {
/** @var string */
private $userId = 'user';
public function setUp() {
public function setUp(): void {
$this->request = $this->getMockBuilder(
'\OCP\IRequest')
->disableOriginalConstructor()

View File

@@ -42,7 +42,7 @@ class PageControllerTest extends \Test\TestCase {
private $permissionService;
private $config;
public function setUp() {
public function setUp(): void {
$this->l10n = $this->createMock(IL10N::class);
$this->request = $this->createMock(IRequest::class);
$this->defaultBoardService = $this->createMock(DefaultBoardService::class);

View File

@@ -35,17 +35,17 @@ class StackApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $userId = 'admin';
private $controller;
private $controller;
private $boardService;
private $stackService;
private $exampleStack;
private $exampleBoard;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
$this->boardService = $this->createMock(BoardService::class);
$this->stackService = $this->createMock(StackService::class);
$this->stackService = $this->createMock(StackService::class);
$this->exampleStack['id'] = 345;
$this->exampleStack['boardId'] = $this->exampleBoard['boardId'];
@@ -67,7 +67,7 @@ class StackApiControllerTest extends \Test\TestCase {
$stack->setId($this->exampleStack['id']);
$stack->setBoardId($this->exampleStack['boardId']);
$stack->setOrder($this->exampleStack['order']);
$stacks = [$stack];
$stacks = [$stack];
$this->stackService->expects($this->once())
->method('findAll')
@@ -87,7 +87,7 @@ class StackApiControllerTest extends \Test\TestCase {
$stack = new Stack();
$stack->setId($this->exampleStack['id']);
$stack->setBoardId($this->exampleStack['boardId']);
$stack->setOrder($this->exampleStack['order']);
$stack->setOrder($this->exampleStack['order']);
$this->stackService->expects($this->once())
->method('find')
@@ -96,12 +96,12 @@ class StackApiControllerTest extends \Test\TestCase {
$this->request->expects($this->once())
->method('getParam')
->with('stackId')
->willReturn($this->exampleStack['id']);
->willReturn($this->exampleStack['id']);
$expected = new DataResponse($stack, HTTP::STATUS_OK);
$actual = $this->controller->get();
$this->assertEquals($expected, $actual);
}
}
public function testCreate() {
@@ -126,8 +126,8 @@ class StackApiControllerTest extends \Test\TestCase {
}
public function testUpdate() {
$this->request->expects($this->exactly(2))
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['stackId'],
@@ -171,4 +171,4 @@ class StackApiControllerTest extends \Test\TestCase {
$actual = $this->controller->delete();
$this->assertEquals($expected, $actual);
}
}
}

View File

@@ -41,7 +41,7 @@ class StackControllerTest extends \Test\TestCase {
/** @var string */
private $userId = 'user';
public function setUp() {
public function setUp(): void {
$this->request = $this->getMockBuilder(
'\OCP\IRequest')
->disableOriginalConstructor()