Refactor update to have proper order of optional parameters
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -95,7 +95,7 @@ class CardApiController extends ApiController {
|
|||||||
* Update a card
|
* Update a card
|
||||||
*/
|
*/
|
||||||
public function update($title, $type, $order = 0, $description = '', $owner, $duedate = null, $archived = null) {
|
public function update($title, $type, $order = 0, $description = '', $owner, $duedate = null, $archived = null) {
|
||||||
$card = $this->cardService->update($this->request->getParam('cardId'), $title, $this->request->getParam('stackId'), $type, $order, $description, $owner, $duedate, 0, $archived);
|
$card = $this->cardService->update($this->request->getParam('cardId'), $title, $this->request->getParam('stackId'), $type, $owner, $description, $order, $duedate, 0, $archived);
|
||||||
return new DataResponse($card, HTTP::STATUS_OK);
|
return new DataResponse($card, HTTP::STATUS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class CardController extends Controller {
|
|||||||
* @return \OCP\AppFramework\Db\Entity
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
*/
|
*/
|
||||||
public function update($id, $title, $stackId, $type, $order, $description, $duedate, $deletedAt) {
|
public function update($id, $title, $stackId, $type, $order, $description, $duedate, $deletedAt) {
|
||||||
return $this->cardService->update($id, $title, $stackId, $type, $order, $description, $this->userId, $duedate, $deletedAt);
|
return $this->cardService->update($id, $title, $stackId, $type, $this->userId, $description, $order, $duedate, $deletedAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -257,9 +257,9 @@ class CardService {
|
|||||||
* @param $title
|
* @param $title
|
||||||
* @param $stackId
|
* @param $stackId
|
||||||
* @param $type
|
* @param $type
|
||||||
* @param $order
|
|
||||||
* @param $description
|
|
||||||
* @param $owner
|
* @param $owner
|
||||||
|
* @param $description
|
||||||
|
* @param $order
|
||||||
* @param $duedate
|
* @param $duedate
|
||||||
* @return \OCP\AppFramework\Db\Entity
|
* @return \OCP\AppFramework\Db\Entity
|
||||||
* @throws StatusException
|
* @throws StatusException
|
||||||
@@ -268,7 +268,7 @@ class CardService {
|
|||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||||
* @throws BadRequestException
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public function update($id, $title, $stackId, $type, $order = 0, $description = '', $owner, $duedate = null, $deletedAt = null, $archived = null) {
|
public function update($id, $title, $stackId, $type, $owner, $description = '', $order = 0, $duedate = null, $deletedAt = null, $archived = null) {
|
||||||
if (is_numeric($id) === false) {
|
if (is_numeric($id) === false) {
|
||||||
throw new BadRequestException('card id must be a number');
|
throw new BadRequestException('card id must be a number');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<files psalm-version="4.7.0@d4377c0baf3ffbf0b1ec6998e8d1be2a40971005">
|
<files psalm-version="4.7.2@83a0325c0a95c0ab531d6b90c877068b464377b5">
|
||||||
<file src="lib/Activity/ActivityManager.php">
|
<file src="lib/Activity/ActivityManager.php">
|
||||||
<TypeDoesNotContainType occurrences="1">
|
<TypeDoesNotContainType occurrences="1">
|
||||||
<code>$message !== null</code>
|
<code>$message !== null</code>
|
||||||
@@ -197,9 +197,6 @@
|
|||||||
</TooManyArguments>
|
</TooManyArguments>
|
||||||
</file>
|
</file>
|
||||||
<file src="lib/Service/CardService.php">
|
<file src="lib/Service/CardService.php">
|
||||||
<TooFewArguments occurrences="1">
|
|
||||||
<code>findAssignedCards</code>
|
|
||||||
</TooFewArguments>
|
|
||||||
<UndefinedDocblockClass occurrences="1">
|
<UndefinedDocblockClass occurrences="1">
|
||||||
<code>\OCP\AppFramework\Db\</code>
|
<code>\OCP\AppFramework\Db\</code>
|
||||||
</UndefinedDocblockClass>
|
</UndefinedDocblockClass>
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ class CardServiceTest extends TestCase {
|
|||||||
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function ($c) {
|
$this->cardMapper->expects($this->once())->method('update')->willReturnCallback(function ($c) {
|
||||||
return $c;
|
return $c;
|
||||||
});
|
});
|
||||||
$actual = $this->cardService->update(123, 'newtitle', 234, 'text', 999, 'foo', 'admin', '2017-01-01 00:00:00', null);
|
$actual = $this->cardService->update(123, 'newtitle', 234, 'text', 'admin', 'foo', 999, '2017-01-01 00:00:00', null);
|
||||||
$this->assertEquals('newtitle', $actual->getTitle());
|
$this->assertEquals('newtitle', $actual->getTitle());
|
||||||
$this->assertEquals(234, $actual->getStackId());
|
$this->assertEquals(234, $actual->getStackId());
|
||||||
$this->assertEquals('text', $actual->getType());
|
$this->assertEquals('text', $actual->getType());
|
||||||
@@ -212,7 +212,7 @@ class CardServiceTest extends TestCase {
|
|||||||
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
$this->cardMapper->expects($this->once())->method('find')->willReturn($card);
|
||||||
$this->cardMapper->expects($this->never())->method('update');
|
$this->cardMapper->expects($this->never())->method('update');
|
||||||
$this->expectException(StatusException::class);
|
$this->expectException(StatusException::class);
|
||||||
$this->cardService->update(123, 'newtitle', 234, 'text', 999, 'foo', 'admin', '2017-01-01 00:00:00', null, true);
|
$this->cardService->update(123, 'newtitle', 234, 'text', 'admin', 'foo', 999, '2017-01-01 00:00:00', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRename() {
|
public function testRename() {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class CardControllerTest extends TestCase {
|
|||||||
public function testUpdate() {
|
public function testUpdate() {
|
||||||
$this->cardService->expects($this->once())
|
$this->cardService->expects($this->once())
|
||||||
->method('update')
|
->method('update')
|
||||||
->with(1, 'title', 3, 'text', 5, 'foo', $this->userId, '2017-01-01 00:00:00')
|
->with(1, 'title', 3, 'text', $this->userId, 'foo', 5, '2017-01-01 00:00:00')
|
||||||
->willReturn(1);
|
->willReturn(1);
|
||||||
$this->assertEquals(1, $this->controller->update(1, 'title', 3, 'text', 5, 'foo', '2017-01-01 00:00:00', null));
|
$this->assertEquals(1, $this->controller->update(1, 'title', 3, 'text', 5, 'foo', '2017-01-01 00:00:00', null));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user