Use a wrapped function for current_time [MAILPOET-2488]

This commit is contained in:
wxa
2019-12-25 14:13:52 +03:00
committed by amine-mp
parent 176aba69fe
commit 6ed3915b1a
20 changed files with 83 additions and 68 deletions

View File

@ -6,6 +6,7 @@ use MailPoet\API\JSON\v1\ImportExport;
use MailPoet\Cron\Workers\WooCommerceSync;
use MailPoet\DI\ContainerWrapper;
use MailPoet\Models\ScheduledTask;
use MailPoet\WP\Functions as WPFunctions;
use MailPoetVendor\Carbon\Carbon;
class ImportExportTest extends \MailPoetTest {
@ -63,7 +64,7 @@ class ImportExportTest extends \MailPoetTest {
private function createTask($type, $status = null, $scheduled_at = null) {
if (!$scheduled_at) {
Carbon::createFromTimestamp(current_time('timestamp'));
Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'));
}
$task = ScheduledTask::create();
$task->type = $type;

View File

@ -495,8 +495,8 @@ class NewslettersTest extends \MailPoetTest {
$newsletter_option_field->name = 'schedule';
$newsletter_option_field->newsletter_type = Newsletter::TYPE_NOTIFICATION;
$newsletter_option_field->save();
$schedule = sprintf('0 %d * * *', Carbon::createFromTimestamp(current_time('timestamp'))->hour); // every day at current hour
$random_future_date = Carbon::createFromTimestamp(current_time('timestamp'))->addDays(10)->format('Y-m-d H:i:s'); // 10 days from now
$schedule = sprintf('0 %d * * *', Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'))->hour); // every day at current hour
$random_future_date = Carbon::createFromTimestamp(WPFunctions::get()->currentTime('timestamp'))->addDays(10)->format('Y-m-d H:i:s'); // 10 days from now
$newsletter_option = NewsletterOption::createOrUpdate(
[
'newsletter_id' => $this->post_notification->id,