MockDatabase didn't get used
This commit is contained in:
parent
66bd27b0ee
commit
3f689b68bc
1 changed files with 0 additions and 75 deletions
|
@ -336,78 +336,3 @@ class Database
|
|||
return $this->db;
|
||||
}
|
||||
}
|
||||
|
||||
class MockDatabase extends Database
|
||||
{
|
||||
/** @var int */
|
||||
private $query_id = 0;
|
||||
/** @var array */
|
||||
private $responses = [];
|
||||
|
||||
public function __construct(array $responses = [])
|
||||
{
|
||||
parent::__construct("fake:dsn");
|
||||
$this->responses = $responses;
|
||||
}
|
||||
|
||||
public function execute(string $query, array $params=[], bool $scoreql = false): PDOStatement
|
||||
{
|
||||
log_debug(
|
||||
"mock-database",
|
||||
"QUERY: " . $query .
|
||||
"\nARGS: " . var_export($params, true) .
|
||||
"\nRETURN: " . var_export($this->responses[$this->query_id], true)
|
||||
);
|
||||
return $this->responses[$this->query_id++];
|
||||
}
|
||||
|
||||
public function _execute(string $query, array $params=[])
|
||||
{
|
||||
log_debug(
|
||||
"mock-database",
|
||||
"QUERY: " . $query .
|
||||
"\nARGS: " . var_export($params, true) .
|
||||
"\nRETURN: " . var_export($this->responses[$this->query_id], true)
|
||||
);
|
||||
return $this->responses[$this->query_id++];
|
||||
}
|
||||
|
||||
public function get_all(string $query, array $args=[], bool $scoreql = false): array
|
||||
{
|
||||
return $this->_execute($query, $args);
|
||||
}
|
||||
public function get_row(string $query, array $args=[], bool $scoreql = false): ?array
|
||||
{
|
||||
return $this->_execute($query, $args);
|
||||
}
|
||||
public function get_col(string $query, array $args=[], bool $scoreql = false): array
|
||||
{
|
||||
return $this->_execute($query, $args);
|
||||
}
|
||||
public function get_pairs(string $query, array $args=[], bool $scoreql = false): array
|
||||
{
|
||||
return $this->_execute($query, $args);
|
||||
}
|
||||
public function get_one(string $query, array $args=[], bool $scoreql = false)
|
||||
{
|
||||
return $this->_execute($query, $args);
|
||||
}
|
||||
|
||||
public function get_last_insert_id(string $seq): int
|
||||
{
|
||||
return $this->query_id;
|
||||
}
|
||||
|
||||
public function scoreql_to_sql(string $sql): string
|
||||
{
|
||||
return $sql;
|
||||
}
|
||||
|
||||
public function create_table(string $name, string $def): void
|
||||
{
|
||||
}
|
||||
|
||||
public function connect_engine(): void
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue