/** * @testdox Reports can have source queries injected into them. * @test */ public function sources() { $reportsTable = $this->db->get_table(Reports::reports_table_name()); $report = $reportsTable->save_record(array('title' => 'Test Report', 'template' => 'Today is {{dates.0.date}}')); $reportSourcesTable = $this->db->get_table(Reports::report_sources_table_name()); $reportSourcesTable->save_record(array('report' => $report->id(), 'name' => 'dates', 'query' => "SELECT CURRENT_DATE AS `date`;")); $reports = new Reports($this->db); $template = $reports->get_template($report->id()); $this->assertEquals('Today is ' . date('Y-m-d'), $template->render()); }
<?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');