Implement basic WPDB Doctrine driver with connection, statement, and result stubs
[MAILPOET-6142]
This commit is contained in:
48
mailpoet/lib/Doctrine/WPDB/Connection.php
Normal file
48
mailpoet/lib/Doctrine/WPDB/Connection.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Doctrine\WPDB;
|
||||
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||
|
||||
class Connection implements ServerInfoAwareConnection {
|
||||
public function prepare(string $sql): Statement {
|
||||
// TODO: Implement prepare() method.
|
||||
}
|
||||
|
||||
public function query(string $sql): Result {
|
||||
// TODO: Implement query() method.
|
||||
}
|
||||
|
||||
public function exec(string $sql): int {
|
||||
// TODO: Implement exec() method.
|
||||
}
|
||||
|
||||
public function beginTransaction() {
|
||||
// TODO: Implement beginTransaction() method.
|
||||
}
|
||||
|
||||
public function commit() {
|
||||
// TODO: Implement commit() method.
|
||||
}
|
||||
|
||||
public function rollBack() {
|
||||
// TODO: Implement rollBack() method.
|
||||
}
|
||||
|
||||
public function quote($value, $type = ParameterType::STRING) {
|
||||
// TODO: Implement quote() method.
|
||||
}
|
||||
|
||||
public function lastInsertId($name = null) {
|
||||
// TODO: Implement lastInsertId() method.
|
||||
}
|
||||
|
||||
public function getServerVersion() {
|
||||
// TODO: Implement getServerVersion() method.
|
||||
}
|
||||
|
||||
public function __call($name, $arguments) {
|
||||
// TODO: Implement @method object getNativeConnection()
|
||||
}
|
||||
}
|
11
mailpoet/lib/Doctrine/WPDB/Driver.php
Normal file
11
mailpoet/lib/Doctrine/WPDB/Driver.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Doctrine\WPDB;
|
||||
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\AbstractMySQLDriver;
|
||||
|
||||
class Driver extends AbstractMySQLDriver {
|
||||
public function connect(array $params): Connection {
|
||||
return new Connection();
|
||||
}
|
||||
}
|
43
mailpoet/lib/Doctrine/WPDB/Result.php
Normal file
43
mailpoet/lib/Doctrine/WPDB/Result.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Doctrine\WPDB;
|
||||
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\Result as ResultInterface;
|
||||
|
||||
class Result implements ResultInterface {
|
||||
public function fetchNumeric() {
|
||||
// TODO: Implement fetchNumeric() method.
|
||||
}
|
||||
|
||||
public function fetchAssociative() {
|
||||
// TODO: Implement fetchAssociative() method.
|
||||
}
|
||||
|
||||
public function fetchOne() {
|
||||
// TODO: Implement fetchOne() method.
|
||||
}
|
||||
|
||||
public function fetchAllNumeric(): array {
|
||||
// TODO: Implement fetchAllNumeric() method.
|
||||
}
|
||||
|
||||
public function fetchAllAssociative(): array {
|
||||
// TODO: Implement fetchAllAssociative() method.
|
||||
}
|
||||
|
||||
public function fetchFirstColumn(): array {
|
||||
// TODO: Implement fetchFirstColumn() method.
|
||||
}
|
||||
|
||||
public function rowCount(): int {
|
||||
// TODO: Implement rowCount() method.
|
||||
}
|
||||
|
||||
public function columnCount(): int {
|
||||
// TODO: Implement columnCount() method.
|
||||
}
|
||||
|
||||
public function free(): void {
|
||||
// TODO: Implement free() method.
|
||||
}
|
||||
}
|
21
mailpoet/lib/Doctrine/WPDB/Statement.php
Normal file
21
mailpoet/lib/Doctrine/WPDB/Statement.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Doctrine\WPDB;
|
||||
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\Result;
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\Statement as StatementInterface;
|
||||
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||
|
||||
class Statement implements StatementInterface {
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING) {
|
||||
// TODO: Implement bindValue() method.
|
||||
}
|
||||
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null) {
|
||||
// TODO: Implement bindParam() method.
|
||||
}
|
||||
|
||||
public function execute($params = null): Result {
|
||||
// TODO: Implement execute() method.
|
||||
}
|
||||
}
|
20
mailpoet/tests/integration/Doctrine/WPDB/DriverTest.php
Normal file
20
mailpoet/tests/integration/Doctrine/WPDB/DriverTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Test\Doctrine\WPDB;
|
||||
|
||||
use MailPoet\Doctrine\WPDB\Connection;
|
||||
use MailPoet\Doctrine\WPDB\Driver;
|
||||
use MailPoetTest;
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
|
||||
use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1052Platform;
|
||||
use MailPoetVendor\Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
|
||||
class DriverTest extends MailPoetTest {
|
||||
public function testDriverSetup(): void {
|
||||
$driver = new Driver();
|
||||
$this->assertInstanceOf(Connection::class, $driver->connect([]));
|
||||
$this->assertInstanceOf(MySQLPlatform::class, $driver->getDatabasePlatform());
|
||||
$this->assertInstanceOf(MariaDb1052Platform::class, $driver->createDatabasePlatformForVersion('10.5.8-MariaDB-1:10.5.8+maria~focal'));
|
||||
$this->assertInstanceOf(ExceptionConverter::class, $driver->getExceptionConverter());
|
||||
}
|
||||
}
|
19
mailpoet/tests/unit/Doctrine/WPDB/DriverTest.php
Normal file
19
mailpoet/tests/unit/Doctrine/WPDB/DriverTest.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace MailPoet\Doctrine\WPDB;
|
||||
|
||||
use MailPoetUnitTest;
|
||||
use MailPoetVendor\Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
|
||||
use MailPoetVendor\Doctrine\DBAL\Platforms\MariaDb1052Platform;
|
||||
use MailPoetVendor\Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
|
||||
class DriverTest extends MailPoetUnitTest {
|
||||
public function testDriverSetup(): void {
|
||||
$driver = $this->createPartialMock(Driver::class, ['connect']);
|
||||
|
||||
$this->assertInstanceOf(Connection::class, $driver->connect([]));
|
||||
$this->assertInstanceOf(MySQLPlatform::class, $driver->getDatabasePlatform());
|
||||
$this->assertInstanceOf(MariaDb1052Platform::class, $driver->createDatabasePlatformForVersion('10.5.8-MariaDB-1:10.5.8+maria~focal'));
|
||||
$this->assertInstanceOf(ExceptionConverter::class, $driver->getExceptionConverter());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user