Skip to content

Commit

Permalink
in AutoSuggestAPITest, make sure static var overrides are undone afte…
Browse files Browse the repository at this point in the history
…r the test finishes (#20828)
  • Loading branch information
diosmosis authored Jun 5, 2023
1 parent 24e2ac9 commit a727364
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions plugins/API/tests/System/AutoSuggestAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,32 @@ class AutoSuggestAPITest extends SystemTestCase
{
public static $fixture = null; // initialized below class definition

private static $originalAutoSuggestLookBack = null;

protected static $processed = 0;
protected static $skipped = array();
private static $hasArchivedData = false;

public static function setUpBeforeClass(): void
{
$date = mktime(0, 0, 0, 1, 1, 2018);

$lookBack = ceil((time() - $date) / 86400);

self::$originalAutoSuggestLookBack = API::$_autoSuggestLookBack;

API::$_autoSuggestLookBack = $lookBack;
self::$fixture->dateTime = Date::factory($date)->getDatetime();

parent::setUpBeforeClass();

API::setSingletonInstance(CachedAPI::getInstance());
}

public static function tearDownAfterClass(): void
{
API::$_autoSuggestLookBack = self::$originalAutoSuggestLookBack;

parent::tearDownAfterClass();

CachedAPI::$cache = [];
Expand Down Expand Up @@ -293,11 +306,4 @@ public static function getPathToTestDirectory()
}
}

$date = mktime(0, 0, 0, 1, 1, 2018);

$lookBack = ceil((time() - $date) / 86400);

API::$_autoSuggestLookBack = $lookBack;

\Piwik\Plugins\API\tests\System\AutoSuggestAPITest::$fixture = new ManyVisitsWithGeoIPAndEcommerce();
\Piwik\Plugins\API\tests\System\AutoSuggestAPITest::$fixture->dateTime = Date::factory($date)->getDatetime();

0 comments on commit a727364

Please sign in to comment.