function DeleteTruncateTest::testSpecialColumnDelete

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

Confirms that we can delete a single special column name record successfully.

File

core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php, line 150

Class

DeleteTruncateTest
Tests delete and truncate queries.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testSpecialColumnDelete() {
    $num_records_before = $this->connection
        ->query('SELECT COUNT(*) FROM {test_special_columns}')
        ->fetchField();
    $num_deleted = $this->connection
        ->delete('test_special_columns')
        ->condition('id', 1)
        ->execute();
    $this->assertIdentical($num_deleted, 1, 'Deleted 1 special column record.');
    $num_records_after = $this->connection
        ->query('SELECT COUNT(*) FROM {test_special_columns}')
        ->fetchField();
    $this->assertEqual($num_records_before, $num_records_after + $num_deleted, 'Deletion adds up.');
}

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