/** * Checks (de)activating the plugin (un)schedules "old" alerts for * deletion. * * It is important for Buoy alerts to be ephemeral in nature, not * necessarily stored in a database for a long time. This test is * used to make sure that merely activating the plugin is enough * to tell the plugin to delete any incident data that was made * 48 hours ago (or longer). * * This test also checks for the inverse: that this scheduled job * is automatically removed whenever the plugin is deactivated. * * Note that this test does *not* ensure the alert data itself is * deleted, only that the automatic job scheduler has the correct * information. * * @ticket 21 */ public function test_schedule_and_unschedule_delete_old_alerts_hook_on_activation_and_deactivation() { WP_Buoy_Plugin::activate(); $this->assertEquals('hourly', wp_get_schedule('buoy_delete_old_alerts', array('-2 days'))); WP_Buoy_Plugin::deactivate(); $this->assertFalse(wp_get_schedule('buoy_delete_old_alerts', array('-2 days'))); }
public function test_deactivation_unschedules_delete_old_alerts_hook() { WP_Buoy_Plugin::deactivate(); $this->assertFalse(wp_get_schedule('buoy_delete_old_alerts', array('-2 days'))); }
private static function error_msg($message) { $dbt = debug_backtrace(); // the "2" is so we get the name of the function that originally called debug_log() // This works so long as error_msg() is always called by debug_log() return '[' . get_called_class() . '::' . $dbt[2]['function'] . '()]: ' . $message; } /** * Prints a message to the WordPress debug log if the plugin's * "detailed debugging" setting is enabled. * * By default, the WordPress debug log is `wp-content/debug.log` * relative to the WordPress installation root (`ABSPATH`). * * @link https://codex.wordpress.org/Debugging_in_WordPress * * @uses WP_Buoy_Settings::get() * * @param string $message * * @return void */ protected static function debug_log($message) { if (WP_Buoy_Settings::get_instance()->get('debug')) { error_log(static::error_msg($message)); } } } WP_Buoy_Plugin::register();