Skip to content
Extraits de code Groupes Projets
Valider 6fdf3c30 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

When generating the OmniFixture dump, restore site properties to their initial...

When generating the OmniFixture dump, restore site properties to their initial values before setting up each initial fixture. Ensures that changes to site properties by fixtures are reset before setting up the next fixture.
parent 1a13eb84
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -8,12 +8,10 @@ ...@@ -8,12 +8,10 @@
namespace Piwik\Tests\Fixtures; namespace Piwik\Tests\Fixtures;
use Piwik\Date; use Piwik\Date;
use Piwik\Access;
use Piwik\Option; use Piwik\Option;
use ReflectionClass; use ReflectionClass;
use Piwik\Plugins\VisitsSummary\API as VisitsSummaryAPI; use Piwik\Plugins\SitesManager\API as SitesManagerAPI;
use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\Fixture;
use Piwik\Tests\Framework\OverrideLogin;
/** /**
* This fixture is the combination of every other fixture defined by Piwik. Should be used * This fixture is the combination of every other fixture defined by Piwik. Should be used
...@@ -120,10 +118,15 @@ class OmniFixture extends Fixture ...@@ -120,10 +118,15 @@ class OmniFixture extends Fixture
public function setUp() public function setUp()
{ {
$firstFixture = array_shift($this->fixtures);
$this->setUpFixture($firstFixture);
$initialSitesProperties = SitesManagerAPI::getInstance()->getAllSites();
foreach ($this->fixtures as $fixture) { foreach ($this->fixtures as $fixture) {
echo "Setting up " . get_class($fixture) . "...\n"; $this->restoreSitesProperties($initialSitesProperties);
$fixture->setUp(); $this->setUpFixture($fixture);
} }
Option::set("Tests.forcedNowTimestamp", $this->now->getTimestamp()); Option::set("Tests.forcedNowTimestamp", $this->now->getTimestamp());
...@@ -137,4 +140,36 @@ class OmniFixture extends Fixture ...@@ -137,4 +140,36 @@ class OmniFixture extends Fixture
$fixture->tearDown(); $fixture->tearDown();
} }
} }
private function setUpFixture(Fixture $fixture)
{
echo "Setting up " . get_class($fixture) . "...\n";
$fixture->setUp();
}
private function restoreSitesProperties($initialSitesProperties)
{
foreach ($initialSitesProperties as $idSite => $properties) {
SitesManagerAPI::getInstance()->updateSite(
$idSite,
$siteName = $properties['name'],
$urls = $properties[''],
$ecommerce = $properties['ecommerce'],
$siteSearch = $properties['sitesearch'],
$searchKeywordParameters = $properties['sitesearch_keyword_parameters'],
$searchCategoryParameters = $properties['sitesearch_category_parameters'],
$excludedIps = $properties['excluded_ips'],
$excludedQueryParameters = $properties['excluded_parameters'],
$timezone = $properties['timezone'],
$currency = $properties['currency'],
$group = $properties['group'],
$startDate = $properties['ts_created'],
$excludedUserAgents = $properties['excluded_user_agents'],
$keepURLFragments = $properties['keep_url_fragment'],
$type = $properties['type'],
$settings = null,
$excludeUnknownUrls = $properties['exclude_unknown_urls']
);
}
}
} }
\ No newline at end of file
Le fichier a été supprimé par une entrée .gitattributes, ou son encodage n'est pas pris en charge.
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter