You are here

class TestSqlBase in Drupal 10

Same name in this branch
  1. 10 core/modules/migrate/tests/src/Unit/SqlBaseTest.php \Drupal\Tests\migrate\Unit\TestSqlBase
  2. 10 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\TestSqlBase
Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\TestSqlBase
  2. 9 core/modules/migrate/tests/src/Kernel/SqlBaseTest.php \Drupal\Tests\migrate\Kernel\TestSqlBase

A dummy source to help with testing SqlBase.

@package Drupal\migrate\Plugin\migrate\source

Hierarchy

  • class \Drupal\Tests\migrate\Kernel\TestSqlBase extends \Drupal\migrate\Plugin\migrate\source\SqlBase

Expanded class hierarchy of TestSqlBase

File

core/modules/migrate/tests/src/Kernel/SqlBaseTest.php, line 186
Contains \Drupal\Tests\migrate\Kernel\SqlBaseTest.

Namespace

Drupal\Tests\migrate\Kernel
View source
class TestSqlBase extends SqlBase {

  /**
   * The query to execute.
   *
   * @var \Drupal\Core\Database\Query\SelectInterface
   */
  protected $query;

  /**
   * Overrides the constructor so we can create one easily.
   *
   * @param array $configuration
   *   The plugin instance configuration.
   * @param \Drupal\migrate\Plugin\MigrationInterface $migration
   *   (optional) The migration being run.
   */
  public function __construct(array $configuration = [], MigrationInterface $migration = NULL) {
    parent::__construct($configuration, 'sql_base', [], $migration, \Drupal::state());
  }

  /**
   * Gets the database without caching it.
   */
  public function getDatabase() {
    $this->database = NULL;
    return parent::getDatabase();
  }

  /**
   * Allows us to set the configuration from a test.
   *
   * @param array $config
   *   The config array.
   */
  public function setConfiguration($config) {
    $this->configuration = $config;
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    throw new \RuntimeException(__METHOD__ . " not implemented for " . __CLASS__);
  }

  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->query;
  }

  /**
   * Sets the query to execute.
   *
   * @param \Drupal\Core\Database\Query\SelectInterface $query
   *   The query to execute.
   */
  public function setQuery(SelectInterface $query) {
    $this->query = $query;
  }

}

Members