class PostgresqlSchemaTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlSchemaTest
@coversDefaultClass \Drupal\Core\Database\Driver\pgsql\Schema @group Database
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlSchemaTest
Expanded class hierarchy of PostgresqlSchemaTest
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ Driver/ pgsql/ PostgresqlSchemaTest.php, line 16 - Contains \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlSchemaTest.
Namespace
Drupal\Tests\Core\Database\Driver\pgsqlView source
class PostgresqlSchemaTest extends UnitTestCase {
/**
* The PostgreSql DB connection.
*
* @var \PHPUnit_Framework_MockObject_MockObject|\Drupal\Core\Database\Driver\pgsql\Connection
*/
protected $connection;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->connection = $this
->getMockBuilder('\\Drupal\\Core\\Database\\Driver\\pgsql\\Connection')
->disableOriginalConstructor()
->getMock();
}
/**
* 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);
}
/**
* Data provider for ::testComputedConstraintName().
*/
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',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PostgresqlSchemaTest:: |
protected | property | The PostgreSql DB connection. | |
PostgresqlSchemaTest:: |
public | function | Data provider for ::testComputedConstraintName(). | |
PostgresqlSchemaTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PostgresqlSchemaTest:: |
public | function | Tests whether the actual constraint name is correctly computed. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |