Skip to content

Commit

Permalink
MBS-8974: Unit test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-csg committed Dec 16, 2024
1 parent 6311c8b commit 407902d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion classes/boardmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ public function set_card_complete(int $cardid, int $state): void {
$assignees = $this->get_card_assignees($cardid);
if ($state) {
helper::remove_calendar_event($this->kanban, $card, $assignees);
if ($card->repeat_enable) {
if (!empty($card->repeat_enable)) {
$newcard = clone $card;
if ($card->repeat_newduedate == constants::MOD_KANBAN_REPEAT_NONEWDUEDATE) {
$newcard->duedate = 0;
Expand Down
1 change: 0 additions & 1 deletion classes/external/change_kanban_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ public static function move_card_returns(): external_single_structure {
* @throws moodle_exception
*/
public static function move_card(int $cmid, int $boardid, array $data): array {
global $USER;
$params = self::validate_parameters(self::move_card_parameters(), [
'cmid' => $cmid,
'boardid' => $boardid,
Expand Down
8 changes: 6 additions & 2 deletions tests/change_kanban_content_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,12 @@ public function test_move_card(): void {

$update = json_decode($returnvalue['update'], true);

$this->assertCount(3, $update);
// As the target column has autoclose enabled by default, we get two updates for cards.
$this->assertCount(4, $update);
$this->assertEquals('cards', $update[0]['name']);
$this->assertEquals('columns', $update[1]['name']);
$this->assertEquals('columns', $update[2]['name']);
$this->assertEquals('cards', $update[3]['name']);

$this->assertEquals(join(',', [$cards[0]->id, $cards[2]->id]), $update[2]['fields']['sequence']);
$this->assertEquals('', $update[1]['fields']['sequence']);
Expand Down Expand Up @@ -301,10 +303,12 @@ public function test_move_card(): void {

$update = json_decode($returnvalue['update'], true);

$this->assertCount(3, $update);
// As the target column has autoclose enabled by default, we get two updates for cards.
$this->assertCount(4, $update);
$this->assertEquals('cards', $update[0]['name']);
$this->assertEquals('columns', $update[1]['name']);
$this->assertEquals('columns', $update[2]['name']);
$this->assertEquals('cards', $update[3]['name']);

$this->assertEquals(join(',', [$cards[2]->id, $cards[1]->id, $cards[0]->id]), $update[2]['fields']['sequence']);
$this->assertEquals('', $update[1]['fields']['sequence']);
Expand Down

0 comments on commit 407902d

Please sign in to comment.