From f3854427fe59b751855768ff02f8366728b20b36 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 13 Nov 2022 09:28:51 +0900 Subject: [PATCH 1/8] docs: fix @param --- tests/system/Models/DeleteModelTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index ed8f9c620856..b2c03e7dd0f0 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -167,7 +167,7 @@ public function testDontThrowExceptionWhenSoftDeleteConditionIsSetWithEmptyValue /** * @dataProvider emptyPkValues * - * @param mixed $emptyValue + * @param int|string|null $emptyValue */ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): void { @@ -181,7 +181,7 @@ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): /** * @dataProvider emptyPkValues * - * @param mixed $emptyValue + * @param int|string|null $emptyValue */ public function testDontDeleteRowsWhenSoftDeleteParamIsEmpty($emptyValue): void { From 7c1c0041943664043bf7904ef6279dab7286ba1c Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 13 Nov 2022 09:29:31 +0900 Subject: [PATCH 2/8] docs: fix typo --- system/Database/BaseBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 3433de491fa6..4941ba78a739 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -2111,7 +2111,7 @@ protected function _update(string $table, array $values): string /** * This method is used by both update() and getCompiledUpdate() to * validate that data is actually being set and that a table has been - * chosen to be update. + * chosen to be updated. * * @throws DatabaseException */ From 3b7607a5d4e96dd57f91aba407d556a03412cf91 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 13 Nov 2022 09:29:54 +0900 Subject: [PATCH 3/8] style: add empty line --- tests/system/Models/DeleteModelTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index b2c03e7dd0f0..1c6006e4315b 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -175,6 +175,7 @@ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): $this->expectExceptionMessage('Deletes are not allowed unless they contain a "where" or "like" clause.'); $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); + $this->createModel(UserModel::class)->delete($emptyValue); } From c3981bdb5a2f6626a6bfa1be62384703ec4ce367 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 13 Nov 2022 09:30:15 +0900 Subject: [PATCH 4/8] test: fix broken test --- tests/system/Models/DeleteModelTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index 1c6006e4315b..ce84caffce5c 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -186,12 +186,14 @@ public function testThrowExceptionWhenSoftDeleteParamIsEmptyValue($emptyValue): */ public function testDontDeleteRowsWhenSoftDeleteParamIsEmpty($emptyValue): void { - $this->expectException(DatabaseException::class); - $this->expectExceptionMessage('Deletes are not allowed unless they contain a "where" or "like" clause.'); - $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); - $this->createModel(UserModel::class)->delete($emptyValue); + try { + $this->createModel(UserModel::class)->delete($emptyValue); + } catch (DatabaseException $e) { + // Do nothing. + } + $this->seeInDatabase('user', ['name' => 'Derek Jones', 'deleted_at IS NULL' => null]); } From 6876a77bc6fb1aac4d0442d89010d1472344b33f Mon Sep 17 00:00:00 2001 From: kenjis Date: Sun, 13 Nov 2022 09:33:48 +0900 Subject: [PATCH 5/8] test: add test case and fix typos in comment --- tests/system/Models/DeleteModelTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index ce84caffce5c..e1c13f407fa3 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -148,8 +148,8 @@ public function testOnlyDeleted(): void } /** - * If where condition is set, beyond the value was empty (0,'', NULL, etc.), - * Exception should not be thrown because condition was explicity set + * If where condition is set, beyond the value was empty (0, '', NULL, etc.), + * Exception should not be thrown because condition was explicitly set * * @dataProvider emptyPkValues * @@ -203,6 +203,7 @@ public static function emptyPkValues(): iterable [0], [null], ['0'], + [''], ]; } From 4827697dcd725ddf675fbd1178f3b917f39dd051 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 16 Nov 2022 15:17:37 +0900 Subject: [PATCH 6/8] test: fix comment and remove failed test case '' fails on Postgres. --- tests/system/Models/DeleteModelTest.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index e1c13f407fa3..7d8f8e21505b 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -148,8 +148,8 @@ public function testOnlyDeleted(): void } /** - * If where condition is set, beyond the value was empty (0, '', NULL, etc.), - * Exception should not be thrown because condition was explicitly set + * If where condition is set, even if the value is empty (0, NULL, etc.), + * Exception should not be thrown because condition is explicitly set. * * @dataProvider emptyPkValues * @@ -203,7 +203,6 @@ public static function emptyPkValues(): iterable [0], [null], ['0'], - [''], ]; } From 67c51091c3712f3741aa91e490ec0e709081ce53 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 16 Nov 2022 15:18:48 +0900 Subject: [PATCH 7/8] test: fix @param type --- tests/system/Models/DeleteModelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index 7d8f8e21505b..d5f3e74843f9 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -153,7 +153,7 @@ public function testOnlyDeleted(): void * * @dataProvider emptyPkValues * - * @param mixed $emptyValue + * @param int|string|null $emptyValue */ public function testDontThrowExceptionWhenSoftDeleteConditionIsSetWithEmptyValue($emptyValue): void { From 83b9f4a1b6cf3844d94f11d88c641a15b3ca92c5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 16 Nov 2022 20:43:10 +0900 Subject: [PATCH 8/8] docs: improve comment Co-authored-by: MGatner --- tests/system/Models/DeleteModelTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/system/Models/DeleteModelTest.php b/tests/system/Models/DeleteModelTest.php index d5f3e74843f9..82ffcf20bf34 100644 --- a/tests/system/Models/DeleteModelTest.php +++ b/tests/system/Models/DeleteModelTest.php @@ -148,8 +148,9 @@ public function testOnlyDeleted(): void } /** - * If where condition is set, even if the value is empty (0, NULL, etc.), - * Exception should not be thrown because condition is explicitly set. + * Given an explicit empty value in the WHERE condition + * When executing a soft delete + * Then an exception should not be thrown * * @dataProvider emptyPkValues *