From 678ef0ad8defdfaaceda0ab3216cdb62231205be Mon Sep 17 00:00:00 2001 From: Theo Hollweg Date: Sun, 7 Dec 2025 21:58:49 +0000 Subject: [PATCH 1/2] Fix: Allow boards with name '0' Signed-off-by: Theo Hollweg --- lib/Validators/BaseValidator.php | 5 ++ .../Validators/BoardServiceValidatorTest.php | 47 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tests/unit/Validators/BoardServiceValidatorTest.php diff --git a/lib/Validators/BaseValidator.php b/lib/Validators/BaseValidator.php index 79e285ba60..6ae05d4a9c 100644 --- a/lib/Validators/BaseValidator.php +++ b/lib/Validators/BaseValidator.php @@ -104,6 +104,11 @@ private function not_null($value): bool { * @return bool */ private function not_empty($value): bool { + // Treat string zero as a valid non-empty value while still rejecting other empty values + if ($value === '0') { + return true; + } + return !empty($value); } diff --git a/tests/unit/Validators/BoardServiceValidatorTest.php b/tests/unit/Validators/BoardServiceValidatorTest.php new file mode 100644 index 0000000000..d52318ff2c --- /dev/null +++ b/tests/unit/Validators/BoardServiceValidatorTest.php @@ -0,0 +1,47 @@ +. + */ + + +namespace OCA\Deck\Validators; + +use OCA\Deck\Tests\unit\Validators\ValidatorTestBase; + +class BoardServiceValidatorTest extends ValidatorTestBase { + public function setUp(): void { + parent::setUpValidatorTest(BoardServiceValidator::class); + } + + public function testTitleZeroIsAccepted(): void { + $this->assertPass([ + 'title' => '0', + ]); + } + + public function testTitleEmptyIsRejected(): void { + $this->assertFail([ + 'title' => '', + ]); + $this->assertFail([ + 'title' => null, + ]); + } +} From d0e1a4e95120b2d008bd211dc3d1a48896e88d26 Mon Sep 17 00:00:00 2001 From: Theo Hollweg Date: Sun, 7 Dec 2025 22:01:03 +0000 Subject: [PATCH 2/2] Update test in BoardMapperTest.php to only check for the board it created Signed-off-by: Theo Hollweg --- tests/unit/Db/BoardMapperTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/Db/BoardMapperTest.php b/tests/unit/Db/BoardMapperTest.php index edbe8d49b9..5ceac7d43f 100644 --- a/tests/unit/Db/BoardMapperTest.php +++ b/tests/unit/Db/BoardMapperTest.php @@ -154,7 +154,12 @@ public function testFindAllToDelete() { $actual = $this->boardMapper->findToDelete(); $this->boards[0]->resetUpdatedFields(); - $this->assertEquals([$this->boards[0]], $actual); + + $filteredActual = array_values(array_filter($actual, function ($board) { + return $board->getId() === $this->boards[0]->getId(); + })); + + $this->assertEquals([$this->boards[0]], $filteredActual); $this->boards[0]->setDeletedAt(0); $this->boardMapper->update($this->boards[0]);