/**
  * @testdox A record can be deleted, and it's history along with it.
  */
 public function delete()
 {
     // Create two, to make sure only one is deleted.
     $test_types = $this->db->get_table('test_types');
     $test_types->save_record(array('title' => 'First Type'));
     $test_types->save_record(array('title' => 'Second Type'));
     $this->assertEquals(2, $test_types->count_records());
     $test_types->delete_record(2);
     $this->assertEquals(1, $test_types->count_records());
     $changesets = $this->db->get_table(ChangeTracker::changesets_name());
     $this->assertEquals(1, $changesets->count_records());
 }
예제 #2
0
<?php

if (!defined('ABSPATH') || !defined('WP_UNINSTALL_PLUGIN')) {
    return false;
}
// Clear Grants' option.
$grants = new \WordPress\Tabulate\DB\Grants();
$grants->delete();
// Drop the ChangeTracker's and Reports' tables.
global $wpdb;
$wpdb->query('SET FOREIGN_KEY_CHECKS = 0');
foreach (\WordPress\Tabulate\DB\ChangeTracker::table_names() as $tbl) {
    $wpdb->query("DROP TABLE IF EXISTS `{$tbl}`;");
}
$wpdb->query("DROP TABLE IF EXISTS `" . \WordPress\Tabulate\DB\Reports::reports_table_name() . "`;");
$wpdb->query("DROP TABLE IF EXISTS `" . \WordPress\Tabulate\DB\Reports::report_sources_table_name() . "`;");
$wpdb->query('SET FOREIGN_KEY_CHECKS = 1');