1<?php
2
3namespace Drupal\Tests\Core\Database\Stub;
4
5use Drupal\Core\Database\Connection;
6use Drupal\Core\Database\StatementEmpty;
7
8/**
9 * A stub of the abstract Connection class for testing purposes.
10 *
11 * Includes minimal implementations of Connection's abstract methods.
12 */
13class StubConnection extends Connection {
14
15  /**
16   * Public property so we can test driver loading mechanism.
17   *
18   * @var string
19   * @see driver().
20   */
21  public $driver = 'stub';
22
23  /**
24   * {@inheritdoc}
25   */
26  public function queryRange($query, $from, $count, array $args = [], array $options = []) {
27    return new StatementEmpty();
28  }
29
30  /**
31   * {@inheritdoc}
32   */
33  public function queryTemporary($query, array $args = [], array $options = []) {
34    return '';
35  }
36
37  /**
38   * {@inheritdoc}
39   */
40  public function driver() {
41    return $this->driver;
42  }
43
44  /**
45   * {@inheritdoc}
46   */
47  public function databaseType() {
48    return 'stub';
49  }
50
51  /**
52   * {@inheritdoc}
53   */
54  public function createDatabase($database) {}
55
56  /**
57   * {@inheritdoc}
58   */
59  public function mapConditionOperator($operator) {
60    return NULL;
61  }
62
63  /**
64   * {@inheritdoc}
65   */
66  public function nextId($existing_id = 0) {
67    return 0;
68  }
69
70}
71