Added BadRequestException checks in DefaultBoardService. Fixed bug in DefaultBoardService BadRequestException checks.
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
committed by
Julius Härtl
parent
6f5c0a2816
commit
aba7d02cfe
@@ -446,15 +446,15 @@ class BoardService {
|
|||||||
throw new BadRequestException('id must be a number');
|
throw new BadRequestException('id must be a number');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($edit === false || $edit === null) {
|
if ($edit === null) {
|
||||||
throw new BadRequestException('edit must be provided');
|
throw new BadRequestException('edit must be provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($share === false || $share === null) {
|
if ($share === null) {
|
||||||
throw new BadRequestException('share must be provided');
|
throw new BadRequestException('share must be provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($manage === false || $manage === null) {
|
if ($manage === null) {
|
||||||
throw new BadRequestException('manage must be provided');
|
throw new BadRequestException('manage must be provided');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ use OCA\Deck\Service\StackService;
|
|||||||
use OCA\Deck\Service\CardService;
|
use OCA\Deck\Service\CardService;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
|
use OCA\Deck\BadRequestException;
|
||||||
|
|
||||||
class DefaultBoardService {
|
class DefaultBoardService {
|
||||||
|
|
||||||
@@ -83,8 +84,22 @@ class DefaultBoardService {
|
|||||||
* @throws \OCA\Deck\StatusException
|
* @throws \OCA\Deck\StatusException
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
* @throws \OCP\AppFramework\Db\DoesNotExistException
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public function createDefaultBoard($title, $userId, $color) {
|
public function createDefaultBoard($title, $userId, $color) {
|
||||||
|
|
||||||
|
if ($title === false || $title === null) {
|
||||||
|
throw new BadRequestException('title must be provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($userId === false || $userId == null) {
|
||||||
|
throw new BadRequestException('userId must be provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($color === false || $color === null) {
|
||||||
|
throw new BadRequestException('color must be provided');
|
||||||
|
}
|
||||||
|
|
||||||
$defaultBoard = $this->boardService->create($title, $userId, $color);
|
$defaultBoard = $this->boardService->create($title, $userId, $color);
|
||||||
$defaultStacks = [];
|
$defaultStacks = [];
|
||||||
$defaultCards = [];
|
$defaultCards = [];
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class DefaultBoardServiceTest extends TestCase {
|
|||||||
$this->cardService = $this->createMock(CardService::class);
|
$this->cardService = $this->createMock(CardService::class);
|
||||||
$this->config = $this->createMock(IConfig::class);
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->l10n = $this->createMock(IL10N::class);
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
|
$this->userId = 'admin';
|
||||||
|
|
||||||
$this->service = new DefaultBoardService(
|
$this->service = new DefaultBoardService(
|
||||||
$this->l10n,
|
$this->l10n,
|
||||||
|
|||||||
Reference in New Issue
Block a user