function AlterTest::testSimpleAlter

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest::testSimpleAlter()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest::testSimpleAlter()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest::testSimpleAlter()

Tests that we can do basic alters.

File

core/tests/Drupal/KernelTests/Core/Database/AlterTest.php, line 16

Class

AlterTest
Tests the hook_query_alter capabilities of the Select builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSimpleAlter() {
    $query = $this->connection
        ->select('test');
    $query->addField('test', 'name');
    $query->addField('test', 'age', 'age');
    $query->addTag('database_test_alter_add_range');
    $result = $query->execute()
        ->fetchAll();
    $this->assertCount(2, $result, 'Returned the correct number of rows.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.