diff options
author | dizzy <diosmosis@users.noreply.github.com> | 2021-04-12 06:23:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 06:23:28 +0300 |
commit | 5573d22a459d65749ebdfc257ac773979ae12ea4 (patch) | |
tree | d3eac59ac3228b0e31848ab170bea793c43b03a5 /tests/PHPUnit/Framework | |
parent | 375af64031844e6161d8ce6e778da304e0680230 (diff) |
Initiate range archiving if an archive is invalidated, the request is from the browser, and browser archiving is authorized (#17379)
* Initiate archiving if an archive is invalidated, the request is from the browser, and browser archiving for the current request is authorized.
* add test that was strangely removed and add tests for period = range
* Add test for tracking data in the past and fix invalidation issue in core:archive.
* Add test for default use case of core:archive w/ browser initiated range archiving.
* actually just dont perform the check if the period does not include today
* undo isPeriodIncludesToday change
* Fix ArchiveInvalidationTest and get to work, fix bug in Loader causing it to fail
* fix tests
* add comment to test
* Fix CronArchiveTest, make sure we do not use a TTL when running invalidateRecentDate("yesterday").
* tweak comment
* make sure invalid ranges only rearchive when authorized to rearchive child archive or when all child archives are usable while still respecting ttl for periods that include today
* instead of previous change, make range ttl get respected if range period is used and archiving is enabled for the current request/period
* remove dead code + tweak test
* add check for invalidated archive
* move new invalidation check to Loader from ArchiveSelector since getArchiveIdAndVisits is used in multiple code paths now
* remove TODO
* remove use
* apply pr feedback
* get tests to pass
* Fix strange test failure on travis-ci (class was loaded before mock file methods used in next test were loaded)
Diffstat (limited to 'tests/PHPUnit/Framework')
-rw-r--r-- | tests/PHPUnit/Framework/Fixture.php | 2 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestCase/SystemTestCase.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/Framework/TestingEnvironmentVariables.php | 5 |
3 files changed, 13 insertions, 0 deletions
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index 9358b9d8c6..fefe641240 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -48,6 +48,7 @@ use Piwik\Singleton; use Piwik\Site; use Piwik\Tests; use Piwik\Tests\Framework\Mock\FakeAccess; +use Piwik\Tests\Framework\Mock\File as MockFileMethods; use Piwik\Tests\Framework\TestCase\SystemTestCase; use Piwik\Tracker; use Piwik\Tracker\Cache; @@ -393,6 +394,7 @@ class Fixture extends \PHPUnit\Framework\Assert Date::$now = null; FrontController::$requestId = null; Cache::$cache = null; + MockFileMethods::reset(); Archive::clearStaticCache(); DataTableManager::getInstance()->deleteAll(); Option::clearCache(); diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php index 802b22ecf5..85a2e85326 100644 --- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php @@ -25,6 +25,7 @@ use Piwik\ReportRenderer; use Piwik\Site; use Piwik\Tests\Framework\Constraint\ResponseCode; use Piwik\Tests\Framework\Constraint\HttpResponseText; +use Piwik\Tests\Framework\Mock\File as MockFileMethods; use Piwik\Tests\Framework\TestRequest\ApiTestConfig; use Piwik\Tests\Framework\TestRequest\Collection; use Piwik\Tests\Framework\TestRequest\Response; @@ -75,6 +76,11 @@ abstract class SystemTestCase extends TestCase { Log::debug("Setting up " . get_called_class()); + // NOTE: it is important to reference this class in a test framework class like Fixture so the mocks + // will be loaded before any testable classed load, otherwise some tests may fail w/o any obvious reason. + // (the actual reason being ) + MockFileMethods::reset(); + if (!isset(static::$fixture)) { $fixture = new Fixture(); } else { diff --git a/tests/PHPUnit/Framework/TestingEnvironmentVariables.php b/tests/PHPUnit/Framework/TestingEnvironmentVariables.php index 697caf7a95..b14cd693f3 100644 --- a/tests/PHPUnit/Framework/TestingEnvironmentVariables.php +++ b/tests/PHPUnit/Framework/TestingEnvironmentVariables.php @@ -84,6 +84,11 @@ class TestingEnvironmentVariables $this->configOverride = $config; } + public function removeOverriddenConfig($group, $name) + { + unset($this->configOverride[$group][$name]); + } + public function save() { $includePath = __DIR__ . '/../../..'; |