From c2e97a952de7f961a8f10934bcaeff785b126fc6 Mon Sep 17 00:00:00 2001 From: miladev-ent Date: Sat, 13 May 2023 15:58:45 +0330 Subject: [PATCH 1/3] add `castAsJson` to Database --- src/Database.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Database.php b/src/Database.php index f0be69a..d7549e2 100644 --- a/src/Database.php +++ b/src/Database.php @@ -127,3 +127,13 @@ function expectsDatabaseQueryCount(int $excepted, string|null $connection = null { return test()->expectsDatabaseQueryCount(...func_get_args()); } + +/** + *Cast a JSON string to a database compatible type. + * + * @return TestCase + */ +function castAsJson($value) +{ + return test()->castAsJson($value); +} From bd552989bc2d41fc7ab12a5ef22e38d449aba494 Mon Sep 17 00:00:00 2001 From: miladev-ent Date: Sat, 20 May 2023 14:39:06 +0330 Subject: [PATCH 2/3] add missing space for castAsJson --- src/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database.php b/src/Database.php index d7549e2..fe0e3bd 100644 --- a/src/Database.php +++ b/src/Database.php @@ -129,7 +129,7 @@ function expectsDatabaseQueryCount(int $excepted, string|null $connection = null } /** - *Cast a JSON string to a database compatible type. + * Cast a JSON string to a database compatible type. * * @return TestCase */ From 2ee00bd89368ca25f77eda161d0c56877f38ee4e Mon Sep 17 00:00:00 2001 From: miladev-ent Date: Sat, 20 May 2023 14:39:21 +0330 Subject: [PATCH 3/3] add type hint for `value` param in castAsJson --- src/Database.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database.php b/src/Database.php index fe0e3bd..01ed8aa 100644 --- a/src/Database.php +++ b/src/Database.php @@ -133,7 +133,7 @@ function expectsDatabaseQueryCount(int $excepted, string|null $connection = null * * @return TestCase */ -function castAsJson($value) +function castAsJson(array|object|string $value) { return test()->castAsJson($value); }