function ConnectionTest::createConnection
Same name in other branches
- 10 core/modules/mysql/tests/src/Unit/ConnectionTest.php \Drupal\Tests\mysql\Unit\ConnectionTest::createConnection()
- 11.x core/modules/mysql/tests/src/Unit/ConnectionTest.php \Drupal\Tests\mysql\Unit\ConnectionTest::createConnection()
Creates a Connection object for testing.
Return value
\Drupal\mysql\Driver\Database\mysql\Connection
1 call to ConnectionTest::createConnection()
- ConnectionTest::testVersionAndIsMariaDb in core/
modules/ mysql/ tests/ src/ Unit/ ConnectionTest.php - @covers ::version @covers ::isMariaDb @dataProvider providerVersionAndIsMariaDb
File
-
core/
modules/ mysql/ tests/ src/ Unit/ ConnectionTest.php, line 44
Class
- ConnectionTest
- Tests MySQL database connections.
Namespace
Drupal\Tests\mysql\UnitCode
private function createConnection() : Connection {
$this->pdoStatement
->setFetchMode(Argument::any())
->shouldBeCalled()
->willReturn(TRUE);
$this->pdoStatement
->execute(Argument::any())
->shouldBeCalled()
->willReturn(TRUE);
$this->pdoConnection
->prepare('SELECT VERSION()', Argument::any())
->shouldBeCalled()
->willReturn($this->pdoStatement
->reveal());
/** @var \PDO $pdo_connection */
$pdo_connection = $this->pdoConnection
->reveal();
return new class ($pdo_connection) extends Connection {
public function __construct(\PDO $connection) {
$this->connection = $connection;
$this->setPrefix('');
}
};
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.