Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Baños Fariñas <diegobanosfarinas@gmail.com>2019-03-04 03:07:02 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2019-03-04 03:07:02 +0300
commiteb76c695a5a9d77c8a845f6c9694fb18f20b9400 (patch)
tree4ea2746323a50a7dee1253d68fd52d70c267cddf /tests/PHPUnit/Unit
parentfd2a9c15cc6b80a96599192c0edbccf5deeaecdd (diff)
GeoIP first will update the next day, then weekly/monthly after that. Fixes #11006 (#11659)
* Feature: GeoIP first update will be the next day. Then Monthly or Weekly * Get unit test to pass.
Diffstat (limited to 'tests/PHPUnit/Unit')
-rw-r--r--tests/PHPUnit/Unit/DateTest.php11
-rw-r--r--tests/PHPUnit/Unit/Scheduler/SchedulerTest.php19
-rw-r--r--tests/PHPUnit/Unit/Scheduler/TimetableTest.php22
3 files changed, 51 insertions, 1 deletions
diff --git a/tests/PHPUnit/Unit/DateTest.php b/tests/PHPUnit/Unit/DateTest.php
index 3e27f0c8a3..990dbf4c40 100644
--- a/tests/PHPUnit/Unit/DateTest.php
+++ b/tests/PHPUnit/Unit/DateTest.php
@@ -51,6 +51,17 @@ class DateTest extends \PHPUnit_Framework_TestCase
}
/**
+ * create tomorrow object check that timestamp is correct (midnight)
+ *
+ * @group Core
+ */
+ public function testTomorrow()
+ {
+ $date = Date::tomorrow();
+ $this->assertEquals(strtotime(date("Y-m-d ", strtotime('+1day')) . " 00:00:00"), $date->getTimestamp());
+ }
+
+ /**
* create today object check that timestamp is correct (midnight)
*
* @group Core
diff --git a/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php b/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php
index 236b8eb8ed..8fe3589803 100644
--- a/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/SchedulerTest.php
@@ -8,6 +8,7 @@
namespace Piwik\Tests\Unit\Scheduler;
+use Piwik\Date;
use Piwik\Plugin;
use Piwik\Scheduler\Scheduler;
use Piwik\Scheduler\Task;
@@ -58,6 +59,24 @@ class SchedulerTest extends \PHPUnit_Framework_TestCase
self::resetPiwikOption();
}
+ public function testRescheduleTaskAndRunTomorrow()
+ {
+ $timetable = serialize(self::getTestTimetable());
+ self::stubPiwikOption($timetable);
+
+ $plugin = new Plugin();
+ $task = new Task($plugin, 'getVersion', null, null);
+
+ $taskLoader = $this->getMockBuilder('Piwik\Scheduler\TaskLoader')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $scheduler = new Scheduler($taskLoader, new NullLogger());
+
+ $scheduler->rescheduleTaskAndRunTomorrow($task);
+
+ $this->assertEquals(Date::factory('tomorrow')->getTimeStamp(), $scheduler->getScheduledTimeForMethod(Plugin::class, 'getVersion', null));
+ }
+
/**
* Dataprovider for testRun
*/
diff --git a/tests/PHPUnit/Unit/Scheduler/TimetableTest.php b/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
index dfd4c1f414..0be402cec4 100644
--- a/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
+++ b/tests/PHPUnit/Unit/Scheduler/TimetableTest.php
@@ -8,7 +8,9 @@
namespace Piwik\Tests\Unit\Scheduler;
+use Piwik\Date;
use Piwik\Plugin;
+use Piwik\Scheduler\Task;
use Piwik\Scheduler\Timetable;
use Piwik\Tests\Framework\Mock\PiwikOption;
use ReflectionProperty;
@@ -23,6 +25,11 @@ class TimetableTest extends \PHPUnit_Framework_TestCase
'PrivacyManager.deleteReportData_1' => 1322229607,
);
+ public function tearDown()
+ {
+ self::resetPiwikOption();
+ }
+
/**
* Dataprovider for testGetTimetableFromOptionValue
*/
@@ -57,8 +64,21 @@ class TimetableTest extends \PHPUnit_Framework_TestCase
$timetable = new Timetable();
$this->assertEquals($expectedTimetable, $timetable->getTimetable());
+ }
- self::resetPiwikOption();
+ public function testRescheduleTaskAndRunTomorrow()
+ {
+ self::stubPiwikOption(serialize([]));
+
+ $timetable = new Timetable();
+ $task = $this->getMockBuilder(Task::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $task->method('getName')->willReturn('taskName');
+
+ $timetable->rescheduleTaskAndRunTomorrow($task);
+
+ $this->assertEquals(Date::factory('tomorrow')->getTimeStamp(), $timetable->getTimetable()[$task->getName()]);
}
/**