From 13f23c726a67393b19130aa6c4b0c987b9b275c1 Mon Sep 17 00:00:00 2001 From: Dmitriy Gritsenko Date: Wed, 25 Dec 2024 14:57:23 +0500 Subject: [PATCH] Fix issue #762 --- src/Schema/AbstractSchema.php | 14 +++----------- src/Schema/SchemaInterface.php | 6 +++--- tests/Common/CommonSchemaTest.php | 14 +++++++------- tests/Db/Schema/SchemaTest.php | 8 ++++---- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/Schema/AbstractSchema.php b/src/Schema/AbstractSchema.php index 5a52d9322..264c8902d 100644 --- a/src/Schema/AbstractSchema.php +++ b/src/Schema/AbstractSchema.php @@ -576,12 +576,9 @@ public function getViewNames(string $schema = '', bool $refresh = false): array } /** - * @param string $tableName The table name. - * @param string $schema The schema of the tables. - * @return bool * @throws Throwable */ - public function hasTableName(string $tableName, string $schema = ''): bool + public function hasTable(string $tableName, string $schema = ''): bool { $tables = $this->getTableNames($schema); @@ -589,11 +586,9 @@ public function hasTableName(string $tableName, string $schema = ''): bool } /** - * @param string $schema The schema name. - * @return bool * @throws Throwable */ - public function hasSchemaName(string $schema): bool + public function hasSchema(string $schema): bool { $schemas = $this->getSchemaNames(); @@ -601,12 +596,9 @@ public function hasSchemaName(string $schema): bool } /** - * @param string $viewName The view name. - * @param string $schema The schema of the views. - * @return bool * @throws Throwable */ - public function hasViewName(string $viewName, string $schema = ''): bool + public function hasView(string $viewName, string $schema = ''): bool { $views = $this->getViewNames($schema); diff --git a/src/Schema/SchemaInterface.php b/src/Schema/SchemaInterface.php index 9f05ec54d..422518564 100644 --- a/src/Schema/SchemaInterface.php +++ b/src/Schema/SchemaInterface.php @@ -425,7 +425,7 @@ public function getViewNames(string $schema = '', bool $refresh = false): array; * name. If not empty, the table will be searched in the specified schema. * @return bool Whether table exists or not */ - public function hasTableName(string $tableName, string $schema = ''): bool; + public function hasTable(string $tableName, string $schema = ''): bool; /** * Determines if a specified schema exists in the database. @@ -433,7 +433,7 @@ public function hasTableName(string $tableName, string $schema = ''): bool; * @param string $schema The table name to search for * @return bool Whether schema exists or not */ - public function hasSchemaName(string $schema): bool; + public function hasSchema(string $schema): bool; /** * Determines if a specified view exists in the database. @@ -443,5 +443,5 @@ public function hasSchemaName(string $schema): bool; * name. If not empty, the table will be searched in the specified schema. * @return bool Whether view exists or not */ - public function hasViewName(string $viewName, string $schema = ''): bool; + public function hasView(string $viewName, string $schema = ''): bool; } diff --git a/tests/Common/CommonSchemaTest.php b/tests/Common/CommonSchemaTest.php index 5e6ce718d..1541dde65 100644 --- a/tests/Common/CommonSchemaTest.php +++ b/tests/Common/CommonSchemaTest.php @@ -405,7 +405,7 @@ public function testGetTableNames(array $pdoAttributes): void $db->close(); } - public function testHasTableName(array $pdoAttributes): void + public function testHasTable(array $pdoAttributes): void { $db = $this->getConnection(true); @@ -419,9 +419,9 @@ public function testHasTableName(array $pdoAttributes): void $schema = $db->getSchema(); - $this->assertTrue($schema->hasTableName('customer')); - $this->assertTrue($schema->hasTableName('category')); - $this->assertFalse($schema->hasTableName('no_such_table')); + $this->assertTrue($schema->hasTable('customer')); + $this->assertTrue($schema->hasTable('category')); + $this->assertFalse($schema->hasTable('no_such_table')); $db->close(); } @@ -503,14 +503,14 @@ public function testGetViewNames(): void $db->close(); } - public function hasViewName(): void + public function hasView(): void { $db = $this->getConnection(true); $schema = $db->getSchema(); - $this->assertTrue($schema->hasViewName('animal_view')); - $this->assertFalse($schema->hasViewName('no_such_view')); + $this->assertTrue($schema->hasView('animal_view')); + $this->assertFalse($schema->hasView('no_such_view')); $db->close(); } diff --git a/tests/Db/Schema/SchemaTest.php b/tests/Db/Schema/SchemaTest.php index e4e7453ca..60cd54cb0 100644 --- a/tests/Db/Schema/SchemaTest.php +++ b/tests/Db/Schema/SchemaTest.php @@ -202,16 +202,16 @@ public function testGetSchemaNamesWithSchema(): void $this->assertSame(['dbo', 'public'], $schema->getSchemaNames()); } - public function testHasSchemaName(): void + public function testHasSchema(): void { $db = $this->getConnection(); $schema = $db->getSchema(); Assert::setInaccessibleProperty($schema, 'schemaNames', ['dbo', 'public']); - $this->assertTrue($schema->hasSchemaName('dbo')); - $this->assertTrue($schema->hasSchemaName('public')); - $this->assertFalse($schema->hasSchemaName('no_such_schema')); + $this->assertTrue($schema->hasSchema('dbo')); + $this->assertTrue($schema->hasSchema('public')); + $this->assertFalse($schema->hasSchema('no_such_schema')); $db->close(); }