public function ConnectionTest::testPrefixRoundTrip in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest::testPrefixRoundTrip()
Exercise setPrefix() and tablePrefix().
@dataProvider providerPrefixRoundTrip
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ ConnectionTest.php, line 52 - Contains \Drupal\Tests\Core\Database\ConnectionTest.
Class
- ConnectionTest
- Tests the Connection class.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testPrefixRoundTrip($expected, $prefix_info) {
$mock_pdo = $this
->getMock('Drupal\\Tests\\Core\\Database\\Stub\\StubPDO');
$connection = new StubConnection($mock_pdo, array());
// setPrefix() is protected, so we make it accessible with reflection.
$reflection = new \ReflectionClass('Drupal\\Tests\\Core\\Database\\Stub\\StubConnection');
$set_prefix = $reflection
->getMethod('setPrefix');
$set_prefix
->setAccessible(TRUE);
// Set the prefix data.
$set_prefix
->invokeArgs($connection, array(
$prefix_info,
));
// Check the round-trip.
foreach ($expected as $table => $prefix) {
$this
->assertEquals($prefix, $connection
->tablePrefix($table));
}
}