diff --git a/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php
index b55ddbb85f..fac83eac2a 100644
--- a/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php
@@ -116,4 +116,33 @@ public function testEscapeField($expected, $name) {
     $this->assertEquals($expected, $pgsql_connection->escapeField($name));
   }
 
+  /**
+   * Data provider for testPrefixTables.
+   *
+   * @return array
+   *   Array of arrays with the following elements:
+   *   - Expected prefixed table name.
+   *   - Prefix to use.
+   *   - Table name to prefix.
+   */
+  public function providerPrefixTables() {
+    return [
+      ['test', NULL, '{test}'],
+      ['prefix_test', 'prefix_', '{test}'],
+      ['prefix.test', 'prefix.', '{test}'],
+    ];
+  }
+
+  /**
+   * @covers ::prefixTables
+   * @dataProvider providerPrefixTables
+   */
+  public function testPrefixTables($expected, $prefix, $name) {
+    $connection_options = [
+      'prefix' => $prefix,
+    ];
+    $pgsql_connection = new Connection($this->mockPdo, $connection_options);
+    $this->assertEquals($expected, $pgsql_connection->prefixTables($name));
+  }
+
 }
diff --git a/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php
index d25d2cd281..04014ced1e 100644
--- a/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php
@@ -44,23 +44,34 @@ protected function setUp() {
    */
   public function testComputedConstraintName($table_name, $name, $expected) {
     $max_identifier_length = 63;
-    $schema = new Schema($this->connection);
 
     $statement = $this->getMock('\Drupal\Core\Database\StatementInterface');
     $statement->expects($this->any())
       ->method('fetchField')
-      ->willReturn($max_identifier_length);
+      ->will($this->onConsecutiveCalls($max_identifier_length, 1));
 
     $this->connection->expects($this->any())
       ->method('query')
-      ->willReturn($statement);
+      ->will($this->returnValueMap([
+        ["SHOW max_identifier_length", [], [], $statement],
+        ["SELECT 1 FROM pg_constraint WHERE conname = '$expected'", [], [], $statement],
+    ]));
 
-    $this->connection->expects($this->at(2))
-      ->method('query')
-      ->with("SELECT 1 FROM pg_constraint WHERE conname = '$expected'")
-      ->willReturn($this->getMock('\Drupal\Core\Database\StatementInterface'));
+    $this->connection->expects($this->any())
+      ->method('tablePrefix')
+      ->willReturn('');
+
+    $this->connection->expects($this->any())
+      ->method('escapeTable')
+      ->willReturnMap([
+        ['user_field_data____pkey' , '"user_field_data____pkey"'],
+        ['user_field_data__name__key', '"user_field_data__name__key"'],
+        ['drupal_BGGYAXgbqlAF1rMOyFTdZGj9zIMXZtSvEjMAKZ9wGIk_key', '"drupal_BGGYAXgbqlAF1rMOyFTdZGj9zIMXZtSvEjMAKZ9wGIk_key"'],
+      ]);
+
+    $schema = new Schema($this->connection);
 
-    $schema->constraintExists($table_name, $name);
+    $this->assertTrue($schema->constraintExists($table_name, $name));
   }
 
   /**
