
| Current Path : /var/www/html1/rrr/web/core/tests/Drupal/Tests/Core/Database/Stub/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //var/www/html1/rrr/web/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php |
<?php
namespace Drupal\Tests\Core\Database\Stub;
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Log;
use Drupal\Core\Database\StatementEmpty;
use Drupal\Core\Database\StatementWrapper;
/**
* A stub of the abstract Connection class for testing purposes.
*
* Includes minimal implementations of Connection's abstract methods.
*/
class StubConnection extends Connection {
/**
* {@inheritdoc}
*/
protected $statementClass = NULL;
/**
* {@inheritdoc}
*/
protected $statementWrapperClass = StatementWrapper::class;
/**
* Public property so we can test driver loading mechanism.
*
* @var string
* @see driver().
*/
public $driver = 'stub';
/**
* Constructs a Connection object.
*
* @param \PDO $connection
* An object of the PDO class representing a database connection.
* @param array $connection_options
* An array of options for the connection.
* @param string[]|null $identifier_quotes
* The identifier quote characters. Defaults to an empty strings.
* @param string|null $statement_class
* A class to use as a statement class for deprecation testing.
*/
public function __construct(\PDO $connection, array $connection_options, $identifier_quotes = ['', ''], $statement_class = NULL) {
$this->identifierQuotes = $identifier_quotes;
if ($statement_class) {
$this->statementClass = $statement_class;
$this->statementWrapperClass = NULL;
}
parent::__construct($connection, $connection_options);
}
/**
* {@inheritdoc}
*/
public function queryRange($query, $from, $count, array $args = [], array $options = []) {
return new StatementEmpty();
}
/**
* {@inheritdoc}
*/
public function queryTemporary($query, array $args = [], array $options = []) {
return '';
}
/**
* {@inheritdoc}
*/
public function driver() {
return $this->driver;
}
/**
* {@inheritdoc}
*/
public function databaseType() {
return 'stub';
}
/**
* {@inheritdoc}
*/
public function createDatabase($database) {}
/**
* {@inheritdoc}
*/
public function mapConditionOperator($operator) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function nextId($existing_id = 0) {
return 0;
}
/**
* Helper method to test database classes are not included in backtraces.
*
* @return array
* The caller stack entry.
*/
public function testLogCaller() {
return (new Log())->findCaller();
}
}