Fix php cs issues

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-04-22 19:57:19 +02:00
parent 7ad5daabeb
commit 52febb396c
130 changed files with 1068 additions and 1424 deletions

View File

@@ -30,143 +30,139 @@ use OCA\Deck\Service\AttachmentService;
use OCA\Deck\Db\Attachment;
class AttachmentApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $controller;
private $request;
private $attachmentExample;
private $cardId;
private $attachmentService;
private $appName = 'deck';
private $controller;
private $request;
private $attachmentExample;
private $cardId;
private $attachmentService;
public function setUp(): void {
parent::setUp();
$this->attachmentExample = new Attachment();
$this->attachmentExample->setId(1);
$this->cardId = 1;
$this->request = $this->createMock(IRequest::class);
$this->attachmentService = $this->createMock(AttachmentService::class);
$this->controller = new AttachmentApiController(
$this->appName,
$this->request,
$this->attachmentService
);
}
public function setUp(): void {
parent::setUp();
$this->attachmentExample = new Attachment();
$this->attachmentExample->setId(1);
$this->cardId = 1;
$this->request = $this->createMock(IRequest::class);
$this->attachmentService = $this->createMock(AttachmentService::class);
$this->controller = new AttachmentApiController(
$this->appName,
$this->request,
$this->attachmentService
);
}
public function testGetAll() {
$allAttachments = [$this->attachmentExample];
public function testGetAll() {
$this->attachmentService->expects($this->once())
->method('findAll')
->willReturn($allAttachments);
$allAttachments = [$this->attachmentExample];
$this->request->expects($this->once())
->method('getParam')
->with('cardId')
->willReturn($allAttachments);
$this->attachmentService->expects($this->once())
->method('findAll')
->willReturn($allAttachments);
$expected = new DataResponse($allAttachments, HTTP::STATUS_OK);
$actual = $this->controller->getAll();
$this->assertEquals($expected, $actual);
}
$this->request->expects($this->once())
->method('getParam')
->with('cardId')
->willReturn($allAttachments);
public function testDisplay() {
$this->attachmentService->expects($this->once())
->method('display')
->willReturn($this->attachmentExample);
$expected = new DataResponse($allAttachments, HTTP::STATUS_OK);
$actual = $this->controller->getAll();
$this->assertEquals($expected, $actual);
}
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
public function testDisplay() {
$expected = $this->attachmentExample;
$actual = $this->controller->display();
$this->assertEquals($expected, $actual);
}
$this->attachmentService->expects($this->once())
->method('display')
->willReturn($this->attachmentExample);
public function testCreate() {
$type = 'not null';
$data = ['not null'];
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
$this->attachmentService->expects($this->once())
->method('create')
->willReturn($this->attachmentExample);
$expected = $this->attachmentExample;
$actual = $this->controller->display();
$this->assertEquals($expected, $actual);
}
$this->request->expects($this->once())
->method('getParam')
->with('cardId')
->willReturn($this->cardId);
public function testCreate() {
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->create($type, $data);
$this->assertEquals($expected, $actual);
}
$type = 'not null';
$data = ['not null'];
public function testUpdate() {
$this->attachmentService->expects($this->once())
->method('create')
->willReturn($this->attachmentExample);
// FIXME: what is data supposed to be in this context?
$data = ['not empty data'];
$this->request->expects($this->once())
->method('getParam')
->with('cardId')
->willReturn($this->cardId);
$this->attachmentService->expects($this->once())
->method('update')
->willReturn($this->attachmentExample);
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->create($type, $data);
$this->assertEquals($expected, $actual);
}
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
public function testUpdate() {
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->update($data);
$this->assertEquals($expected, $actual);
}
// FIXME: what is data supposed to be in this context?
$data = ['not empty data'];
public function testDelete() {
$this->attachmentService->expects($this->once())
->method('delete')
->willReturn($this->attachmentExample);
$this->attachmentService->expects($this->once())
->method('update')
->willReturn($this->attachmentExample);
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->delete();
$this->assertEquals($expected, $actual);
}
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->update($data);
$this->assertEquals($expected, $actual);
}
public function testRestore() {
$this->attachmentService->expects($this->once())
->method('restore')
->willReturn($this->attachmentExample);
public function testDelete() {
$this->attachmentService->expects($this->once())
->method('delete')
->willReturn($this->attachmentExample);
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->delete();
$this->assertEquals($expected, $actual);
}
public function testRestore() {
$this->attachmentService->expects($this->once())
->method('restore')
->willReturn($this->attachmentExample);
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
['cardId'],
['attachmentId']
)->willReturnonConsecutiveCalls(
$this->cardId,
$this->attachmentExample->getId());
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->restore();
$this->assertEquals($expected, $actual);
}
$expected = new DataResponse($this->attachmentExample, HTTP::STATUS_OK);
$actual = $this->controller->restore();
$this->assertEquals($expected, $actual);
}
}

View File

