diff --git a/tests/PHPUnit/Integration/ArchiveTest.php b/tests/PHPUnit/Integration/ArchiveTest.php index d90132c768cb..6c324af966b3 100644 --- a/tests/PHPUnit/Integration/ArchiveTest.php +++ b/tests/PHPUnit/Integration/ArchiveTest.php @@ -292,8 +292,16 @@ public function test_shouldNotArchivePeriodsStartingInTheFuture() public function test_shouldArchivePeriodsStartingInTheFuture_IfWebSiteLocalTimeIsInNextDay() { // Create a site with a timezone ahead of UTC - $idSite = Fixture::createWebsite('2014-05-06', 1, false, false, - 1, null, null, 'Pacific/Auckland'); + $idSite = Fixture::createWebsite( + '2014-05-06', + 1, + false, + false, + 1, + null, + null, + 'Pacific/Auckland' + ); self::$fixture->getTestEnvironment()->overrideConfig('General', 'browser_archiving_disabled_enforce', 0); self::$fixture->getTestEnvironment()->overrideConfig('General', 'archiving_range_force_on_browser_request', 1); @@ -348,8 +356,16 @@ public function test_shouldNotArchivePeriodsStartingInTheFuture_IfWebSiteLocalTi { // Create a site with a timezone behind of UTC - $idSite = Fixture::createWebsite('2014-05-06', 1, false, false, - 1, null, null, 'America/Vancouver'); // -8hrs + $idSite = Fixture::createWebsite( + '2014-05-06', + 1, + false, + false, + 1, + null, + null, + 'America/Vancouver' + ); // -8hrs self::$fixture->getTestEnvironment()->overrideConfig('General', 'browser_archiving_disabled_enforce', 0); self::$fixture->getTestEnvironment()->overrideConfig('General', 'archiving_range_force_on_browser_request', 1); diff --git a/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php b/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php index cd658a5ab9ec..7a65bf17a6c2 100644 --- a/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php +++ b/tests/PHPUnit/Integration/Concurrency/DistributedListTest.php @@ -140,9 +140,11 @@ private function initOptionValue($data = false) $data = $data ?: self::$defaultOptionValues; $optionTable = Common::prefixTable('option'); - Db::query("INSERT INTO `$optionTable` (option_name, option_value, autoload) VALUES (?, ?, ?) + Db::query( + "INSERT INTO `$optionTable` (option_name, option_value, autoload) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE option_value = ?", - array(self::TEST_OPTION_NAME, serialize($data), 0, serialize($data))); + array(self::TEST_OPTION_NAME, serialize($data), 0, serialize($data)) + ); } private function getOptionValueForList() diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php index 639a0d013d7e..78dd626cfcdc 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php @@ -138,8 +138,14 @@ public function test_markArchivesAsInvalidated_doesNotInvalidatePartialArchives( /** @var ArchiveInvalidator $archiveInvalidator */ $archiveInvalidator = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\Archive\ArchiveInvalidator'); - $archiveInvalidator->markArchivesAsInvalidated([1], ['2020-03-03'], 'day', - null, $cascadeDown = true, false); + $archiveInvalidator->markArchivesAsInvalidated( + [1], + ['2020-03-03'], + 'day', + null, + $cascadeDown = true, + false + ); $invalidatedArchives = $this->getInvalidatedArchives(); $this->assertEmpty($invalidatedArchives); @@ -603,8 +609,16 @@ public function test_markArchivesAsInvalidated_invalidatesPastPurgeThreshold_ifF /** @var ArchiveInvalidator $archiveInvalidator */ $archiveInvalidator = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\Archive\ArchiveInvalidator'); - $result = $archiveInvalidator->markArchivesAsInvalidated(array(1), array($dateBeforeThreshold), 'day', - null, false, false, null, true); + $result = $archiveInvalidator->markArchivesAsInvalidated( + array(1), + array($dateBeforeThreshold), + 'day', + null, + false, + false, + null, + true + ); $this->assertEquals($thresholdDate->toString(), $result->minimumDateWithLogs); @@ -1730,8 +1744,16 @@ public function test_markArchivesAsInvalidated_invalidatesIndividualPluginNames( ]; $plugin = 'ExamplePlugin'; - $this->test_markArchivesAsInvalidated_MarksCorrectArchivesAsInvalidated($idSites, $dates, $period, $segment, $cascadeDown, $expectedIdArchives, - $expectedInvalidatedArchives, $plugin); + $this->test_markArchivesAsInvalidated_MarksCorrectArchivesAsInvalidated( + $idSites, + $dates, + $period, + $segment, + $cascadeDown, + $expectedIdArchives, + $expectedInvalidatedArchives, + $plugin + ); } public function test_markArchivesAsInvalidated_invalidatesIndividualReports() @@ -1750,8 +1772,16 @@ public function test_markArchivesAsInvalidated_invalidatesIndividualReports() ]; $report = 'ExamplePlugin.someReport'; - $this->test_markArchivesAsInvalidated_MarksCorrectArchivesAsInvalidated($idSites, $dates, $period, $segment, $cascadeDown, $expectedIdArchives, - $expectedInvalidatedArchives, $report); + $this->test_markArchivesAsInvalidated_MarksCorrectArchivesAsInvalidated( + $idSites, + $dates, + $period, + $segment, + $cascadeDown, + $expectedIdArchives, + $expectedInvalidatedArchives, + $report + ); } public function test_markArchivesAsInvalidated_doesNotInsertDuplicateInvalidations() @@ -1785,10 +1815,22 @@ public function test_markArchivesAsInvalidated_doesNotInsertDuplicateInvalidatio $this->insertInvalidations($existingInvalidations); - $archiveInvalidator->markArchivesAsInvalidated([1], ['2020-03-04', '2020-05-06'], 'week', - $segment, $cascadeDown = true, false); - $archiveInvalidator->markArchivesAsInvalidated([1], ['2020-05-01'], 'year', - $segment, $cascadeDown = false, 'aReport'); + $archiveInvalidator->markArchivesAsInvalidated( + [1], + ['2020-03-04', '2020-05-06'], + 'week', + $segment, + $cascadeDown = true, + false + ); + $archiveInvalidator->markArchivesAsInvalidated( + [1], + ['2020-05-01'], + 'year', + $segment, + $cascadeDown = false, + 'aReport' + ); $expectedInvalidations = [ array ( diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php index 4aef1966620d..8b54b49ef361 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php @@ -61,8 +61,14 @@ public function test_getArchiveIds_handlesCutOffGroupConcat() $this->insertArchiveData($archiveRows); - $archiveIds = ArchiveSelector::getArchiveIds([1], [Factory::build('day', '2020-03-01')], new Segment('', [1]), ['Funnels'], - true, true); + $archiveIds = ArchiveSelector::getArchiveIds( + [1], + [Factory::build('day', '2020-03-01')], + new Segment('', [1]), + ['Funnels'], + true, + true + ); $expected = [ 'done.Funnels' => [ @@ -167,8 +173,10 @@ private function insertArchiveData($archiveRows) $d = Date::factory($row['date1']); $table = !empty($row['is_blob_data']) ? ArchiveTableCreator::getBlobTable($d) : ArchiveTableCreator::getNumericTable($d); $tsArchived = isset($row['ts_archived']) ? $row['ts_archived'] : Date::now()->getDatetime(); - Db::query("INSERT INTO `$table` (idarchive, idsite, period, date1, date2, `name`, `value`, ts_archived) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [$row['idarchive'], $row['idsite'], $row['period'], $row['date1'], $row['date2'], $row['name'], $row['value'], $tsArchived]); + Db::query( + "INSERT INTO `$table` (idarchive, idsite, period, date1, date2, `name`, `value`, ts_archived) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + [$row['idarchive'], $row['idsite'], $row['period'], $row['date1'], $row['date2'], $row['name'], $row['value'], $tsArchived] + ); } } diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php index d5c6f553c1ca..fe0561db33ae 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php @@ -33,7 +33,8 @@ public function setUp(): void parent::setUp(); $this->archiveTableDao = self::$fixture->piwikEnvironment->getContainer()->get( - 'Piwik\DataAccess\ArchiveTableDao'); + 'Piwik\DataAccess\ArchiveTableDao' + ); ArchiveTableCreator::getBlobTable(Date::factory('2015-01-01')); ArchiveTableCreator::getNumericTable(Date::factory('2015-01-01')); @@ -50,35 +51,101 @@ public function test_getArchiveTableAnalysis_QueriesNumericAndBlobTable_Includin $this->insertArchive($tableMonth, $idSite = 2, $period = 'day', $date1 = '2015-01-03', $date2 = '2015-01-03'); $this->insertArchive($tableMonth, $idSite = 1, $period = 'week', $date1 = '2015-01-04', $date2 = '2015-01-11'); $this->insertArchive($tableMonth, $idSite = 3, $period = 'month', $date1 = '2015-01-01', $date2 = '2015-01-31'); - $this->insertArchive($tableMonth, $idSite = 4, $period = 'year', $date1 = '2015-01-01', $date2 = '2015-12-31', - $segment = 'browserCode==FF'); + $this->insertArchive( + $tableMonth, + $idSite = 4, + $period = 'year', + $date1 = '2015-01-01', + $date2 = '2015-12-31', + $segment = 'browserCode==FF' + ); $this->insertArchive($tableMonth, $idSite = 1, $period = 'range', $date1 = '2015-01-15', $date2 = '2015-01-20'); // invalid - $this->insertArchive($tableMonth, $idSite = 1, $period = 'day', $date1 = '2015-01-01', $date2 = '2015-01-01', - $segment = false, $doneValue = ArchiveWriter::DONE_INVALIDATED); - $this->insertArchive($tableMonth, $idSite = 1, $period = 'day', $date1 = '2015-01-01', $date2 = '2015-01-01', - $segment = false, $doneValue = ArchiveWriter::DONE_INVALIDATED); - $this->insertArchive($tableMonth, $idSite = 4, $period = 'year', $date1 = '2015-01-01', $date2 = '2015-12-31', - $segment = 'browserCode==FF', $doneValue = ArchiveWriter::DONE_INVALIDATED); + $this->insertArchive( + $tableMonth, + $idSite = 1, + $period = 'day', + $date1 = '2015-01-01', + $date2 = '2015-01-01', + $segment = false, + $doneValue = ArchiveWriter::DONE_INVALIDATED + ); + $this->insertArchive( + $tableMonth, + $idSite = 1, + $period = 'day', + $date1 = '2015-01-01', + $date2 = '2015-01-01', + $segment = false, + $doneValue = ArchiveWriter::DONE_INVALIDATED + ); + $this->insertArchive( + $tableMonth, + $idSite = 4, + $period = 'year', + $date1 = '2015-01-01', + $date2 = '2015-12-31', + $segment = 'browserCode==FF', + $doneValue = ArchiveWriter::DONE_INVALIDATED + ); // temporary - $this->insertArchive($tableMonth, $idSite = 1, $period = 'week', $date1 = '2015-01-04', $date2 = '2015-01-11', - $segment = false, $doneValue = ArchiveWriter::DONE_OK_TEMPORARY); - $this->insertArchive($tableMonth, $idSite = 3, $period = 'month', $date1 = '2015-01-01', $date2 = '2015-01-31', - $segment = 'daysSinceFirstVisit==1', $doneValue = ArchiveWriter::DONE_OK_TEMPORARY); + $this->insertArchive( + $tableMonth, + $idSite = 1, + $period = 'week', + $date1 = '2015-01-04', + $date2 = '2015-01-11', + $segment = false, + $doneValue = ArchiveWriter::DONE_OK_TEMPORARY + ); + $this->insertArchive( + $tableMonth, + $idSite = 3, + $period = 'month', + $date1 = '2015-01-01', + $date2 = '2015-01-31', + $segment = 'daysSinceFirstVisit==1', + $doneValue = ArchiveWriter::DONE_OK_TEMPORARY + ); // error - $this->insertArchive($tableMonth, $idSite = 1, $period = 'week', $date1 = '2015-01-04', $date2 = '2015-01-11', - $segment = false, $doneValue = ArchiveWriter::DONE_ERROR); - $this->insertArchive($tableMonth, $idSite = 3, $period = 'month', $date1 = '2015-01-01', $date2 = '2015-01-31', - $segment = 'daysSinceFirstVisit==1', $doneValue = ArchiveWriter::DONE_ERROR); + $this->insertArchive( + $tableMonth, + $idSite = 1, + $period = 'week', + $date1 = '2015-01-04', + $date2 = '2015-01-11', + $segment = false, + $doneValue = ArchiveWriter::DONE_ERROR + ); + $this->insertArchive( + $tableMonth, + $idSite = 3, + $period = 'month', + $date1 = '2015-01-01', + $date2 = '2015-01-31', + $segment = 'daysSinceFirstVisit==1', + $doneValue = ArchiveWriter::DONE_ERROR + ); // blob only - $this->insertBlobArchive($tableMonth, $idSite = 1, $period = 'day', $date1 = '2015-01-20', - $date2 = '2015-01-20'); - $this->insertBlobArchive($tableMonth, $idSite = 2, $period = 'day', $date1 = '2015-01-21', - $date2 = '2015-01-21', $segment = 'browserCode==SF'); + $this->insertBlobArchive( + $tableMonth, + $idSite = 1, + $period = 'day', + $date1 = '2015-01-20', + $date2 = '2015-01-20' + ); + $this->insertBlobArchive( + $tableMonth, + $idSite = 2, + $period = 'day', + $date1 = '2015-01-21', + $date2 = '2015-01-21', + $segment = 'browserCode==SF' + ); $expectedStats = array( '1.2015-01-01.2015-01-01.1' => array( diff --git a/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php b/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php index 1dc8bff4436f..79a791c826bd 100644 --- a/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php +++ b/tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php @@ -306,8 +306,10 @@ private function insertArchiveData($archiveRows) $table = ArchiveTableCreator::getNumericTable($d); $tsArchived = isset($row['ts_archived']) ? $row['ts_archived'] : Date::now()->getDatetime(); - Db::query("INSERT INTO `$table` (idarchive, idsite, period, date1, date2, `name`, `value`, ts_archived) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", - [$row['idarchive'], $row['idsite'], $row['period'], $row['date1'], $row['date2'], $row['name'], $row['value'], $tsArchived]); + Db::query( + "INSERT INTO `$table` (idarchive, idsite, period, date1, date2, `name`, `value`, ts_archived) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", + [$row['idarchive'], $row['idsite'], $row['period'], $row['date1'], $row['date2'], $row['name'], $row['value'], $tsArchived] + ); } } diff --git a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php index 55d79792ad75..872b68bfab7f 100644 --- a/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php +++ b/tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php @@ -539,8 +539,16 @@ public function test_queryVisitsByDimension_ShouldAddJoinQueryHintOriginHintMaxE DatabaseConfig::setConfigValue('enable_first_table_join_prefix', '1'); $this->logAggregator->setQueryOriginHint('MyPluginName'); - $query = $this->logAggregator->getQueryByDimensionSql($dimensions, false, [], false, false, - false, 5, false); + $query = $this->logAggregator->getQueryByDimensionSql( + $dimensions, + false, + [], + false, + false, + false, + 5, + false + ); $expected = [ 'sql' => "SELECT /*+ MAX_EXECUTION_TIME(5000) */ /*+ JOIN_PREFIX(log_visit) */ /* sites 1 */ /* 2010-03-01,2010-03-31 */ /* MyPluginName */ diff --git a/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php b/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php index ccc56c4ff564..9a8136201f22 100644 --- a/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php +++ b/tests/PHPUnit/Integration/DataTable/Filter/PivotByDimensionTest.php @@ -211,8 +211,13 @@ public function test_filter_CorrectlyCreatesPivotTable_WhenSubtablesHaveNoRows() $table = $this->getTableToFilter(false); - $pivotFilter = new PivotByDimension($table, "CustomVariables.getCustomVariables", "CustomVariables.CustomVariableValue", - 'nb_visits', $fetchBySegment = false); + $pivotFilter = new PivotByDimension( + $table, + "CustomVariables.getCustomVariables", + "CustomVariables.CustomVariableValue", + 'nb_visits', + $fetchBySegment = false + ); $pivotFilter->filter($table); $expectedRows = array( diff --git a/tests/PHPUnit/Integration/DocumentationGeneratorTest.php b/tests/PHPUnit/Integration/DocumentationGeneratorTest.php index 076f3771667b..dd6eb235c483 100644 --- a/tests/PHPUnit/Integration/DocumentationGeneratorTest.php +++ b/tests/PHPUnit/Integration/DocumentationGeneratorTest.php @@ -41,30 +41,36 @@ public function test_CheckDocumentation() public function test_CheckIfMethodComment_ContainsHideAnnotation_andText() { $annotation = '@hideForAll test test'; - EventDispatcher::getInstance()->addObserver('API.DocumentationGenerator.@hideForAll', + EventDispatcher::getInstance()->addObserver( + 'API.DocumentationGenerator.@hideForAll', function (&$hide) { $hide = true; - }); + } + ); $this->assertEquals(Proxy::getInstance()->shouldHideAPIMethod($annotation), true); } public function test_CheckIfMethodComment_ContainsHideAnnotation_only() { $annotation = '@hideForAll'; - EventDispatcher::getInstance()->addObserver('API.DocumentationGenerator.@hideForAll', + EventDispatcher::getInstance()->addObserver( + 'API.DocumentationGenerator.@hideForAll', function (&$hide) { $hide = true; - }); + } + ); $this->assertEquals(Proxy::getInstance()->shouldHideAPIMethod($annotation), true); } public function test_CheckIfMethodComment_DoesNotContainHideAnnotation() { $annotation = '@not found here'; - EventDispatcher::getInstance()->addObserver('API.DocumentationGenerator.@hello', + EventDispatcher::getInstance()->addObserver( + 'API.DocumentationGenerator.@hello', function (&$hide) { $hide = true; - }); + } + ); $this->assertEquals(Proxy::getInstance()->shouldHideAPIMethod($annotation), false); } } diff --git a/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php b/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php index c8e7d26d339c..127807b89877 100644 --- a/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php +++ b/tests/PHPUnit/Integration/Measurable/MeasurableSettingsTest.php @@ -35,10 +35,17 @@ public function setUp(): void if (!Fixture::siteCreated($this->idSite)) { $type = WebsiteType::ID; - Fixture::createWebsite('2015-01-01 00:00:00', - $ecommerce = 0, $siteName = false, $siteUrl = false, - $siteSearch = 1, $searchKeywordParameters = null, - $searchCategoryParameters = null, $timezone = null, $type); + Fixture::createWebsite( + '2015-01-01 00:00:00', + $ecommerce = 0, + $siteName = false, + $siteUrl = false, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $timezone = null, + $type + ); } $this->settings = $this->createSettings(); diff --git a/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php b/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php index c78e3931308a..aa33eb46d04b 100644 --- a/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php +++ b/tests/PHPUnit/Integration/ProfessionalSupport/AdvertisingTest.php @@ -86,8 +86,13 @@ public function test_addPromoCampaignParametersToUrl_withoutContentWithoutQuery( public function test_addPromoCampaignParametersToUrl_withContentWithoutQuery() { - $link = $this->advertising->addPromoCampaignParametersToUrl($this->exampleUrl, 'MyName', 'Installation_Start', - 'MyContent', 'MySource'); + $link = $this->advertising->addPromoCampaignParametersToUrl( + $this->exampleUrl, + 'MyName', + 'Installation_Start', + 'MyContent', + 'MySource' + ); $this->assertSame($this->exampleUrl . '?mtm_campaign=MyName&mtm_source=MySource&mtm_medium=Installation_Start.MyContent', $link); } diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php index 091ce661a48d..1f101aaa1330 100644 --- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php @@ -262,11 +262,13 @@ private function assertFilesDoNotContain($files, $patternFailIfFound, $allowedFi } } - $this->assertEmpty($foundPatterns, - sprintf("Forbidden pattern \"%s\" was found in the following files ---> please manually delete these files from Git. \n\n\t%s", - $patternFailIfFound, - implode("\n\t", $foundPatterns) - ) + $this->assertEmpty( + $foundPatterns, + sprintf( + "Forbidden pattern \"%s\" was found in the following files ---> please manually delete these files from Git. \n\n\t%s", + $patternFailIfFound, + implode("\n\t", $foundPatterns) + ) ); } @@ -292,8 +294,11 @@ public function testCheckThatGivenPluginsAreDisabledByDefault() 'DBStats' ); foreach ($pluginsShouldBeDisabled as $pluginName) { - $this->assertNotContains($pluginName, $this->globalConfig['Plugins']['Plugins'], - "Plugin $pluginName is enabled by default but shouldn't."); + $this->assertNotContains( + $pluginName, + $this->globalConfig['Plugins']['Plugins'], + "Plugin $pluginName is enabled by default but shouldn't." + ); } } @@ -398,9 +403,11 @@ public function test_directoriesShouldBeChmod755() $chmod = substr(decoct(fileperms($pathToTest)), -3); $valid = array('777', '775', '755'); $command = "find $pluginsPath -type d -exec chmod 755 {} +"; - $this->assertTrue(in_array($chmod, $valid), - "Some directories within plugins/ are not chmod 755 \n\nGot: $chmod for : $pathToTest \n\n" . - "Run this command to set all directories to 755: \n$command\n"); + $this->assertTrue( + in_array($chmod, $valid), + "Some directories within plugins/ are not chmod 755 \n\nGot: $chmod for : $pathToTest \n\n" . + "Run this command to set all directories to 755: \n$command\n" + ); } } @@ -436,7 +443,8 @@ public function test_DirectoriesInPluginsFolder_areKnown() $enabled = in_array($pluginName, $pluginsBundledWithPiwik); - $this->assertTrue( $enabled + $disabled === 1, + $this->assertTrue( + $enabled + $disabled === 1, "Plugin $pluginName should be either enabled (in global.ini.php) or disabled (in Piwik\\Application\\Kernel\\PluginList). It is currently (enabled=" . (int)$enabled . ", disabled=" . (int)$disabled . ")" ); @@ -503,11 +511,13 @@ public function test_piwikJs_minified_isUpToDate() { shell_exec("sed '//,/<\/DEBUG>/d' < " . PIWIK_DOCUMENT_ROOT . "/js/piwik.js | sed 's/eval/replacedEvilString/' | java -jar " . PIWIK_DOCUMENT_ROOT . "/tests/resources/yuicompressor/yuicompressor-2.4.8.jar --type js --line-break 1000 | sed 's/replacedEvilString/eval/' | sed 's/^[/][*]/\/*!/' > " . PIWIK_DOCUMENT_ROOT . "/piwik-minified.js"); - $this->assertFileEquals(PIWIK_DOCUMENT_ROOT . '/piwik-minified.js', + $this->assertFileEquals( + PIWIK_DOCUMENT_ROOT . '/piwik-minified.js', PIWIK_DOCUMENT_ROOT . '/piwik.js', 'minified /piwik.js is out of date, please re-generate the minified files using instructions in /js/README' ); - $this->assertFileEquals(PIWIK_DOCUMENT_ROOT . '/piwik-minified.js', + $this->assertFileEquals( + PIWIK_DOCUMENT_ROOT . '/piwik-minified.js', PIWIK_DOCUMENT_ROOT . '/js/piwik.min.js', 'minified /js/piwik.min.js is out of date, please re-generate the minified files using instructions in /js/README' ); @@ -619,7 +629,8 @@ public function test_TotalPiwikFilesSize_isWithinReasonnableSize() $this->assertLessThan( $maximumTotalFilesizesExpectedInMb * 1024 * 1024, $sumFilesizes, - sprintf("Sum of all files should be less than $maximumTotalFilesizesExpectedInMb Mb. + sprintf( + "Sum of all files should be less than $maximumTotalFilesizesExpectedInMb Mb. \nGot total file sizes of: %d Mb. \nBiggest files: %s", $sumFilesizes / 1024 / 1024, diff --git a/tests/PHPUnit/Integration/ReportTest.php b/tests/PHPUnit/Integration/ReportTest.php index 4f09c0bfedba..a31b42e02806 100644 --- a/tests/PHPUnit/Integration/ReportTest.php +++ b/tests/PHPUnit/Integration/ReportTest.php @@ -382,7 +382,9 @@ public function test_fetch_ShouldUseCorrectApiUrl() $proxyMock = $this->getMockBuilder('stdClass')->addMethods(array('call', '__construct'))->getMock(); $proxyMock->expects($this->once())->method('call')->with( - '\\Piwik\\Plugins\\ExampleReport\\API', 'getExampleReport', array( + '\\Piwik\\Plugins\\ExampleReport\\API', + 'getExampleReport', + array( 'idSite' => 1, 'date' => '2012-01-02', 'format' => 'original', @@ -406,7 +408,9 @@ public function test_fetchSubtable_ShouldUseCorrectApiUrl() $proxyMock = $this->getMockBuilder('stdClass')->addMethods(array('call', '__construct'))->getMock(); $proxyMock->expects($this->once())->method('call')->with( - '\\Piwik\\Plugins\\Referrers\\API', 'getSearchEnginesFromKeywordId', array( + '\\Piwik\\Plugins\\Referrers\\API', + 'getSearchEnginesFromKeywordId', + array( 'idSubtable' => 23, 'idSite' => 1, 'date' => '2012-01-02', diff --git a/tests/PHPUnit/Integration/ServeStaticFileTest.php b/tests/PHPUnit/Integration/ServeStaticFileTest.php index 062157d0b0e7..466c89a7197e 100644 --- a/tests/PHPUnit/Integration/ServeStaticFileTest.php +++ b/tests/PHPUnit/Integration/ServeStaticFileTest.php @@ -168,8 +168,10 @@ public function test_firstAccessNoCompression() $this->assertEquals(filesize(TEST_FILE_LOCATION), $responseInfo["size_download"]); // Tests if returned modified date is correctly set - $this->assertEquals(gmdate('D, d M Y H:i:s', filemtime(TEST_FILE_LOCATION)) . ' GMT', - $this->getLastModifiedValue($fullResponse)); + $this->assertEquals( + gmdate('D, d M Y H:i:s', filemtime(TEST_FILE_LOCATION)) . ' GMT', + $this->getLastModifiedValue($fullResponse) + ); // Tests if cache control headers are correctly set $this->assertEquals("public, must-revalidate", $this->getCacheControlValue($fullResponse)); @@ -422,8 +424,11 @@ public function test_partialFileServeNoCompression() // check $partialResponse $this->assertEquals(PARTIAL_BYTE_END - PARTIAL_BYTE_START, $responseInfo["size_download"]); - $expectedPartialContents = substr(file_get_contents(TEST_FILE_LOCATION), PARTIAL_BYTE_START, - PARTIAL_BYTE_END - PARTIAL_BYTE_START); + $expectedPartialContents = substr( + file_get_contents(TEST_FILE_LOCATION), + PARTIAL_BYTE_START, + PARTIAL_BYTE_END - PARTIAL_BYTE_START + ); $this->assertEquals($expectedPartialContents, $partialResponse); } @@ -450,8 +455,11 @@ public function test_partialFileServeWithCompression() $this->assertFileNotExists($this->getCompressedFileLocation() . ".gz"); // check $partialResponse - $expectedPartialContents = substr(file_get_contents(TEST_FILE_LOCATION), PARTIAL_BYTE_START, - PARTIAL_BYTE_END - PARTIAL_BYTE_START); + $expectedPartialContents = substr( + file_get_contents(TEST_FILE_LOCATION), + PARTIAL_BYTE_START, + PARTIAL_BYTE_END - PARTIAL_BYTE_START + ); $this->assertEquals($expectedPartialContents, $partialResponse); $this->removeCompressedFiles(); diff --git a/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php b/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php index 1971379a64ed..747c391e29e4 100644 --- a/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php +++ b/tests/PHPUnit/Integration/Settings/Storage/StorageTest.php @@ -95,8 +95,10 @@ public function test_save_shouldPersistValueInDatabase() $this->storage->setValue($this->settingName, 'myRandomVal'); $this->storage->save(); - $this->assertEquals(array($this->settingName => 'myRandomVal'), - $this->loadValuesFromBackend()); + $this->assertEquals( + array($this->settingName => 'myRandomVal'), + $this->loadValuesFromBackend() + ); } public function test_save_shouldPersistMultipleValues_ContainingInt() @@ -105,8 +107,10 @@ public function test_save_shouldPersistMultipleValues_ContainingInt() $this->storage->setValue('mySecondName', 5); $this->storage->save(); - $this->assertEquals(array($this->settingName => 'myRandomVal', 'mySecondName' => 5), - $this->loadValuesFromBackend()); + $this->assertEquals( + array($this->settingName => 'myRandomVal', 'mySecondName' => 5), + $this->loadValuesFromBackend() + ); } public function test_save_shouldNotClearTrackerCacheEntries_IfThereWasNoChange() diff --git a/tests/PHPUnit/Integration/Tracker/ActionTest.php b/tests/PHPUnit/Integration/Tracker/ActionTest.php index 86877a321d30..6d0b0729c189 100644 --- a/tests/PHPUnit/Integration/Tracker/ActionTest.php +++ b/tests/PHPUnit/Integration/Tracker/ActionTest.php @@ -163,10 +163,22 @@ public function getTestUrls() public function testExcludeQueryParametersNone($url, $filteredUrl) { $this->setUpRootAccess(); - $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters = '', $timezone = null, $currency = null, - $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); + $idSite = API::getInstance()->addSite( + "site1", + array('http://example.org'), + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = '', + $excludedQueryParameters = '', + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 1 + ); $this->assertEquals($filteredUrl[0], PageUrl::excludeQueryParametersFromUrl($url, $idSite)); } @@ -197,10 +209,22 @@ public function getTestAdvertisingClickIdUrls() public function testExcludeQueryParametersAdvertisingClickIds($url, $filteredUrl) { $this->setUpRootAccess(); - $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters = '', $timezone = null, $currency = null, - $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); + $idSite = API::getInstance()->addSite( + "site1", + array('http://example.org'), + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = '', + $excludedQueryParameters = '', + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 1 + ); $this->assertEquals($filteredUrl, PageUrl::excludeQueryParametersFromUrl($url, $idSite)); } @@ -234,10 +258,22 @@ public function testExcludeQueryParametersSiteExcluded($url, $filteredUrl) { $excludedQueryParameters = 'p4, p2, var[value][date]'; $this->setUpRootAccess(); - $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, - $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); + $idSite = API::getInstance()->addSite( + "site1", + array('http://example.org'), + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = '', + $excludedQueryParameters, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 1 + ); $this->assertEquals($filteredUrl[1], PageUrl::excludeQueryParametersFromUrl($url, $idSite)); } @@ -249,10 +285,22 @@ public function testExcludeQueryParametersRegExSiteExcluded($url, $filteredUrl) { $excludedQueryParameters = '/p[4|2]/, /^var.*/'; $this->setUpRootAccess(); - $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, - $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); + $idSite = API::getInstance()->addSite( + "site1", + array('http://example.org'), + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = '', + $excludedQueryParameters, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 1 + ); $this->assertEquals($filteredUrl[1], PageUrl::excludeQueryParametersFromUrl($url, $idSite)); } @@ -266,10 +314,22 @@ public function testExcludeQueryParametersSiteAndGlobalExcluded($url, $filteredU $excludedQueryParameters = 'P2,var[value][date]'; $excludedGlobalParameters = 'blabla, P4'; $this->setUpRootAccess(); - $idSite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, - $excludedIps = '', $excludedQueryParameters, $timezone = null, $currency = null, - $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = 1); + $idSite = API::getInstance()->addSite( + "site1", + array('http://example.org'), + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIps = '', + $excludedQueryParameters, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgents = null, + $keepURLFragments = 1 + ); API::getInstance()->setGlobalExcludedQueryParameters($excludedGlobalParameters); $this->assertEquals($filteredUrl[1], PageUrl::excludeQueryParametersFromUrl($url, $idSite)); } diff --git a/tests/PHPUnit/Integration/Tracker/ModelTest.php b/tests/PHPUnit/Integration/Tracker/ModelTest.php index eb5c2ec80ec1..4fb498e3a39d 100644 --- a/tests/PHPUnit/Integration/Tracker/ModelTest.php +++ b/tests/PHPUnit/Integration/Tracker/ModelTest.php @@ -222,9 +222,11 @@ private function assertLogActionTableContainsTestAction($idaction) private function insertSingleDuplicateAction() { $logActionTable = Common::prefixTable('log_action'); - Db::query("INSERT INTO $logActionTable (idaction, name, type, url_prefix, hash) VALUES (?, ?, ?, ?, CRC32(?))", + Db::query( + "INSERT INTO $logActionTable (idaction, name, type, url_prefix, hash) VALUES (?, ?, ?, ?, CRC32(?))", array(5, self::TEST_ACTION_NAME, self::TEST_ACTION_TYPE, self::TEST_ACTION_URL_PREFIX, - self::TEST_ACTION_NAME)); + self::TEST_ACTION_NAME) + ); } private function insertManyActions() diff --git a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php index a63b26cd8d56..3c1ed9b08620 100644 --- a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php +++ b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php @@ -30,13 +30,22 @@ public function testJavascriptTrackingCode_withAllOptions() 'https://another-domain/piwik' ); $idSite = \Piwik\Plugins\SitesManager\API::getInstance()->addSite('Site name here <-->', $urls); - $jsTag = $generator->generate($idSite, 'http://piwik-server/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, + $jsTag = $generator->generate( + $idSite, + 'http://piwik-server/piwik', + $mergeSubdomains = true, + $groupPageTitlesByDomain = true, + $mergeAliasUrls = true, $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), - $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true, $disableCookies = false, $trackNoScript = true, - $crossDomain = true, $excludedQueryParams = array("uid", "aid")); + $customCampaignNameQueryParam = "campaignKey", + $customCampaignKeywordParam = "keywordKey", + $doNotTrack = true, + $disableCookies = false, + $trackNoScript = true, + $crossDomain = true, + $excludedQueryParams = array("uid", "aid") + ); $expected = "<!-- Matomo --> <script> @@ -109,13 +118,22 @@ public function testJavascriptTrackingCode_withAllOptionsAndProtocolOverwrite() $codeImpl['protocol'] = 'https://'; }); - $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, + $jsTag = $generator->generate( + $idSite = 1, + $piwikUrl = 'http://localhost/piwik', + $mergeSubdomains = true, + $groupPageTitlesByDomain = true, + $mergeAliasUrls = true, $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), - $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true, $disableCookies = false, $trackNoScript = false, - $crossDomain = false, $excludedQueryParams = array("uid", "aid")); + $customCampaignNameQueryParam = "campaignKey", + $customCampaignKeywordParam = "keywordKey", + $doNotTrack = true, + $disableCookies = false, + $trackNoScript = false, + $crossDomain = false, + $excludedQueryParams = array("uid", "aid") + ); $expected = "<!-- Matomo --> <script> @@ -158,13 +176,22 @@ public function testJavascriptTrackingCode_withAllOptionsAndOptionsBeforeTracker $codeImpl['optionsBeforeTrackerUrl'] .= "_paq.push(['setAPIUrl', 'http://localhost/statistics']);\n "; }); - $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, + $jsTag = $generator->generate( + $idSite = 1, + $piwikUrl = 'http://localhost/piwik', + $mergeSubdomains = true, + $groupPageTitlesByDomain = true, + $mergeAliasUrls = true, $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), $pageCustomVariables = array(array("page cvar", "page cvar value")), - $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true, $disableCookies = false, $trackNoScript = false, - $crossDomain = false, $excludedQueryParams = array("uid", "aid")); + $customCampaignNameQueryParam = "campaignKey", + $customCampaignKeywordParam = "keywordKey", + $doNotTrack = true, + $disableCookies = false, + $trackNoScript = false, + $crossDomain = false, + $excludedQueryParams = array("uid", "aid") + ); $expected = "<!-- Matomo --> <script> @@ -208,8 +235,13 @@ public function testJavascriptTrackingCode_loadSync() $codeImpl['loadAsync'] = false; }); - $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true); + $jsTag = $generator->generate( + $idSite = 1, + $piwikUrl = 'http://localhost/piwik', + $mergeSubdomains = true, + $groupPageTitlesByDomain = true, + $mergeAliasUrls = true + ); $expected = "<!-- Matomo --> <script> diff --git a/tests/PHPUnit/Integration/Tracker/VisitTest.php b/tests/PHPUnit/Integration/Tracker/VisitTest.php index ac8d1d80ac4a..255e55c10361 100644 --- a/tests/PHPUnit/Integration/Tracker/VisitTest.php +++ b/tests/PHPUnit/Integration/Tracker/VisitTest.php @@ -98,8 +98,15 @@ public function test_worksWhenSiteDoesNotExist() */ public function testIsVisitorIpExcluded($excludedIp, $tests) { - $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp); + $idsite = API::getInstance()->addSite( + "name", + "http://piwik.net/", + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIp + ); $request = new RequestAuthenticated(array('idsite' => $idsite)); @@ -186,8 +193,14 @@ public function testExcludeByUrl($siteUrls, $excludeUnknownUrls, array $urlsTrac */ public function testVisitShouldNotBeExcluded_IfMadeViaChromeDataSaverCompressionProxy($ip, $isNonHumanBot) { - $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null); + $idsite = API::getInstance()->addSite( + "name", + "http://piwik.net/", + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null + ); $request = new RequestAuthenticated(array('idsite' => $idsite, 'cip' => $ip)); @@ -259,10 +272,21 @@ public function getExcludedUserAgentTestData() */ public function testIsVisitorUserAgentExcluded($excludedUserAgent, $tests) { - $idsite = API::getInstance()->addSite("name", "http://piwik.net/", $ecommerce = 0, - $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIp = null, - $excludedQueryParameters = null, $timezone = null, $currency = null, $group = null, $startDate = null, - $excludedUserAgent); + $idsite = API::getInstance()->addSite( + "name", + "http://piwik.net/", + $ecommerce = 0, + $siteSearch = 1, + $searchKeywordParameters = null, + $searchCategoryParameters = null, + $excludedIp = null, + $excludedQueryParameters = null, + $timezone = null, + $currency = null, + $group = null, + $startDate = null, + $excludedUserAgent + ); $request = new Request(array('idsite' => $idsite)); @@ -435,13 +459,17 @@ public function test_markArchivedReportsAsInvalidIfArchiveAlreadyFinished_should $oneHourAfterMidnight = $midnight->addHour(1)->getDatetime(); $oneHourBeforeMidnight = $midnight->subHour(1)->getDatetime(); - $idsite = API::getInstance()->addSite('name', 'http://piwik.net/', $ecommerce = null, + $idsite = API::getInstance()->addSite( + 'name', + 'http://piwik.net/', + $ecommerce = null, $siteSearch = null, $searchKeywordParameters = null, $searchCategoryParameters = null, $excludedIps = null, $excludedQueryParameters = null, - $timezone = 'UTC+5'); + $timezone = 'UTC+5' + ); $expectedRemembered = array( substr($oneHourAfterMidnight, 0, 10) => array($idsite), diff --git a/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php b/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php index ffe1e59868de..25c36b4bd4ed 100644 --- a/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php +++ b/tests/PHPUnit/Integration/Tracker/VisitorRecognizerTest.php @@ -32,8 +32,13 @@ class VisitorRecognizerTest extends IntegrationTestCase public function setUp(): void { parent::setUp(); - $this->recognizer = new VisitorRecognizer(true, 1800, 24000, - new Model(), EventDispatcher::getInstance()); + $this->recognizer = new VisitorRecognizer( + true, + 1800, + 24000, + new Model(), + EventDispatcher::getInstance() + ); Fixture::createWebsite('2020-01-01 02:03:04'); } diff --git a/tests/PHPUnit/System/DataComparisonTest.php b/tests/PHPUnit/System/DataComparisonTest.php index 39a823c5aec0..7d27bd4d62c9 100644 --- a/tests/PHPUnit/System/DataComparisonTest.php +++ b/tests/PHPUnit/System/DataComparisonTest.php @@ -34,7 +34,10 @@ public static function setUpBeforeClass(): void // the specific site and will be invalid in global context // Added to avoid further regressions like: https://github.com/matomo-org/matomo/issues/21573 $idDimension = \Piwik\Plugins\CustomDimensions\API::getInstance()->configureNewCustomDimension( - self::$fixture->idSite, 'test', CustomDimensions::SCOPE_VISIT, true + self::$fixture->idSite, + 'test', + CustomDimensions::SCOPE_VISIT, + true ); Fixture::clearInMemoryCaches(false); \Piwik\Plugins\SegmentEditor\API::getInstance()->add('custom dimension', "dimension$idDimension==test", self::$fixture->idSite); diff --git a/tests/PHPUnit/System/LabelFilterTest.php b/tests/PHPUnit/System/LabelFilterTest.php index 868bfabfb805..c57f2a107be9 100644 --- a/tests/PHPUnit/System/LabelFilterTest.php +++ b/tests/PHPUnit/System/LabelFilterTest.php @@ -100,7 +100,8 @@ public function getApiForTesting() ' ' . // test trimming urlencode('incredible parent title! <>,;') . '>' . - urlencode('subtitle <>,;')), + urlencode('subtitle <>,;') + ), 'expanded' => 0 ) )); diff --git a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php index ac3bec5097fd..91d636a86065 100644 --- a/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php +++ b/tests/PHPUnit/System/OneVisitorTwoVisitsTest.php @@ -222,7 +222,12 @@ public function testArchiveSitesWhenRestrictingToLogin() try { Archive::build( - 'all', 'day', self::$fixture->dateTime, $segment = false, $_restrictToLogin = 'anotherLogin'); + 'all', + 'day', + self::$fixture->dateTime, + $segment = false, + $_restrictToLogin = 'anotherLogin' + ); $this->fail("Restricting sites to invalid login did not return 0 sites."); } catch (Exception $ex) { diff --git a/tests/PHPUnit/Unit/ConfigTest.php b/tests/PHPUnit/Unit/ConfigTest.php index 567767c0cad8..67255d7e4706 100644 --- a/tests/PHPUnit/Unit/ConfigTest.php +++ b/tests/PHPUnit/Unit/ConfigTest.php @@ -30,12 +30,12 @@ public function __construct($configLocal, $configGlobal, $configCommon, $configC parent::__construct(); $this->iniFileChain = new DumpConfigTestMockIniFileChain( - array( + array( $this->pathGlobal => $configGlobal, $this->pathCommon => $configCommon, $this->pathLocal => $configLocal, - ), - $configCache + ), + $configCache ); } } diff --git a/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php b/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php index 79de18937abc..77e62be1de3d 100644 --- a/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php +++ b/tests/PHPUnit/Unit/DataTable/Filter/PrependSegmentFilterTest.php @@ -50,13 +50,15 @@ public function test_filter_shouldRemoveAllMetadataEntriesHavingTheGivenName() $this->table->filter($this->filter, array($prepend)); $metadata = $this->table->getRowsMetadata('segment'); - $this->assertSame(array( + $this->assertSame( + array( false, $prepend . 'country=NZ', false, $prepend . 'country=AU', $prepend), - $metadata); + $metadata + ); // should be still the same $metadata = $this->table->getRowsMetadata('test'); diff --git a/tests/PHPUnit/Unit/Tracker/ResponseTest.php b/tests/PHPUnit/Unit/Tracker/ResponseTest.php index 5fad45d72b16..1264278f37e3 100644 --- a/tests/PHPUnit/Unit/Tracker/ResponseTest.php +++ b/tests/PHPUnit/Unit/Tracker/ResponseTest.php @@ -128,8 +128,10 @@ public function test_outputResponse_shouldOutputPiwikMessage_InCaseNothingWasTra $tracker->setCountOfLoggedRequests(0); $this->response->outputResponse($tracker); - $this->assertEquals("This resource is part of Matomo. Keep full control of your data with the leading free and open source web analytics & conversion optimisation platform.
\nThis file is the endpoint for the Matomo tracking API. If you want to access the Matomo UI or use the Reporting API, please use index.php instead.\n", - $this->response->getOutput()); + $this->assertEquals( + "This resource is part of Matomo. Keep full control of your data with the leading free and open source web analytics & conversion optimisation platform.
\nThis file is the endpoint for the Matomo tracking API. If you want to access the Matomo UI or use the Reporting API, please use index.php instead.\n", + $this->response->getOutput() + ); } public function test_getMessageFromException_ShouldNotOutputAnyDetails_IfErrorContainsDbCredentials() diff --git a/tests/PHPUnit/Unit/UrlHelperTest.php b/tests/PHPUnit/Unit/UrlHelperTest.php index 6f19e03f5a3d..d5a1f8e2a36e 100644 --- a/tests/PHPUnit/Unit/UrlHelperTest.php +++ b/tests/PHPUnit/Unit/UrlHelperTest.php @@ -169,24 +169,34 @@ public function testGetPathAndQueryFromUrl() $this->assertEquals('test/index.php?module=CoreHome', UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php?module=CoreHome')); // Add parameters to existing params - $this->assertEquals('test/index.php?module=CoreHome&abc=123&def=456', - UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php?module=CoreHome', ['abc' => '123', 'def' => '456'])); + $this->assertEquals( + 'test/index.php?module=CoreHome&abc=123&def=456', + UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php?module=CoreHome', ['abc' => '123', 'def' => '456']) + ); // Add parameters with no existing params - $this->assertEquals('test/index.php?abc=123&def=456', - UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php', ['abc' => '123', 'def' => '456'])); + $this->assertEquals( + 'test/index.php?abc=123&def=456', + UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php', ['abc' => '123', 'def' => '456']) + ); // Preserve anchor - $this->assertEquals('test/index.php#anchor', - UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php#anchor', [], true)); + $this->assertEquals( + 'test/index.php#anchor', + UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php#anchor', [], true) + ); // Do not preserve anchor - $this->assertEquals('test/index.php', - UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php#anchor', [], false)); + $this->assertEquals( + 'test/index.php', + UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php#anchor', [], false) + ); // Add parameters with existing params, preserve anchor - $this->assertEquals('test/index.php#anchor?abc=123&def=456', - UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php#anchor', ['abc' => '123', 'def' => '456'], true)); + $this->assertEquals( + 'test/index.php#anchor?abc=123&def=456', + UrlHelper::getPathAndQueryFromUrl('http://piwik.org/test/index.php#anchor', ['abc' => '123', 'def' => '456'], true) + ); } /** diff --git a/tests/PHPUnit/Unit/UrlTest.php b/tests/PHPUnit/Unit/UrlTest.php index 8f97831f6210..7dd0cb6c8bed 100644 --- a/tests/PHPUnit/Unit/UrlTest.php +++ b/tests/PHPUnit/Unit/UrlTest.php @@ -481,12 +481,16 @@ public function testAddCampaignParametersToMatomoLink_exceptIfDisabled() $_GET['action'] = 'trackingCodeGenerator'; Config::getInstance()->General['disable_tracking_matomo_app_links'] = 1; - $this->assertEquals('https://matomo.org/faq/123', - Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/123')); + $this->assertEquals( + 'https://matomo.org/faq/123', + Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/123') + ); Config::getInstance()->General['disable_tracking_matomo_app_links'] = 0; - $this->assertEquals('https://matomo.org/faq/123?mtm_campaign=Matomo_App&mtm_source=Matomo_App_OnPremise&mtm_medium=App.CoreHomeAdmin.trackingCodeGenerator', - Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/123')); + $this->assertEquals( + 'https://matomo.org/faq/123?mtm_campaign=Matomo_App&mtm_source=Matomo_App_OnPremise&mtm_medium=App.CoreHomeAdmin.trackingCodeGenerator', + Url::addCampaignParametersToMatomoLink('https://matomo.org/faq/123') + ); } /**