Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply coding style around FunctionCallSignature #9 #21935

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions tests/PHPUnit/Integration/ArchiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions tests/PHPUnit/Integration/Concurrency/DistributedListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
66 changes: 54 additions & 12 deletions tests/PHPUnit/Integration/DataAccess/ArchiveInvalidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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 (
Expand Down
16 changes: 12 additions & 4 deletions tests/PHPUnit/Integration/DataAccess/ArchiveSelectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down Expand Up @@ -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]
);
}
}

Expand Down
109 changes: 88 additions & 21 deletions tests/PHPUnit/Integration/DataAccess/ArchiveTableDaoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions tests/PHPUnit/Integration/DataAccess/ArchiveWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
}
}

Expand Down
12 changes: 10 additions & 2 deletions tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading
Loading