@@ -23,21 +23,17 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Db\Acl;
use OCA\Deck\Service\AttachmentService;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\LabelService;
use OCA\Deck\Service\StackService;
use OCP\AppFramework\Controller;
use OCP\IRequest;
class AttachmentControllerTest extends \Test\TestCase {
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
private $controller;
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var AttachmentService|\PHPUnit\Framework\MockObject\MockObject */
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var AttachmentService|\PHPUnit\Framework\MockObject\MockObject */
private $attachmentService;
/** @var string */
private $userId = 'user';
@@ -49,19 +45,19 @@ class AttachmentControllerTest extends \Test\TestCase {
'deck',
$this->request,
$this->attachmentService,
$this->userId
);
$this->userId
);
}
public function testGetAll() {
$this->attachmentService->expects($this->once())->method('findAll')->with(1);
$this->controller->getAll(1);
}
public function testGetAll() {
$this->attachmentService->expects($this->once())->method('findAll')->with(1);
$this->controller->getAll(1);
}
public function testDisplay() {
$this->attachmentService->expects($this->once())->method('display')->with(1, 2);
$this->controller->display(1, 2);
}
public function testDisplay() {
$this->attachmentService->expects($this->once())->method('display')->with(1, 2);
$this->controller->display(1, 2);
}
public function testCreate() {
$this->request->expects($this->exactly(2))
@@ -101,5 +97,4 @@ class AttachmentControllerTest extends \Test\TestCase {
->willReturn(1);
$this->assertEquals(1, $this->controller->restore(123, 234));
}
}

View File

@@ -30,7 +30,6 @@ use OCA\Deck\Service\BoardService;
use OCA\Deck\Db\Board;
class BoardApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $userId = 'admin';
private $controller;

View File

