From ae9cc73418223a1a6ff54b3917a04b12fff6a6c3 Mon Sep 17 00:00:00 2001 From: Simon Asika Date: Fri, 10 Nov 2023 19:17:36 +0800 Subject: [PATCH] Fix test --- .../Manager/PostgreSQLTableManagerTest.php | 4 ++-- .../test/Platform/PostgreSQLPlatformTest.php | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/database/test/Manager/PostgreSQLTableManagerTest.php b/packages/database/test/Manager/PostgreSQLTableManagerTest.php index 1ada600fe..64df35588 100644 --- a/packages/database/test/Manager/PostgreSQLTableManagerTest.php +++ b/packages/database/test/Manager/PostgreSQLTableManagerTest.php @@ -75,7 +75,7 @@ static function (Schema $schema) { ORDER BY "table_name" ASC; CREATE TABLE IF NOT EXISTS "enterprise" ( "id" serial NOT NULL, - "type" char(25) NOT NULL DEFAULT '', + "type" varchar(25) NOT NULL DEFAULT '', "catid" integer DEFAULT NULL, "alias" varchar(255) NOT NULL DEFAULT '', "title" varchar(255) NOT NULL DEFAULT 'H', @@ -179,7 +179,7 @@ function (Schema $schema) { ALTER TABLE "enterprise" ADD COLUMN "first_officer" varchar(512) NOT NULL DEFAULT ''; ALTER TABLE "enterprise" - ALTER COLUMN "alias" TYPE char(25), + ALTER COLUMN "alias" TYPE varchar(25), ALTER COLUMN "alias" SET NOT NULL, ALTER COLUMN "alias" SET DEFAULT ''; SELECT "ix".*, tc.constraint_type = 'PRIMARY KEY' AS "is_primary" diff --git a/packages/database/test/Platform/PostgreSQLPlatformTest.php b/packages/database/test/Platform/PostgreSQLPlatformTest.php index b23357f2f..21a657791 100644 --- a/packages/database/test/Platform/PostgreSQLPlatformTest.php +++ b/packages/database/test/Platform/PostgreSQLPlatformTest.php @@ -85,6 +85,15 @@ public function testGetViews(): void { $views = $this->instance->listViews(static::$schema); + foreach ($views as &$view) { + // Remove prefix since it may different between PostgreSQL versions. + $view['VIEW_DEFINITION'] = str_replace( + 'ww_articles.', + '', + $view['VIEW_DEFINITION'] + ); + } + self::assertEquals( [ 'ww_articles_view' => [ @@ -92,8 +101,12 @@ public function testGetViews(): void 'TABLE_CATALOG' => 'windwalker_test', 'TABLE_SCHEMA' => 'public', 'TABLE_TYPE' => 'VIEW', - 'VIEW_DEFINITION' => Str::replaceCRLF( - ' SELECT ww_articles.id, + // Remove prefix since it may different between PostgreSQL versions. + 'VIEW_DEFINITION' => str_replace( + 'ww_articles.', + '', + Str::replaceCRLF( + ' SELECT ww_articles.id, ww_articles.category_id, ww_articles.page_id, ww_articles.type, @@ -108,6 +121,7 @@ public function testGetViews(): void ww_articles.language, ww_articles.params FROM ww_articles;' + ) ), 'CHECK_OPTION' => 'NONE', 'IS_UPDATABLE' => 'YES',