class PostgresqlConnectionTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlConnectionTest.php \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlConnectionTest
@coversDefaultClass \Drupal\Core\Database\Driver\pgsql\Connection @group Database
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlConnectionTest
Expanded class hierarchy of PostgresqlConnectionTest
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ Driver/ pgsql/ PostgresqlConnectionTest.php, line 16 - Contains \Drupal\Tests\Core\Database\Driver\pgsql\PostgresqlConnectionTest.
Namespace
Drupal\Tests\Core\Database\Driver\pgsqlView source
class PostgresqlConnectionTest extends UnitTestCase {
/**
* Mock PDO object for use in tests.
*
* @var \PHPUnit_Framework_MockObject_MockObject|\Drupal\Tests\Core\Database\Stub\StubPDO
*/
protected $mockPdo;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->mockPdo = $this
->getMock('Drupal\\Tests\\Core\\Database\\Stub\\StubPDO');
}
/**
* Data provider for testEscapeTable.
*
* @return []
* An indexed array of where each value is an array of arguments to pass to
* testEscapeField. The first value is the expected value, and the second
* value is the value to test.
*/
public function providerEscapeTables() {
return array(
array(
'nocase',
'nocase',
),
array(
'"camelCase"',
'camelCase',
),
array(
'"camelCase"',
'"camelCase"',
),
array(
'"camelCase"',
'camel/Case',
),
);
}
/**
* Data provider for testEscapeAlias.
*
* @return []
* Array of arrays with the following elements:
* - Expected escaped string.
* - String to escape.
*/
public function providerEscapeAlias() {
return array(
array(
'nocase',
'nocase',
),
array(
'"camelCase"',
'"camelCase"',
),
array(
'"camelCase"',
'camelCase',
),
array(
'"camelCase"',
'camel.Case',
),
);
}
/**
* Data provider for testEscapeField.
*
* @return []
* Array of arrays with the following elements:
* - Expected escaped string.
* - String to escape.
*/
public function providerEscapeFields() {
return array(
array(
'title',
'title',
),
array(
'"isDefaultRevision"',
'isDefaultRevision',
),
array(
'"isDefaultRevision"',
'"isDefaultRevision"',
),
array(
'entity_test."isDefaultRevision"',
'entity_test.isDefaultRevision',
),
array(
'entity_test."isDefaultRevision"',
'"entity_test"."isDefaultRevision"',
),
array(
'"entityTest"."isDefaultRevision"',
'"entityTest"."isDefaultRevision"',
),
array(
'"entityTest"."isDefaultRevision"',
'entityTest.isDefaultRevision',
),
array(
'entity_test."isDefaultRevision"',
'entity_test.is.Default.Revision',
),
);
}
/**
* @covers ::escapeTable
* @dataProvider providerEscapeTables
*/
public function testEscapeTable($expected, $name) {
$pgsql_connection = new Connection($this->mockPdo, []);
$this
->assertEquals($expected, $pgsql_connection
->escapeTable($name));
}
/**
* @covers ::escapeAlias
* @dataProvider providerEscapeAlias
*/
public function testEscapeAlias($expected, $name) {
$pgsql_connection = new Connection($this->mockPdo, []);
$this
->assertEquals($expected, $pgsql_connection
->escapeAlias($name));
}
/**
* @covers ::escapeField
* @dataProvider providerEscapeFields
*/
public function testEscapeField($expected, $name) {
$pgsql_connection = new Connection($this->mockPdo, []);
$this
->assertEquals($expected, $pgsql_connection
->escapeField($name));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PostgresqlConnectionTest:: |
protected | property | Mock PDO object for use in tests. | |
PostgresqlConnectionTest:: |
public | function | Data provider for testEscapeAlias. | |
PostgresqlConnectionTest:: |
public | function | Data provider for testEscapeField. | |
PostgresqlConnectionTest:: |
public | function | Data provider for testEscapeTable. | |
PostgresqlConnectionTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PostgresqlConnectionTest:: |
public | function | @covers ::escapeAlias @dataProvider providerEscapeAlias | |
PostgresqlConnectionTest:: |
public | function | @covers ::escapeField @dataProvider providerEscapeFields | |
PostgresqlConnectionTest:: |
public | function | @covers ::escapeTable @dataProvider providerEscapeTables | |
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. |