@@ -27,7 +27,6 @@ use OCA\Deck\Db\Acl;
use OCP\IUser;
class BoardControllerTest extends \Test\TestCase {
private $controller;
private $request;
private $userManager;

View File

@@ -31,7 +31,6 @@ use OCA\Deck\Db\Card;
use OCA\Deck\Service\CardService;
class CardApiControllerTest extends \Test\TestCase {
private $controller;
private $request;
private $cardService;
@@ -50,7 +49,7 @@ class CardApiControllerTest extends \Test\TestCase {
$this->cardExample['id'] = 1;
$this->stackExample['id'] = 1;
$this->controller = new CardApiController (
$this->controller = new CardApiController(
$appName = 'deck',
$this->request,
$this->cardService,
@@ -78,7 +77,6 @@ class CardApiControllerTest extends \Test\TestCase {
}
public function testCreate() {
$card = new Card();
$card->setId($this->cardExample['id']);
$card->setStackId($this->stackExample['id']);
@@ -121,7 +119,6 @@ class CardApiControllerTest extends \Test\TestCase {
}
public function testDelete() {
$card = new Card();
$card->setId($this->cardExample['id']);
@@ -138,5 +135,4 @@ class CardApiControllerTest extends \Test\TestCase {
$actual = $this->controller->delete();
$this->assertEquals($expected, $actual);
}
}

View File

@@ -31,11 +31,11 @@ use Test\TestCase;
class CardControllerTest extends TestCase {
/** @var CardController|MockObject */
/** @var CardController|MockObject */
private $controller;
/** @var IRequest|MockObject */
private $request;
/** @var CardService|MockObject */
/** @var IRequest|MockObject */
private $request;
/** @var CardService|MockObject */
private $cardService;
/** @var AssignmentService|MockObject */
private $assignmentService;
@@ -89,31 +89,31 @@ class CardControllerTest extends TestCase {
}
public function testArchive() {
$this->cardService->expects($this->once())->method('archive')->willReturn(true);
$this->controller->archive(1);
}
public function testUnarchive() {
$this->cardService->expects($this->once())->method('unarchive');
$this->controller->unarchive(1);
}
public function testAssignLabel() {
$this->cardService->expects($this->once())->method('assignLabel');
$this->controller->assignLabel(1,2);
}
public function testRemoveLabel() {
$this->cardService->expects($this->once())->method('removeLabel');
$this->controller->removeLabel(1,2);
}
$this->cardService->expects($this->once())->method('archive')->willReturn(true);
$this->controller->archive(1);
}
public function testUnarchive() {
$this->cardService->expects($this->once())->method('unarchive');
$this->controller->unarchive(1);
}
public function testAssignLabel() {
$this->cardService->expects($this->once())->method('assignLabel');
$this->controller->assignLabel(1,2);
}
public function testRemoveLabel() {
$this->cardService->expects($this->once())->method('removeLabel');
$this->controller->removeLabel(1,2);
}
public function testReorder() {
$this->cardService->expects($this->once())->method('reorder');
$this->controller->reorder(1, 2, 3);
}
public function testReorder() {
$this->cardService->expects($this->once())->method('reorder');
$this->controller->reorder(1, 2, 3);
}
public function testRename() {
$this->cardService->expects($this->once())->method('rename');
$this->controller->rename(1, 'test');
}
public function testRename() {
$this->cardService->expects($this->once())->method('rename');
$this->controller->rename(1, 'test');
}
public function testAssignUser() {
$this->assignmentService->expects($this->once())->method('assignUser');
@@ -124,5 +124,4 @@ class CardControllerTest extends TestCase {
$this->assignmentService->expects($this->once())->method('unassignUser');
$this->controller->unassignUser(1, 'admin');
}
}

View File

@@ -30,7 +30,6 @@ use OCA\Deck\Db\Label;
use OCA\Deck\Service\LabelService;
class LabelApiControllerTest extends \Test\TestCase {
private $controller;
private $request;
private $labelService;
@@ -69,7 +68,6 @@ class LabelApiControllerTest extends \Test\TestCase {
}
public function testCreate() {
$label = new Label();
$label->setId($this->exampleLabel['id']);
@@ -88,7 +86,6 @@ class LabelApiControllerTest extends \Test\TestCase {
}
public function testUpdate() {
$label = new Label();
$label->setId($this->exampleLabel['id']);
@@ -107,7 +104,6 @@ class LabelApiControllerTest extends \Test\TestCase {
}
public function testDelete() {
$label = new Label();
$label->setId($this->exampleLabel['id']);
@@ -124,5 +120,4 @@ class LabelApiControllerTest extends \Test\TestCase {
$actual = $this->controller->delete();
$this->assertEquals($expected, $actual);
}
}

View File

@@ -23,19 +23,17 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Db\Acl;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\LabelService;
use OCP\AppFramework\Controller;
use OCP\IRequest;
class LabelControllerTest extends \Test\TestCase {
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
private $controller;
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var LabelService|\PHPUnit\Framework\MockObject\MockObject */
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var LabelService|\PHPUnit\Framework\MockObject\MockObject */
private $labelService;
/** @var string */
private $userId = 'user';
@@ -53,7 +51,7 @@ class LabelControllerTest extends \Test\TestCase {
'deck',
$this->request,
$this->labelService
);
);
}
@@ -80,5 +78,4 @@ class LabelControllerTest extends \Test\TestCase {
->willReturn(1);
$this->assertEquals(1, $this->controller->delete(123));
}
}

View File

@@ -28,13 +28,10 @@ use OCA\Deck\Service\PermissionService;
use OCP\IInitialStateService;
use OCP\IL10N;
use OCP\IRequest;
use PHPUnit_Framework_TestCase;
use OCA\Deck\Service\DefaultBoardService;
use OCA\Deck\Db\Board;
use OCP\IConfig;
class PageControllerTest extends \Test\TestCase {
private $controller;
private $request;
private $l10n;
@@ -56,7 +53,6 @@ class PageControllerTest extends \Test\TestCase {
}
public function testIndex() {
$board = new Board();
$board->setTitle('Personal');
$board->setOwner($this->userId);
@@ -69,5 +65,4 @@ class PageControllerTest extends \Test\TestCase {
$response = $this->controller->index();
$this->assertEquals('main', $response->getTemplateName());
}
}

View File

@@ -28,11 +28,9 @@ use OCP\IRequest;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\StackService;
use OCA\Deck\Db\Board;
use OCA\Deck\Db\Stack;
class StackApiControllerTest extends \Test\TestCase {
private $appName = 'deck';
private $userId = 'admin';
private $controller;
@@ -104,7 +102,6 @@ class StackApiControllerTest extends \Test\TestCase {
}
public function testCreate() {
$this->request->expects($this->any())
->method('getParam')
->with('boardId')
@@ -126,7 +123,6 @@ class StackApiControllerTest extends \Test\TestCase {
}
public function testUpdate() {
$this->request->expects($this->exactly(2))
->method('getParam')
->withConsecutive(
@@ -151,7 +147,6 @@ class StackApiControllerTest extends \Test\TestCase {
}
public function testDelete() {
$stack = new Stack();
$stack->setId($this->exampleStack['id']);
$stack->setBoardId($this->exampleStack['boardId']);

View File

@@ -23,20 +23,17 @@
namespace OCA\Deck\Controller;
use OCA\Deck\Db\Acl;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\LabelService;
use OCA\Deck\Service\StackService;
use OCP\AppFramework\Controller;
use OCP\IRequest;
class StackControllerTest extends \Test\TestCase {
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
private $controller;
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var StackService|\PHPUnit\Framework\MockObject\MockObject */
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
private $request;
/** @var StackService|\PHPUnit\Framework\MockObject\MockObject */
private $stackService;
/** @var string */
private $userId = 'user';
@@ -54,19 +51,19 @@ class StackControllerTest extends \Test\TestCase {
'deck',
$this->request,
$this->stackService,
$this->userId
);
$this->userId
);
}
public function testIndex() {
$this->stackService->expects($this->once())->method('findAll');
$this->controller->index(1);
}
public function testIndex() {
$this->stackService->expects($this->once())->method('findAll');
$this->controller->index(1);
}
public function testArchived() {
$this->stackService->expects($this->once())->method('findAllArchived');
$this->controller->archived(1);
}
public function testArchived() {
$this->stackService->expects($this->once())->method('findAllArchived');
$this->controller->archived(1);
}
public function testCreate() {
$this->stackService->expects($this->once())
@@ -99,5 +96,4 @@ class StackControllerTest extends \Test\TestCase {
->willReturn(1);
$this->assertEquals(1, $this->controller->delete(123));
}
}