PostgresqlSchemaTest.php in Zircon Profile 8.0
File
core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php
View source
<?php
namespace Drupal\Tests\Core\Database\Driver\pgsql;
use Drupal\Core\Database\Driver\pgsql\Schema;
use Drupal\Tests\UnitTestCase;
class PostgresqlSchemaTest extends UnitTestCase {
protected $connection;
protected function setUp() {
parent::setUp();
$this->connection = $this
->getMockBuilder('\\Drupal\\Core\\Database\\Driver\\pgsql\\Connection')
->disableOriginalConstructor()
->getMock();
}
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);
}
public function providerComputedConstraintName() {
return [
[
'user_field_data',
'pkey',
'user_field_data____pkey',
],
[
'user_field_data',
'name__key',
'user_field_data__name__key',
],
[
'user_field_data',
'a_veeeery_veery_very_super_long_field_name__key',
'drupal_BGGYAXgbqlAF1rMOyFTdZGj9zIMXZtSvEjMAKZ9wGIk_key',
],
];
}
}