Esempio n. 1
0
 public static function init()
 {
     add_action(self::WPML_LOGROTATION_SCHEDULE_HOOK, array(__NAMESPACE__ . '\\WPML_LogRotation', self::WPML_LOGROTATION_SCHEDULE));
     $logRotation = new WPML_LogRotation();
     register_deactivation_hook(plugin_dir_path(__FILE__) . $logRotation->getMainPluginFileName(), array($logRotation, 'unschedule'));
 }
 /**
  * Test limitNumberOfMailsByTime - Check if all old messages where deleted.
  * The LogRotation supports the limitation of stored mails by date.
  * This test checks of old messages are deleted after given time by comparing the amount of mails.
  * @since 1.6.0
  * @see WPML_LogRotation::limitNumberOfMailsByTime
  */
 function test_limitNumberOfMailsByTime_order()
 {
     global $wpml_settings;
     $amount = 10;
     $old = 3;
     $days = 5;
     $this->prepareMessages($amount);
     $wpml_settings['log-rotation-delete-time'] = '1';
     $wpml_settings['log-rotation-delete-time-days'] = $days;
     // Make #$old mails #$days older:
     foreach ($this->query_some_mails($old) as $mail) {
         $mail->set_timestamp(gmdate('Y-m-d H:i:s', time() + get_option('gmt_offset') * HOUR_IN_SECONDS + $days * DAY_IN_SECONDS))->save();
     }
     WPML_LogRotation::limitNumberOfMailsByTime();
     // Assert that there are just $amount-$old mails left.
     $this->assertEquals($amount - $old, $this->count_mails());
 }