diff --git a/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js b/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js index 537925358918c2b3d72dd6e846f06810f842cd1a..d90620053feccaefe817bb4402b2b623c720800b 100644 --- a/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js +++ b/plugins/CoreHome/angularjs/common/directives/autocomplete-matched.js @@ -37,7 +37,7 @@ return; } - var content = element.text(); + var content = piwik.helper.htmlEntities(element.text()); var startTerm = content.toLowerCase().indexOf(searchTerm.toLowerCase()); if (-1 !== startTerm) { diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php index 87162291165827780dcc9dc44ae13769d01f7a87..0c8533885035948880134a44e01dee4b2ba3f534 100644 --- a/plugins/Monolog/tests/System/TrackerLoggingTest.php +++ b/plugins/Monolog/tests/System/TrackerLoggingTest.php @@ -12,6 +12,7 @@ use Piwik\Config; use Piwik\Date; use Piwik\Tests\Framework\Fixture; use Piwik\Tests\Framework\TestCase\SystemTestCase; +use Piwik\Tests\Framework\TestingEnvironmentVariables; use PiwikTracker; /** @@ -82,7 +83,7 @@ DEBUG: 'apiv' => '1',", $response); private function setTrackerConfig($trackerConfig) { - $testingEnvironment = self::$fixture->getTestEnvironment(); + $testingEnvironment = new TestingEnvironmentVariables(); $testingEnvironment->overrideConfig('Tracker', $trackerConfig); $testingEnvironment->overrideConfig('log', 'log_writers', array('screen')); $testingEnvironment->save(); diff --git a/tests/PHPUnit/Fixtures/InvalidVisits.php b/tests/PHPUnit/Fixtures/InvalidVisits.php index 5518a7a163f3689f0d595f1346fdbb4d27221588..da1038eba2e5133568d74b9665d1c4080ba18cd7 100644 --- a/tests/PHPUnit/Fixtures/InvalidVisits.php +++ b/tests/PHPUnit/Fixtures/InvalidVisits.php @@ -112,6 +112,12 @@ class InvalidVisits extends Fixture $t->setUrl("http://their.stuff.com/back/to/the/future"); $t->doTrackPageView("ignored, not from my.stuff.com"); + // undo exclude unknown urls change (important when multiple fixtures are setup together, as is done in OmniFixture) + API::getInstance()->updateSite($idSite, $siteName = null, $urls, $ecommerce = null, $siteSearch = null, + $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParams = null, + $timezone = null, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, + $keepUrlFragments = null, $type = null, $settings = null, $excludeUnknownUrls = 0); + try { @$t->setAttributionInfo(array()); self::fail(); diff --git a/tests/PHPUnit/Fixtures/OmniFixture.php b/tests/PHPUnit/Fixtures/OmniFixture.php index 3c083130188f79e9203449a7fcb1d8bdd06078be..800a4e48bf60a9b021fb95b128429e565ea249d0 100644 --- a/tests/PHPUnit/Fixtures/OmniFixture.php +++ b/tests/PHPUnit/Fixtures/OmniFixture.php @@ -7,13 +7,12 @@ */ namespace Piwik\Tests\Fixtures; +use Piwik\API\Request; use Piwik\Date; -use Piwik\Access; use Piwik\Option; 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\OverrideLogin; /** * This fixture is the combination of every other fixture defined by Piwik. Should be used @@ -21,15 +20,24 @@ use Piwik\Tests\Framework\OverrideLogin; */ class OmniFixture extends Fixture { + const DEFAULT_SEGMENT = "browserCode==FF"; + public $month = '2012-01'; public $idSite = 'all'; public $dateTime = '2012-02-01'; + + /** + * @var Date + */ public $now = null; - public $segment = "browserCode==FF"; + public $segment = self::DEFAULT_SEGMENT; // Visitor profile screenshot test needs visitor id public $visitorIdDeterministic = null; + /** + * @var Fixture[] + */ public $fixtures = array(); private function requireAllFixtures() @@ -111,18 +119,18 @@ class OmniFixture extends Fixture public function setUp() { + $firstFixture = array_shift($this->fixtures); + $this->setUpFixture($firstFixture); + + $initialSitesProperties = SitesManagerAPI::getInstance()->getAllSites(); + 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()); - - // launch archiving so tests don't run out of time - $date = Date::factory($this->dateTime)->toString(); - VisitsSummaryAPI::getInstance()->get($this->idSite, 'year', $date); - VisitsSummaryAPI::getInstance()->get($this->idSite, 'year', $date, urlencode($this->segment)); } public function tearDown() @@ -133,4 +141,34 @@ class OmniFixture extends Fixture $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) { + Request::processRequest('SitesManager.updateSite', array( + 'idSite' => $idSite, + 'siteName' => $properties['name'], + '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'], + 'excludeUnknownUrls' => $properties['exclude_unknown_urls'] + )); + } + } } \ No newline at end of file diff --git a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php index a32129c93b6919707d093ff3a1986505a1f395e8..03cb78f9da22073a93ab9d2df5ea703dd7fb8bcc 100644 --- a/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php +++ b/tests/PHPUnit/Fixtures/SomeVisitsCustomVariablesCampaignsNotHeuristics.php @@ -10,6 +10,7 @@ namespace Piwik\Tests\Fixtures; use Piwik\Date; use Piwik\Plugins\Goals\API; use Piwik\Tests\Framework\Fixture; +use Piwik\Tests\Framework\TestingEnvironmentVariables; use PiwikTracker; /** @@ -36,7 +37,7 @@ class SomeVisitsCustomVariablesCampaignsNotHeuristics extends Fixture private function setPiwikEnvironmentOverrides() { - $env = $this->getTestEnvironment(); + $env = new TestingEnvironmentVariables(); $env->overrideConfig('Tracker', 'create_new_visit_when_website_referrer_changes', 1); $env->save(); } diff --git a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php index ed0647f64cd83a4d2e6eeb45eb602ed55147787e..3a91bf6a91e6ae6b1448f022d54cae81ac0be676 100644 --- a/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php +++ b/tests/PHPUnit/Fixtures/SomeVisitsManyPageviewsWithTransitions.php @@ -9,6 +9,7 @@ namespace Piwik\Tests\Fixtures; use Piwik\Date; use Piwik\Tests\Framework\Fixture; +use PiwikTracker; /** * Adds one site and tracks a couple visits with many pageviews. The diff --git a/tests/PHPUnit/Fixtures/SqlDump.php b/tests/PHPUnit/Fixtures/SqlDump.php index b360d162b31d2f6830256df1b9e1f10fa2c01f54..f5ebc7b364bcfb3792a8e9c03d47cb239d365a98 100644 --- a/tests/PHPUnit/Fixtures/SqlDump.php +++ b/tests/PHPUnit/Fixtures/SqlDump.php @@ -13,6 +13,7 @@ use Piwik\Config; use Piwik\Db; use Piwik\Tests\Framework\Fixture; use Exception; +use Piwik\Tests\Framework\TestingEnvironmentVariables; /** * Reusable fixture. Loads a SQL dump into the DB. @@ -74,12 +75,13 @@ class SqlDump extends Fixture // reload access Access::getInstance()->reloadAccess(); - $this->getTestEnvironment()->configOverride = array( + $testVars = new TestingEnvironmentVariables(); + $testVars->configOverride = array( 'database' => array( 'tables_prefix' => $this->tablesPrefix ) ); - $this->getTestEnvironment()->save(); + $testVars->save(); } /** diff --git a/tests/PHPUnit/Fixtures/UITestFixture.php b/tests/PHPUnit/Fixtures/UITestFixture.php index a1d2d316d07b695773fcae3347b78950426f9c56..4b780215d788d499829fd550b0edf98a9280e73f 100644 --- a/tests/PHPUnit/Fixtures/UITestFixture.php +++ b/tests/PHPUnit/Fixtures/UITestFixture.php @@ -71,13 +71,14 @@ class UITestFixture extends SqlDump // create non super user UsersManagerAPI::getInstance()->addUser('oliverqueen', 'smartypants', 'oli@queenindustries.com'); UsersManagerAPI::getInstance()->setUserAccess('oliverqueen', 'view', array(1)); - - // launch archiving so UI test requests don't launch it - VisitsSummaryAPI::getInstance()->get('all', 'year', '2012-08-09'); } public function performSetUp($setupEnvironmentOnly = false) { + $this->extraTestEnvVars = array( + 'loadRealTranslations' => 1, + ); + parent::performSetUp($setupEnvironmentOnly); $this->createSegments(); @@ -98,6 +99,12 @@ class UITestFixture extends SqlDump $this->testEnvironment->forcedNowTimestamp = $forcedNowTimestamp; $this->testEnvironment->save(); + + // launch archiving so tests don't run out of time + print("Archiving in fixture set up..."); + VisitsSummaryAPI::getInstance()->get('all', 'year', '2012-08-09'); + VisitsSummaryAPI::getInstance()->get('all', 'year', '2012-08-09', urlencode(OmniFixture::DEFAULT_SEGMENT)); + print("Done."); } private function addOverlayVisits() diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index f421ba56583e87c1450355aced28f40f0bdcf70e..3f66bd3a76cdfcc9632c3f6eaad98e377580694b 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -199,6 +199,7 @@ class Fixture extends \PHPUnit_Framework_Assert } $testEnv = $this->getTestEnvironment(); + $testEnv->delete(); $testEnv->testCaseClass = $this->testCaseClass; $testEnv->fixtureClass = get_class($this); $testEnv->dbName = $this->dbName; @@ -303,11 +304,16 @@ class Fixture extends \PHPUnit_Framework_Assert } } + /** + * NOTE: This method should not be used to get a TestingEnvironmentVariables instance. + * Instead just create a new instance. + * + * @return null|\Piwik\Tests\Framework\TestingEnvironmentVariables + */ public function getTestEnvironment() { if ($this->testEnvironment === null) { $this->testEnvironment = new TestingEnvironmentVariables(); - $this->testEnvironment->delete(); if (getenv('PIWIK_USE_XHPROF') == 1) { $this->testEnvironment->useXhprof = true; diff --git a/tests/UI/expected-ui-screenshots b/tests/UI/expected-ui-screenshots index ca74ae5a19497d8678a8e5547834b07a6e2430d6..0409057f3ca667da3f65c7dd928fa7f4acb6f348 160000 --- a/tests/UI/expected-ui-screenshots +++ b/tests/UI/expected-ui-screenshots @@ -1 +1 @@ -Subproject commit ca74ae5a19497d8678a8e5547834b07a6e2430d6 +Subproject commit 0409057f3ca667da3f65c7dd928fa7f4acb6f348 diff --git a/tests/UI/specs/PivotByDimension_spec.js b/tests/UI/specs/PivotByDimension_spec.js index f1899f34850ac7df6f18c02017d67cc9f8e88092..d04d420043a22b2a18350f5fa6287540c93a2366 100644 --- a/tests/UI/specs/PivotByDimension_spec.js +++ b/tests/UI/specs/PivotByDimension_spec.js @@ -22,6 +22,7 @@ describe("PivotByDimension", function () { page.click('.expandDataTableFooterDrawer'); page.mouseMove('.tableConfiguration'); page.click('.dataTablePivotBySubtable'); + page.mouseMove({x: -15, y: -15}); // make sure nothing is highlighted }, done); }); @@ -35,6 +36,7 @@ describe("PivotByDimension", function () { page.click('.expandDataTableFooterDrawer'); page.mouseMove('.tableConfiguration'); page.click('.dataTablePivotBySubtable'); + page.mouseMove({x: -15, y: -15}); // make sure nothing is highlighted }, done); }); }); \ No newline at end of file diff --git a/tests/UI/specs/UIIntegration_spec.js b/tests/UI/specs/UIIntegration_spec.js index 888391e81c9df41de9cde3f9cd3b9d9f4ac6a0e2..65fa37d721ca099f72e8479c77d05d9803cc59f4 100644 --- a/tests/UI/specs/UIIntegration_spec.js +++ b/tests/UI/specs/UIIntegration_spec.js @@ -164,6 +164,9 @@ describe("UIIntegrationTest", function () { // TODO: Rename to Piwik? page.load("?" + urlBase + "#" + generalParams + "&module=Actions&action=menuGetPageUrls"); page.mouseMove('h2[piwik-enriched-headline]'); page.click(".helpIcon"); + page.evaluate(function () { + $('.helpDate:visible').hide(); + }); }, done); }); diff --git a/tests/UI/specs/ViewDataTable_spec.js b/tests/UI/specs/ViewDataTable_spec.js index 279fe010f683f95fa047a0b860e3279a64ec6a50..4dc412cad728fb694045b19a8c2ec626fd94b4e2 100644 --- a/tests/UI/specs/ViewDataTable_spec.js +++ b/tests/UI/specs/ViewDataTable_spec.js @@ -53,7 +53,7 @@ describe("ViewDataTableTest", function () { // TODO: should remove Test suffix f it("should load bar graph when bar graph footer icon clicked", function (done) { expect.screenshot('6_bar_graph').to.be.capture(function (page) { - page.mouseMove('.tableIconsGroup:nth-child(2)'); + page.mouseMove('.tableIconsGroup:nth-child(3)'); page.click('.tableIcon[data-footer-icon-id=graphVerticalBar]'); }, done); }); @@ -67,7 +67,7 @@ describe("ViewDataTableTest", function () { // TODO: should remove Test suffix f it("should load a tag cloud when tag cloud footer icon clicked", function (done) { expect.screenshot('8_tag_cloud').to.be.capture(function (page) { - page.mouseMove('.tableIconsGroup:nth-child(2)'); + page.mouseMove('.tableIconsGroup:nth-child(3)'); page.click('.tableIcon[data-footer-icon-id=cloud]'); }, done); }); @@ -75,6 +75,7 @@ describe("ViewDataTableTest", function () { // TODO: should remove Test suffix f it("should load normal table when normal table footer icon clicked", function (done) { expect.screenshot('9_normal_table').to.be.capture(function (page) { page.click('.tableIcon[data-footer-icon-id=table]'); + page.mouseMove({x: -10, y: -10}); // mae sure no row is highlighted }, done); }); diff --git a/tests/resources/OmniFixture-dump.sql.gz b/tests/resources/OmniFixture-dump.sql.gz index 5466a04b88eff16674db492483296b928196407d..80f9e7678ec293862d80c5c4ca3bc2f4bde6e5ac 100644 Binary files a/tests/resources/OmniFixture-dump.sql.gz and b/tests/resources/OmniFixture-dump.sql.gz differ