function NonPublicSchemaTest::testDelete
@covers \Drupal\Core\Database\Connection::delete
      
    
@covers \Drupal\Core\Database\Connection::truncate
      
    
File
- 
              core/
modules/ pgsql/ tests/ src/ Kernel/ pgsql/ NonPublicSchemaTest.php, line 246  
Class
- NonPublicSchemaTest
 - Tests schema API for non-public schema for the PostgreSQL driver.
 
Namespace
Drupal\Tests\pgsql\Kernel\pgsqlCode
public function testDelete() : void {
  $num_records_before = $this->testingFakeConnection
    ->query('SELECT COUNT(*) FROM {faking_table}')
    ->fetchField();
  $num_deleted = $this->testingFakeConnection
    ->delete('faking_table')
    ->condition('id', 3)
    ->execute();
  $this->assertSame(1, $num_deleted, 'Deleted 1 record.');
  $num_records_after = $this->testingFakeConnection
    ->query('SELECT COUNT(*) FROM {faking_table}')
    ->fetchField();
  $this->assertEquals($num_records_before, $num_records_after + $num_deleted, 'Deletion adds up.');
  $num_records_before = $this->testingFakeConnection
    ->query("SELECT COUNT(*) FROM {faking_table}")
    ->fetchField();
  $this->assertNotEmpty($num_records_before);
  $this->testingFakeConnection
    ->truncate('faking_table')
    ->execute();
  $num_records_after = $this->testingFakeConnection
    ->query("SELECT COUNT(*) FROM {faking_table}")
    ->fetchField();
  $this->assertEquals(0, $num_records_after, 'Truncate really deletes everything.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.