/** * Tests whether the actual constraint name is correctly computed. * * @param string $table_name * The table name the constrained column belongs to. * @param string $name * The constraint name. * @param string $expected * The expected computed constraint name. * * @covers ::constraintExists * @dataProvider providerComputedConstraintName */ 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); $this->connection->expects($this->any())->method('query')->willReturn($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')); $schema->constraintExists($table_name, $name); }
/** * @covers ::escapeField * @dataProvider providerEscapeFields */ public function testEscapeField($expected, $name) { $pgsql_connection = new Connection($this->mock_pdo, array()); $this->assertEquals($expected, $pgsql_connection->escapeField($name)); }