diff --git a/core/database.php b/core/database.php index c2ed9d9a..de4e0122 100644 --- a/core/database.php +++ b/core/database.php @@ -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 - { - } -}