From ecfbeb48a4fc06c97d9457d910ddd0b3a7d14e67 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Tue, 29 Oct 2024 18:06:02 +0300 Subject: [PATCH 1/2] test with uuid --- tests/CheckTypeTest.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/CheckTypeTest.php b/tests/CheckTypeTest.php index 9dae4781..3ae4dafe 100644 --- a/tests/CheckTypeTest.php +++ b/tests/CheckTypeTest.php @@ -206,3 +206,37 @@ public function testCheckTypesInDeclare(){ } } + +class CheckUUIDTest extends TestCase{ + public function testCheckTypesInDeclare(){ + $config = [ + + // Database path + 'database' => '/local', + + // Database endpoint + 'endpoint' => 'localhost:2136', + + // Auto discovery (dedicated server only) + 'discovery' => false, + + // IAM config + 'iam_config' => [ + 'insecure' => true, + ], + + 'credentials' => new AnonymousAuthentication() + ]; + + $ydb = new Ydb($config); + $table = $ydb->table(); + $session = $table->createSession(); + + $query = "DECLARE \$v as Utf8; SELECT CAST(\$v AS UUID) as val;"; + $prepared = $session->prepare($query); + $result = $prepared->execute([ + 'v' => "6E73B41C-4EDE-4D08-9CFB-B7462D9E498B", + ]); + self::assertEquals("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B", $result->rows()[0]["val"]); + } +} From 8cc182aafc34836040b71c07e34d93b193d31452 Mon Sep 17 00:00:00 2001 From: Timofey Koolin Date: Tue, 29 Oct 2024 19:16:18 +0300 Subject: [PATCH 2/2] extract uuid test to own file --- tests/CheckTypeTest.php | 34 ----------------------- tests/CheckUUIDTest.php | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 tests/CheckUUIDTest.php diff --git a/tests/CheckTypeTest.php b/tests/CheckTypeTest.php index 3ae4dafe..9dae4781 100644 --- a/tests/CheckTypeTest.php +++ b/tests/CheckTypeTest.php @@ -206,37 +206,3 @@ public function testCheckTypesInDeclare(){ } } - -class CheckUUIDTest extends TestCase{ - public function testCheckTypesInDeclare(){ - $config = [ - - // Database path - 'database' => '/local', - - // Database endpoint - 'endpoint' => 'localhost:2136', - - // Auto discovery (dedicated server only) - 'discovery' => false, - - // IAM config - 'iam_config' => [ - 'insecure' => true, - ], - - 'credentials' => new AnonymousAuthentication() - ]; - - $ydb = new Ydb($config); - $table = $ydb->table(); - $session = $table->createSession(); - - $query = "DECLARE \$v as Utf8; SELECT CAST(\$v AS UUID) as val;"; - $prepared = $session->prepare($query); - $result = $prepared->execute([ - 'v' => "6E73B41C-4EDE-4D08-9CFB-B7462D9E498B", - ]); - self::assertEquals("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B", $result->rows()[0]["val"]); - } -} diff --git a/tests/CheckUUIDTest.php b/tests/CheckUUIDTest.php new file mode 100644 index 00000000..048f2a76 --- /dev/null +++ b/tests/CheckUUIDTest.php @@ -0,0 +1,60 @@ + '/local', + +// Database endpoint + 'endpoint' => 'localhost:2136', + +// Auto discovery (dedicated server only) + 'discovery' => false, + +// IAM config + 'iam_config' => [ + 'insecure' => true, + ], + + 'credentials' => new AnonymousAuthentication() + ]; + + $ydb = new Ydb($config); + $table = $ydb->table(); + $session = $table->createSession(); + + $query = "DECLARE \$v as Utf8; SELECT CAST(\$v AS UUID) as val;"; + $prepared = $session->prepare($query); + $result = $prepared->execute([ + 'v' => "6E73B41C-4EDE-4D08-9CFB-B7462D9E498B", + ]); + self::assertEquals("6E73B41C-4EDE-4D08-9CFB-B7462D9E498B", $result->rows()[0]["val"]); + } +}