diff --git a/core/Db/Adapter/Mysqli.php b/core/Db/Adapter/Mysqli.php index 2a43c1e6bca..71ec0382691 100644 --- a/core/Db/Adapter/Mysqli.php +++ b/core/Db/Adapter/Mysqli.php @@ -76,7 +76,7 @@ public static function getDefaultPort() return 3306; } - protected function _connect() + protected function _connect() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { if ($this->_connection) { return; diff --git a/core/Db/Adapter/Pdo/Mysql.php b/core/Db/Adapter/Pdo/Mysql.php index a97037b09eb..b054674de54 100644 --- a/core/Db/Adapter/Pdo/Mysql.php +++ b/core/Db/Adapter/Pdo/Mysql.php @@ -99,7 +99,7 @@ public function getConnection() return $this->_connection; } - protected function _connect() + protected function _connect() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { if ($this->_connection) { return; @@ -341,7 +341,7 @@ public function query($sql, $bind = array()) * if unix_socket is set since setting both causes unexpected behaviour * @see http://php.net/manual/en/ref.pdo-mysql.connection.php */ - protected function _dsn() + protected function _dsn() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { if (!empty($this->_config['unix_socket'])) { unset($this->_config['host']); diff --git a/phpcs.xml b/phpcs.xml index 949081a9f2a..00ddd50a020 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -32,7 +32,6 @@ - diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php index 1a32b11bad4..b575ed3b669 100644 --- a/plugins/Dashboard/Controller.php +++ b/plugins/Dashboard/Controller.php @@ -32,7 +32,7 @@ protected function init() $this->dashboard = new Dashboard(); } - protected function _getDashboardView($template) + protected function getDashboardView($template) { $view = new View($template); $this->setGeneralVariablesView($view); @@ -48,14 +48,14 @@ protected function _getDashboardView($template) // this public function embeddedIndex() { - $view = $this->_getDashboardView('@Dashboard/embeddedIndex'); + $view = $this->getDashboardView('@Dashboard/embeddedIndex'); return $view->render(); } // this is the exported widget public function index() { - $view = $this->_getDashboardView('@Dashboard/index'); + $view = $this->getDashboardView('@Dashboard/index'); $view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess(); $view->dashboards = array(); if (!Piwik::isUserIsAnonymous()) { diff --git a/plugins/LanguagesManager/TranslationWriter/Filter/ByParameterCount.php b/plugins/LanguagesManager/TranslationWriter/Filter/ByParameterCount.php index 1f7e375a5ee..ce448301d7a 100644 --- a/plugins/LanguagesManager/TranslationWriter/Filter/ByParameterCount.php +++ b/plugins/LanguagesManager/TranslationWriter/Filter/ByParameterCount.php @@ -44,8 +44,8 @@ public function filter($translations) } // ensure that translated strings have the same number of %s as the english source strings - $baseCount = $this->_getParametersCountToReplace($baseTranslation); - $translationCount = $this->_getParametersCountToReplace($translation); + $baseCount = $this->getParametersCountToReplace($baseTranslation); + $translationCount = $this->getParametersCountToReplace($translation); if ($baseCount != $translationCount) { $this->filteredData[$pluginName][$key] = $translation; @@ -65,7 +65,7 @@ public function filter($translations) * @param string $string * @return array */ - protected function _getParametersCountToReplace($string) + protected function getParametersCountToReplace($string) { $sprintfParameters = array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s', '%6$s', '%7$s', '%8$s', '%9$s'); $count = array(); diff --git a/plugins/Login/tests/Integration/LoginTest.php b/plugins/Login/tests/Integration/LoginTest.php index 533a5747d4c..713fa10da9a 100644 --- a/plugins/Login/tests/Integration/LoginTest.php +++ b/plugins/Login/tests/Integration/LoginTest.php @@ -141,7 +141,7 @@ public function test_authenticate_successAnonymous() public function test_authenticate_failureUserEmptyTokenAuth() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // empty token auth $rc = $this->authenticate($login = $user['login'], $authToken = ''); @@ -150,7 +150,7 @@ public function test_authenticate_failureUserEmptyTokenAuth() public function test_authenticate_failureUserInvalidTokenAuth() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // not a token auth $rc = $this->authenticate($login = $user['login'], $authToken = $user['password']); @@ -159,7 +159,7 @@ public function test_authenticate_failureUserInvalidTokenAuth() public function test_authenticate_failureUserInvalidTokenAuth2() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // not a token auth $rc = $this->authenticate($login = $user['login'], $authToken = md5($user['password'])); @@ -168,7 +168,7 @@ public function test_authenticate_failureUserInvalidTokenAuth2() public function test_authenticate_failureUserEmptyLogin() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // empty login $rc = $this->authenticate($login = '', $user['tokenAuth']); @@ -177,8 +177,8 @@ public function test_authenticate_failureUserEmptyLogin() public function test_authenticate_failureUserWithSuperUserAccessEmptyLogin() { - $user = $this->_setUpUser(); - $this->_setUpSuperUserAccessViaDb(); + $user = $this->setUpUser(); + $this->setUpSuperUserAccessViaDb(); // empty login $rc = $this->authenticate($login = '', $user['tokenAuth']); @@ -187,7 +187,7 @@ public function test_authenticate_failureUserWithSuperUserAccessEmptyLogin() public function test_authenticate_failureUserLoginTokenAuthMissmatch() { - $this->_setUpUser(); + $this->setUpUser(); // not equal $rc = $this->authenticate($login = 0, $authToken = 0); @@ -196,7 +196,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch() public function test_authenticate_failureUserLoginTokenAuthMissmatch2() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // not equal $rc = $this->authenticate($login = 0, $user['tokenAuth']); @@ -205,7 +205,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch2() public function test_authenticate_failureUserLoginTokenAuthMissmatch3() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // not equal $rc = $this->authenticate($user['login'], $authToken = 0); @@ -214,8 +214,8 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch3() public function test_authenticate_failureUserWithSuperUserAccessLoginTokenAuthMissmatch() { - $user = $this->_setUpUser(); - $this->_setUpSuperUserAccessViaDb(); + $user = $this->setUpUser(); + $this->setUpSuperUserAccessViaDb(); // not equal $rc = $this->authenticate($login = null, $authToken = $user['password']); @@ -224,7 +224,7 @@ public function test_authenticate_failureUserWithSuperUserAccessLoginTokenAuthMi public function test_authenticate_successUserTokenAuth() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // API authentication $rc = $this->authenticate($login = null, $user['tokenAuth']); @@ -233,8 +233,8 @@ public function test_authenticate_successUserTokenAuth() public function test_authenticate_successUserWithSuperUserAccessByTokenAuth() { - $user = $this->_setUpUser(); - $this->_setUpSuperUserAccessViaDb(); + $user = $this->setUpUser(); + $this->setUpSuperUserAccessViaDb(); // API authentication $rc = $this->authenticate($login = null, $user['tokenAuth']); @@ -245,7 +245,7 @@ public function test_authenticate_successUserLoginAndTokenAuthWithAnonymous() { DbHelper::createAnonymousUser(); - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // valid login & token auth $rc = $this->authenticate('anonymous', 'anonymous'); @@ -254,7 +254,7 @@ public function test_authenticate_successUserLoginAndTokenAuthWithAnonymous() public function test_authenticate_successUserLoginAndTokenAuth() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); // valid login & token auth $rc = $this->authenticate($user['login'], $user['tokenAuth']); @@ -263,8 +263,8 @@ public function test_authenticate_successUserLoginAndTokenAuth() public function test_authenticate_successUserWithSuperUserAccessLoginAndTokenAuth() { - $user = $this->_setUpUser(); - $this->_setUpSuperUserAccessViaDb(); + $user = $this->setUpUser(); + $this->setUpSuperUserAccessViaDb(); // valid login & token auth $rc = $this->authenticate($user['login'], $user['tokenAuth']); @@ -273,7 +273,7 @@ public function test_authenticate_successUserWithSuperUserAccessLoginAndTokenAut public function test_authenticate_successWithValidPassword() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); $this->auth->setLogin($user['login']); $this->auth->setPassword($user['password']); @@ -286,8 +286,8 @@ public function test_authenticate_successWithValidPassword() public function test_authenticate_successWithSuperUserPassword() { - $user = $this->_setUpUser(); - $this->_setUpSuperUserAccessViaDb(); + $user = $this->setUpUser(); + $this->setUpSuperUserAccessViaDb(); $this->auth->setLogin($user['login']); $this->auth->setPassword($user['password']); @@ -298,7 +298,7 @@ public function test_authenticate_successWithSuperUserPassword() public function test_authenticate_failsWithInvalidPassword() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); $this->auth->setLogin($user['login']); $this->auth->setPassword('foo bar'); @@ -308,7 +308,7 @@ public function test_authenticate_failsWithInvalidPassword() public function test_authenticate_prioritizesPasswordAuthentication() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); $this->auth->setLogin($user['login']); $this->auth->setPassword($user['password']); // correct password $this->auth->setTokenAuth('foo bar'); // invalid token @@ -327,7 +327,7 @@ public function test_authenticate_prioritizesPasswordAuthentication() */ public function test_authenticate_withPasswordIsCaseInsensitiveForLogin() { - $user = $this->_setUpUser(); + $user = $this->setUpUser(); $this->auth->setLogin('uSeR'); $this->auth->setPassword($user['password']); @@ -339,7 +339,7 @@ public function test_authenticate_withPasswordIsCaseInsensitiveForLogin() $this->assertTrue(ctype_xdigit($rc->getTokenAuth())); } - protected function _setUpUser() + protected function setUpUser() { $user = array( 'login' => 'user', @@ -359,7 +359,7 @@ protected function _setUpUser() return $user; } - private function _setUpSuperUserAccessViaDb() + private function setUpSuperUserAccessViaDb() { $userUpdater = new UserUpdater(); $userUpdater->setSuperUserAccessWithoutCurrentPassword('user', true); diff --git a/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php b/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php index 1d6ccec222e..f83351740b0 100644 --- a/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php +++ b/plugins/PrivacyManager/tests/Integration/DataPurgingTest.php @@ -87,8 +87,8 @@ public static function beforeTableDataCached() { parent::beforeTableDataCached(); - self::_addLogData(); - self::_addReportData(); + self::addLogData(); + self::addReportData(); } protected static function configureFixture($fixture) @@ -158,7 +158,7 @@ public function tearDown(): void */ public function testDeleteLogDataInitialRun() { - $this->_checkNoDataChanges(); + $this->checkNoDataChanges(); // Check it does not run $this->assertFalse($this->instance->deleteLogData()); @@ -167,7 +167,7 @@ public function testDeleteLogDataInitialRun() $this->assertEquals(1, Option::get(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL)); // perform other checks - $this->_checkNoDataChanges(); + $this->checkNoDataChanges(); } /** @@ -181,7 +181,7 @@ public function testDeleteReportDataInitialRun() $this->assertEquals(1, Option::get(PrivacyManager::OPTION_LAST_DELETE_PIWIK_LOGS_INITIAL)); // perform other checks - $this->_checkNoDataChanges(); + $this->checkNoDataChanges(); } /** @@ -198,7 +198,7 @@ public function testPurgeDataNotTimeToRun() $this->assertFalse($this->instance->deleteReportData()); // perform checks - $this->_checkNoDataChanges(); + $this->checkNoDataChanges(); } /** @@ -223,27 +223,27 @@ public function testPurgeDataNotInitialAndTimeToRun() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $archiveTables = self::_getArchiveTableNames(); + $archiveTables = self::getArchiveTableNames(); // January numeric table should be dropped - $this->assertEquals(self::JAN_DONE_FLAGS_COUNT, $this->_getTableCount($archiveTables['numeric'][0])); // January + $this->assertEquals(self::JAN_DONE_FLAGS_COUNT, $this->getTableCount($archiveTables['numeric'][0])); // January // Check february metric count - $febRowCount = $this->_getExpectedNumericArchiveCountFeb(); - $this->assertEquals($febRowCount, $this->_getTableCount($archiveTables['numeric'][1])); // February + $febRowCount = $this->getExpectedNumericArchiveCountFeb(); + $this->assertEquals($febRowCount, $this->getTableCount($archiveTables['numeric'][1])); // February // January blob table should be dropped - $this->assertEquals(0, $this->_getTableCount($archiveTables['blob'][0])); // January + $this->assertEquals(0, $this->getTableCount($archiveTables['blob'][0])); // January // Check february blob count (1 blob per period w/ visits + 1 garbage report) - $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->_getTableCount($archiveTables['blob'][1])); // February + $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February } public function test_LogDataPurging_WorksWhenVisitsInPastTracked() @@ -251,9 +251,9 @@ public function test_LogDataPurging_WorksWhenVisitsInPastTracked() DbHelper::deleteArchiveTables(); self::trackVisitInPast(); - self::_addReportData(); + self::addReportData(); - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->checkLogDataPurged(); @@ -279,13 +279,13 @@ public function testPurgeDataBothDisabled() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $hasDeleted = $this->instance->deleteLogData(); $this->assertFalse($hasDeleted); $this->assertFalse($this->instance->deleteReportData()); // perform checks - $this->_checkNoDataChanges(); + $this->checkNoDataChanges(); } /** @@ -304,22 +304,22 @@ public function testPurgeDataDeleteLogsNoData() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks - $this->assertEquals(0, $this->_getTableCount('log_visit')); - $this->assertEquals(0, $this->_getTableCount('log_conversion')); - $this->assertEquals(0, $this->_getTableCount('log_link_visit_action')); - $this->assertEquals(0, $this->_getTableCount('log_conversion_item')); + $this->assertEquals(0, $this->getTableCount('log_visit')); + $this->assertEquals(0, $this->getTableCount('log_conversion')); + $this->assertEquals(0, $this->getTableCount('log_link_visit_action')); + $this->assertEquals(0, $this->getTableCount('log_conversion_item')); - $archiveTables = self::_getArchiveTableNames(); - $this->assertFalse($this->_tableExists($archiveTables['numeric'][0])); // January - $this->assertFalse($this->_tableExists($archiveTables['numeric'][1])); // February - $this->assertFalse($this->_tableExists($archiveTables['blob'][0])); // January - $this->assertFalse($this->_tableExists($archiveTables['blob'][1])); // February + $archiveTables = self::getArchiveTableNames(); + $this->assertFalse($this->tableExists($archiveTables['numeric'][0])); // January + $this->assertFalse($this->tableExists($archiveTables['numeric'][1])); // February + $this->assertFalse($this->tableExists($archiveTables['blob'][0])); // January + $this->assertFalse($this->tableExists($archiveTables['blob'][1])); // February } /** @@ -348,19 +348,19 @@ public function testPurgeDataDeleteReportsKeepBasicMetrics() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $archiveTables = self::_getArchiveTableNames(); + $archiveTables = self::getArchiveTableNames(); // all numeric metrics should be saved except the garbage metric - $janRowCount = $this->_getExpectedNumericArchiveCountJan() - 1; + $janRowCount = $this->getExpectedNumericArchiveCountJan() - 1; $tableName = $archiveTables['numeric'][0]; - $tableCount = $this->_getTableCount($tableName); + $tableCount = $this->getTableCount($tableName); $this->assertEquals($janRowCount, $tableCount); // January if ($janRowCount != $tableCount) { @@ -368,13 +368,13 @@ public function testPurgeDataDeleteReportsKeepBasicMetrics() } // check february numerics not deleted - $febRowCount = $this->_getExpectedNumericArchiveCountFeb(); - $this->assertEquals($febRowCount, $this->_getTableCount($archiveTables['numeric'][1])); // February + $febRowCount = $this->getExpectedNumericArchiveCountFeb(); + $this->assertEquals($febRowCount, $this->getTableCount($archiveTables['numeric'][1])); // February - $this->assertEquals(0, $this->_getTableCount($archiveTables['blob'][0])); // January + $this->assertEquals(0, $this->getTableCount($archiveTables['blob'][0])); // January // check for no changes in the february blob table - $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->_getTableCount($archiveTables['blob'][1])); // February + $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February } /** @@ -403,13 +403,13 @@ public function testPurgeDataDeleteReportsKeepDailyReports() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 5, $janNumericRemaining = 87); // 5 blobs for 5 days + $this->checkReportsAndMetricsPurged($janBlobsRemaining = 5, $janNumericRemaining = 87); // 5 blobs for 5 days } /** @@ -438,13 +438,13 @@ public function testPurgeDataDeleteReportsKeepWeeklyReports() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 4, $janNumericRemaining = 81); // 4 blobs for 4 weeks + $this->checkReportsAndMetricsPurged($janBlobsRemaining = 4, $janNumericRemaining = 81); // 4 blobs for 4 weeks } /** @@ -473,13 +473,13 @@ public function testPurgeDataDeleteReportsKeepMonthlyReports() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 1, $janNumericRemaining = 66); + $this->checkReportsAndMetricsPurged($janBlobsRemaining = 1, $janNumericRemaining = 66); } /** @@ -508,13 +508,13 @@ public function testPurgeDataDeleteReportsKeepYearlyReports() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 1, $janNumericRemaining = 66); + $this->checkReportsAndMetricsPurged($janBlobsRemaining = 1, $janNumericRemaining = 66); } /** @@ -537,7 +537,7 @@ public function testPurgeLogDataConcurrency() // check that actions were purged $contentsNotPurged = 3; - $this->assertEquals(22 + $this->getCountEventIdsNotPurged() + $contentsNotPurged, $this->_getTableCount('log_action')); // January + $this->assertEquals(22 + $this->getCountEventIdsNotPurged() + $contentsNotPurged, $this->getTableCount('log_action')); // January // check that the unused action still exists $count = Db::fetchOne( @@ -575,13 +575,13 @@ public function testPurgeDataDeleteReportsKeepRangeReports() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 2, $janNumericRemaining = 65); // 2 range blobs + $this->checkReportsAndMetricsPurged($janBlobsRemaining = 2, $janNumericRemaining = 65); // 2 range blobs } /** @@ -611,18 +611,18 @@ public function testPurgeDataDeleteReportsKeepSegmentsReports() $this->assertEquals($expectedPrediction, $prediction); // purge data - $this->_setTimeToRun(); + $this->setTimeToRun(); $this->assertTrue($this->instance->deleteLogData()); $this->assertTrue($this->instance->deleteReportData()); // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 114); // 1 segmented blob + 5 day blobs + $this->checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 114); // 1 segmented blob + 5 day blobs } // --- utility functions follow --- - protected static function _addLogData() + protected static function addLogData() { // tracks visits on the following days: // - 2012-01-09 @@ -715,7 +715,7 @@ protected static function trackVisitInPast() $t->doTrackPageView('visit in past'); } - protected static function _addReportData() + protected static function addReportData() { $date = Date::factory(self::$dateTime); @@ -783,7 +783,7 @@ protected static function _addReportData() Archiver::getRecordName('revenue', GoalManager::IDGOAL_ORDER) ); - $archiveTables = self::_getArchiveTableNames(); + $archiveTables = self::getArchiveTableNames(); foreach ($archiveTables['numeric'] as $table) { $realTable = Common::prefixTable($table); $sql = "DELETE FROM $realTable WHERE name NOT IN ('" . implode("','", $metricsToSave) . "') AND name NOT LIKE 'done%'"; @@ -822,27 +822,27 @@ protected static function _addReportData() ); } - protected function _checkNoDataChanges() + protected function checkNoDataChanges() { // 11 visits total w/ 4 actions per visit & 2 conversions per visit. 1 e-commerce order per visit. - $this->assertEquals(11, $this->_getTableCount('log_visit')); - $this->assertEquals(22, $this->_getTableCount('log_conversion')); - $this->assertEquals(44, $this->_getTableCount('log_link_visit_action')); - $this->assertEquals(11, $this->_getTableCount('log_conversion_item')); - $this->assertEquals(45, $this->_getTableCount('log_action')); + $this->assertEquals(11, $this->getTableCount('log_visit')); + $this->assertEquals(22, $this->getTableCount('log_conversion')); + $this->assertEquals(44, $this->getTableCount('log_link_visit_action')); + $this->assertEquals(11, $this->getTableCount('log_conversion_item')); + $this->assertEquals(45, $this->getTableCount('log_action')); - $archiveTables = self::_getArchiveTableNames(); + $archiveTables = self::getArchiveTableNames(); - $janMetricCount = $this->_getExpectedNumericArchiveCountJan(); - $this->assertEquals($janMetricCount, $this->_getTableCount($archiveTables['numeric'][0])); // January + $janMetricCount = $this->getExpectedNumericArchiveCountJan(); + $this->assertEquals($janMetricCount, $this->getTableCount($archiveTables['numeric'][0])); // January // no range metric for february - $febMetricCount = $this->_getExpectedNumericArchiveCountFeb(); - $this->assertEquals($febMetricCount, $this->_getTableCount($archiveTables['numeric'][1])); // February + $febMetricCount = $this->getExpectedNumericArchiveCountFeb(); + $this->assertEquals($febMetricCount, $this->getTableCount($archiveTables['numeric'][1])); // February // 1 entry per period w/ visits + 1 garbage report + 2 range reports + 1 segment report - $this->assertEquals(self::JAN_METRIC_ARCHIVE_COUNT + 1 + 2 + 1, $this->_getTableCount($archiveTables['blob'][0])); // January - $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->_getTableCount($archiveTables['blob'][1])); // February + $this->assertEquals(self::JAN_METRIC_ARCHIVE_COUNT + 1 + 2 + 1, $this->getTableCount($archiveTables['blob'][0])); // January + $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February } /** @@ -850,21 +850,21 @@ protected function _checkNoDataChanges() * was dropped, that the february metric & blob tables are unaffected, and that the january blob * table has a certain number of blobs. */ - protected function _checkReportsAndMetricsPurged($janBlobsRemaining, $janNumericRemaining) + protected function checkReportsAndMetricsPurged($janBlobsRemaining, $janNumericRemaining) { - $archiveTables = self::_getArchiveTableNames(); + $archiveTables = self::getArchiveTableNames(); - $this->assertEquals($janNumericRemaining, $this->_getTableCount($archiveTables['numeric'][0])); + $this->assertEquals($janNumericRemaining, $this->getTableCount($archiveTables['numeric'][0])); // check february numerics not deleted - $febRowCount = $this->_getExpectedNumericArchiveCountFeb(); - $this->assertEquals($febRowCount, $this->_getTableCount($archiveTables['numeric'][1])); // February + $febRowCount = $this->getExpectedNumericArchiveCountFeb(); + $this->assertEquals($febRowCount, $this->getTableCount($archiveTables['numeric'][1])); // February // check the january blob count - $this->assertEquals($janBlobsRemaining, $this->_getTableCount($archiveTables['blob'][0])); // January + $this->assertEquals($janBlobsRemaining, $this->getTableCount($archiveTables['blob'][0])); // January // check for no changes in the february blob table (1 blob for every period w/ visits in feb + 1 garbage report) - $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->_getTableCount($archiveTables['blob'][1])); // February + $this->assertEquals(self::FEB_METRIC_ARCHIVE_COUNT + 1, $this->getTableCount($archiveTables['blob'][1])); // February } private function checkLogDataPurged() @@ -873,14 +873,14 @@ private function checkLogDataPurged() // & 6 actions removed $events = 11 - 3; // 3 deleted (1 per day purged) $contents = 11 - 3; // 3 deleted (1 per day purged) - $this->assertEquals(8, $this->_getTableCount('log_visit')); - $this->assertEquals(16, $this->_getTableCount('log_conversion')); - $this->assertEquals(16 + $events + $contents, $this->_getTableCount('log_link_visit_action')); - $this->assertEquals(8, $this->_getTableCount('log_conversion_item')); + $this->assertEquals(8, $this->getTableCount('log_visit')); + $this->assertEquals(16, $this->getTableCount('log_conversion')); + $this->assertEquals(16 + $events + $contents, $this->getTableCount('log_link_visit_action')); + $this->assertEquals(8, $this->getTableCount('log_conversion_item')); $eventsId = $this->getCountEventIdsNotPurged(); $contentsNotPurged = 3; - $this->assertEquals(21 + $eventsId + $contentsNotPurged, $this->_getTableCount('log_action')); + $this->assertEquals(21 + $eventsId + $contentsNotPurged, $this->getTableCount('log_action')); } /** @@ -907,7 +907,7 @@ public function addReferenceToUnusedAction() Db::query($sql); } - protected function _setTimeToRun() + protected function setTimeToRun() { $lastDateSecs = Date::factory('today')->subDay(8)->getTimestamp(); @@ -916,7 +916,7 @@ protected function _setTimeToRun() Option::set(PrivacyManager::OPTION_LAST_DELETE_PIWIK_REPORTS, $lastDateSecs); } - protected function _getTableCount($tableName, $where = '') + protected function getTableCount($tableName, $where = '') { $sql = "SELECT COUNT(*) FROM " . Common::prefixTable($tableName) . " $where"; return Db::fetchOne($sql); @@ -928,7 +928,7 @@ protected function dumpTable($tableName, $where = '') var_export(Db::fetchAll($sql)); } - protected function _tableExists($tableName) + protected function tableExists($tableName) { $dbName = Config::getInstance()->database['dbname']; @@ -936,7 +936,7 @@ protected function _tableExists($tableName) return Db::fetchOne($sql, array($dbName, Common::prefixTable($tableName))) == 1; } - protected static function _getArchiveTableNames() + protected static function getArchiveTableNames() { return array( 'numeric' => array( @@ -950,7 +950,7 @@ protected static function _getArchiveTableNames() ); } - protected function _getExpectedNumericArchiveCountJan() + protected function getExpectedNumericArchiveCountJan() { // 5 entries per period w/ visits // + 3 entries per dependent goals segment (2 total) per period w/ visits @@ -965,7 +965,7 @@ protected function _getExpectedNumericArchiveCountJan() return self::JAN_METRIC_ARCHIVE_COUNT * 6 + 1 + 2 + 6 + 1 + 3 + 64 + 50; } - protected function _getExpectedNumericArchiveCountFeb() + protected function getExpectedNumericArchiveCountFeb() { // (5 metrics per period w/ visits // + 1 'done' archive for every period w/ data) diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php index 1c642e76f70..95df8ab214b 100644 --- a/plugins/UserCountryMap/Controller.php +++ b/plugins/UserCountryMap/Controller.php @@ -77,7 +77,7 @@ public function visitorMap($fetch = false, $segmentOverride = false) ); $config = []; $config['visitsSummary'] = json_decode($request->process(), true); - $config['countryDataUrl'] = $this->_report( + $config['countryDataUrl'] = $this->report( 'UserCountry', 'getCountry', $this->idSite, @@ -87,7 +87,7 @@ public function visitorMap($fetch = false, $segmentOverride = false) false, $segment ); - $config['regionDataUrl'] = $this->_report( + $config['regionDataUrl'] = $this->report( 'UserCountry', 'getRegion', $this->idSite, @@ -97,7 +97,7 @@ public function visitorMap($fetch = false, $segmentOverride = false) true, $segment ); - $config['cityDataUrl'] = $this->_report( + $config['cityDataUrl'] = $this->report( 'UserCountry', 'getCity', $this->idSite, @@ -355,7 +355,7 @@ private function getApiRequestUrl($module, $action, $idSite, $period, $date, $to return $url; } - private function _report($module, $action, $idSite, $period, $date, $token_auth, $filter_by_country = false, $segmentOverride = false) + private function report($module, $action, $idSite, $period, $date, $token_auth, $filter_by_country = false, $segmentOverride = false) { return $this->getApiRequestUrl( 'API', diff --git a/plugins/UsersManager/tests/Integration/UsersManagerTest.php b/plugins/UsersManager/tests/Integration/UsersManagerTest.php index dc1fc4551a1..dd4f91d32b6 100644 --- a/plugins/UsersManager/tests/Integration/UsersManagerTest.php +++ b/plugins/UsersManager/tests/Integration/UsersManagerTest.php @@ -73,7 +73,7 @@ public function tearDown(): void parent::tearDown(); } - private function _flatten($sitesAccess) + private function flatten($sitesAccess) { $result = array(); @@ -84,7 +84,7 @@ private function _flatten($sitesAccess) return $result; } - private function _checkUserHasNotChanged($user, $newPassword, $newEmail = null) + private function checkUserHasNotChanged($user, $newPassword, $newEmail = null) { if (is_null($newEmail)) { $newEmail = $user['email']; @@ -143,7 +143,7 @@ public function testUpdateUserBadpasswd() try { $this->api->updateUser($login, "pas"); } catch (Exception $expected) { - $this->_checkUserHasNotChanged($user, $user['password']); + $this->checkUserHasNotChanged($user, $user['password']); throw $expected; } } @@ -472,7 +472,7 @@ public function testGetUsers() Option::set('UsersManager.lastSeen.gegg4564eqgeqag', $now = time()); $users = $this->api->getUsers(); - $users = $this->_removeNonTestableFieldsFromUsers($users); + $users = $this->removeNonTestableFieldsFromUsers($users); $user1 = array('login' => "gegg4564eqgeqag", 'email' => "tegst@tesgt.com", 'superuser_access' => 0, @@ -493,11 +493,11 @@ public function testGetUsers() $this->assertEquals($expectedUsers, $users); $this->assertEquals( array($user1), - $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag')) + $this->removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag')) ); $this->assertEquals( array($user1, $user2), - $this->_removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')) + $this->removeNonTestableFieldsFromUsers($this->api->getUsers('gegg4564eqgeqag,geggeqge632ge56a4qag')) ); } @@ -515,7 +515,7 @@ public function testGetUsers_withViewAccess_shouldThrowAnException() $this->api->getUsers(); } - protected function _removeNonTestableFieldsFromUsers($users) + protected function removeNonTestableFieldsFromUsers($users) { foreach ($users as &$user) { unset($user['password']); @@ -639,7 +639,7 @@ public function testSetUserAccessIdsitesIsAll() FakeAccess::$superUser = true; $access = $this->api->getSitesAccessFromUser("gegg4564eqgeqag"); - $access = $this->_flatten($access); + $access = $this->flatten($access); /** @var Access $accessInstance */ $accessInstance = self::$fixture->piwikEnvironment->getContainer()->get('Piwik\Access'); @@ -666,7 +666,7 @@ public function testSetUserAccessIdsitesIsAllSuperuser() $this->api->setUserAccess("gegg4564eqgeqag", "view", "all"); $access = $this->api->getSitesAccessFromUser("gegg4564eqgeqag"); - $access = $this->_flatten($access); + $access = $this->flatten($access); $this->assertEquals($idSites, array_keys($access)); } @@ -690,7 +690,7 @@ public function testSetUserAccessIdsitesOneSite() $this->api->setUserAccess("gegg4564eqgeqag", "view", $idSites); $access = $this->api->getSitesAccessFromUser("gegg4564eqgeqag"); - $access = $this->_flatten($access); + $access = $this->flatten($access); $this->assertEquals($idSites, array_keys($access)); } @@ -705,7 +705,7 @@ public function testSetUserAccessIdsitesMultipleSites() $this->api->setUserAccess("gegg4564eqgeqag", "view", array($id1, $id3)); $access = $this->api->getSitesAccessFromUser("gegg4564eqgeqag"); - $access = $this->_flatten($access); + $access = $this->flatten($access); $this->assertEquals(array($id1, $id3), array_keys($access)); } @@ -719,7 +719,7 @@ public function testSetUserAccessWithIdSitesIsStringCommaSeparated() $this->api->setUserAccess("gegg4564eqgeqag", "view", "1,3"); $access = $this->api->getSitesAccessFromUser("gegg4564eqgeqag"); - $access = $this->_flatten($access); + $access = $this->flatten($access); $this->assertEquals(array(1, 3), array_keys($access)); } @@ -736,7 +736,7 @@ public function testSetUserAccessMultipleCallDistinctAccessSameUser() $this->api->setUserAccess("gegg4564eqgeqag", "admin", array($id2)); $access = $this->api->getSitesAccessFromUser("gegg4564eqgeqag"); - $access = $this->_flatten($access); + $access = $this->flatten($access); $this->assertEquals(array($id1 => 'view', $id2 => 'admin'), $access); } @@ -755,9 +755,9 @@ public function testSetUserAccessMultipleCallDistinctAccessMultipleUser() $this->api->setUserAccess("user2", "view", array($id3, $id2)); $access1 = $this->api->getSitesAccessFromUser("user1"); - $access1 = $this->_flatten($access1); + $access1 = $this->flatten($access1); $access2 = $this->api->getSitesAccessFromUser("user2"); - $access2 = $this->_flatten($access2); + $access2 = $this->flatten($access2); $wanted1 = array($id1 => 'view', $id2 => 'view',); $wanted2 = array($id1 => 'admin', $id2 => 'view', $id3 => 'view'); @@ -809,7 +809,7 @@ public function testSetUserAccessMultipleCallOverwriteSingleUserOneSite() $this->api->setUserAccess("user1", "admin", array($id1)); $access1 = $this->api->getSitesAccessFromUser("user1"); - $access1 = $this->_flatten($access1); + $access1 = $this->flatten($access1); $wanted1 = array($id1 => 'admin', $id2 => 'view',); $this->assertEquals($wanted1, $access1); @@ -867,7 +867,7 @@ public function testSetSuperUserAccess_ShouldDeleteAllExistingAccessEntries() $this->api->setUserAccess('login1', 'admin', array($id2)); // verify user has access before setting Super User access - $access = $this->_flatten($this->api->getSitesAccessFromUser('login1')); + $access = $this->flatten($this->api->getSitesAccessFromUser('login1')); $this->assertEquals(array($id1 => 'view', $id2 => 'admin'), $access); $this->api->setSuperUserAccess('login1', true, $pwd); @@ -1018,7 +1018,7 @@ public function testUpdateUserNoEmail() FakeAccess::$identity = 'login'; $this->api->updateUser($login, "passowordOK", null, false, "geqgeagae"); - $this->_checkUserHasNotChanged($user, "passowordOK", null); + $this->checkUserHasNotChanged($user, "passowordOK", null); } /** @@ -1062,7 +1062,7 @@ public function testUpdateUser() FakeAccess::$identity = 'login'; $this->api->updateUser($login, "passowordOK", "email@geaga.com", false, "geqgeagae"); - $this->_checkUserHasNotChanged($user, "passowordOK", "email@geaga.com"); + $this->checkUserHasNotChanged($user, "passowordOK", "email@geaga.com"); } public function testGetUserByEmailInvalidMail() diff --git a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php index 8a0bf71a433..18dc9c1b3c1 100644 --- a/tests/PHPUnit/Framework/TestCase/SystemTestCase.php +++ b/tests/PHPUnit/Framework/TestCase/SystemTestCase.php @@ -482,7 +482,7 @@ protected function getResponseFromHttpAPI($requestUrl) return $response; } - protected function _testApiUrl($testName, $apiId, $requestUrl, $compareAgainst, $params = array()) + protected function testApiUrl($testName, $apiId, $requestUrl, $compareAgainst, $params = array()) { Manager::getInstance()->deleteAll(); // clearing the datatable cache here GREATLY speeds up system tests on CI @@ -690,7 +690,7 @@ protected function runApiTests($api, $params) $testRequests = $this->getTestRequestsCollection($api, $testConfig, $api); foreach ($testRequests->getRequestUrls() as $apiId => $requestUrl) { - $this->_testApiUrl($testName . $testConfig->testSuffix, $apiId, $requestUrl, $testConfig->compareAgainst, $params); + $this->testApiUrl($testName . $testConfig->testSuffix, $apiId, $requestUrl, $testConfig->compareAgainst, $params); } // change the language back to en diff --git a/tests/PHPUnit/Framework/TestRequest/Collection.php b/tests/PHPUnit/Framework/TestRequest/Collection.php index 71d7ac001ee..d878999a208 100644 --- a/tests/PHPUnit/Framework/TestRequest/Collection.php +++ b/tests/PHPUnit/Framework/TestRequest/Collection.php @@ -92,7 +92,7 @@ public function __construct($api, ApiTestConfig $testConfig, $apiToCall) $this->testConfig = $testConfig; $this->setExplicitApiToCallAndNotCall($apiToCall); - $this->requestUrls = $this->_generateApiUrls(); + $this->requestUrls = $this->generateApiUrls(); } public function getRequestUrls() @@ -105,7 +105,7 @@ public function getRequestUrls() * * @return array */ - protected function _generateApiUrls() + protected function generateApiUrls() { $parametersToSet = array( 'idSite' => $this->testConfig->idSite, diff --git a/tests/PHPUnit/Integration/ArchiveProcessingTest.php b/tests/PHPUnit/Integration/ArchiveProcessingTest.php index 7af558afeeb..a4a9f95fa7f 100644 --- a/tests/PHPUnit/Integration/ArchiveProcessingTest.php +++ b/tests/PHPUnit/Integration/ArchiveProcessingTest.php @@ -64,7 +64,7 @@ public function tearDown(): void * @param string $timezone * @return Site */ - private function _createWebsite($timezone = 'UTC') + private function createWebsite($timezone = 'UTC') { $idSite = Fixture::createWebsite('2013-03-04', 0, false, false, 1, null, null, $timezone); Site::clearCache(); @@ -79,9 +79,9 @@ private function _createWebsite($timezone = 'UTC') * @param string $siteTimezone * @return ArchiveProcessorTest */ - private function _createArchiveProcessor($periodLabel, $dateLabel, $siteTimezone) + private function createArchiveProcessor($periodLabel, $dateLabel, $siteTimezone) { - $site = $this->_createWebsite($siteTimezone); + $site = $this->createWebsite($siteTimezone); $date = Date::factory($dateLabel); $period = Period\Factory::build($periodLabel, $date); $segment = new Segment('', [$site->getId()], $period->getDateTimeStart(), $period->getDateTimeEnd()); @@ -90,7 +90,7 @@ private function _createArchiveProcessor($periodLabel, $dateLabel, $siteTimezone return new ArchiveProcessorTest($params); } - private function _createArchiveProcessorInst($periodLabel, $dateLabel, $idSite, $archiveOnly = false, $plugin = false) + private function createArchiveProcessorInst($periodLabel, $dateLabel, $idSite, $archiveOnly = false, $plugin = false) { $period = Period\Factory::build($periodLabel, $dateLabel); $segment = new Segment('', [$idSite], $period->getDateTimeStart(), $period->getDateTimeEnd()); @@ -151,7 +151,7 @@ public function testInitCurrentMonth() } $dateLabel = date('Y-m-d', $now); - $archiveProcessor = $this->_createArchiveProcessor('month', $dateLabel, $siteTimezone); + $archiveProcessor = $this->createArchiveProcessor('month', $dateLabel, $siteTimezone); $archiveProcessor->time = $now; // min finished timestamp considered when looking at archive timestamp @@ -171,7 +171,7 @@ private function compareTimestamps($expected, $processed) */ public function testInitDayInPast() { - $archiveProcessor = $this->_createArchiveProcessor('day', '2010-01-01', 'UTC'); + $archiveProcessor = $this->createArchiveProcessor('day', '2010-01-01', 'UTC'); $this->assertEquals('2010-01-01 00:00:00', $archiveProcessor->getParams()->getDateStart()->getDateStartUTC()); $this->assertEquals('2010-01-01 23:59:59', $archiveProcessor->getParams()->getDateEnd()->getDateEndUTC()); @@ -183,7 +183,7 @@ public function testInitDayInPast() public function testInitDayInPastNonUTCWebsite() { $timezone = 'UTC+5.5'; - $archiveProcessor = $this->_createArchiveProcessor('day', '2010-01-01', $timezone); + $archiveProcessor = $this->createArchiveProcessor('day', '2010-01-01', $timezone); $this->assertEquals('2009-12-31 18:30:00', $archiveProcessor->getParams()->getDateStart()->getDateStartUTC()); $this->assertEquals('2010-01-01 18:29:59', $archiveProcessor->getParams()->getDateEnd()->getDateEndUTC()); @@ -195,7 +195,7 @@ public function testInitDayInPastNonUTCWebsite() public function testInitMonthInPastNonUTCWebsite() { $timezone = 'UTC-5.5'; - $archiveProcessor = $this->_createArchiveProcessor('month', '2010-01-02', $timezone); + $archiveProcessor = $this->createArchiveProcessor('month', '2010-01-02', $timezone); $this->assertEquals('2010-01-01 05:30:00', $archiveProcessor->getParams()->getDateStart()->getDateStartUTC()); $this->assertEquals('2010-02-01 05:29:59', $archiveProcessor->getParams()->getDateEnd()->getDateEndUTC()); @@ -213,7 +213,7 @@ public function testInitToday() Rules::setBrowserTriggerArchiving(true); - $archiveProcessor = $this->_createArchiveProcessor('day', $dateLabel, $siteTimezone); + $archiveProcessor = $this->createArchiveProcessor('day', $dateLabel, $siteTimezone); $archiveProcessor->time = $now; // when browsers don't trigger archives... @@ -240,7 +240,7 @@ public function testInitTodayEurope() Rules::setBrowserTriggerArchiving(true); - $archiveProcessor = $this->_createArchiveProcessor('day', $dateLabel, $siteTimezone); + $archiveProcessor = $this->createArchiveProcessor('day', $dateLabel, $siteTimezone); $archiveProcessor->time = $now; // when browsers don't trigger archives... @@ -270,7 +270,7 @@ public function testInitTodayToronto() Rules::setBrowserTriggerArchiving(true); - $archiveProcessor = $this->_createArchiveProcessor('day', $dateLabel, $siteTimezone); + $archiveProcessor = $this->createArchiveProcessor('day', $dateLabel, $siteTimezone); $archiveProcessor->time = $now; // when browsers don't trigger archives... @@ -289,7 +289,7 @@ public function testInitTodayToronto() public function testTableInsertBatch() { $table = Common::prefixTable('site_url'); - $data = $this->_getDataInsert(); + $data = $this->getDataInsert(); try { $didWeUseBulk = BatchInsert::tableInsertBatch( $table, @@ -302,18 +302,18 @@ public function testTableInsertBatch() $didWeUseBulk = $e->getMessage(); } - $this->_checkLoadDataInFileWasUsed($didWeUseBulk); + $this->checkLoadDataInFileWasUsed($didWeUseBulk); if ($didWeUseBulk === true) { - $this->_checkTableIsExpected($table, $data); + $this->checkTableIsExpected($table, $data); // INSERT again the bulk. Because we use keyword LOCAL the data will be REPLACED automatically (see mysql doc) BatchInsert::tableInsertBatch($table, array('idsite', 'url'), $data); - $this->_checkTableIsExpected($table, $data); + $this->checkTableIsExpected($table, $data); } } - protected function _checkLoadDataInFileWasUsed($didWeUseBulk) + protected function checkLoadDataInFileWasUsed($didWeUseBulk) { static $skippedOnce = false; if ( @@ -340,9 +340,9 @@ protected function _checkLoadDataInFileWasUsed($didWeUseBulk) public function testTableInsertBatchIterate() { $table = Common::prefixTable('site_url'); - $data = $this->_getDataInsert(); + $data = $this->getDataInsert(); BatchInsert::tableInsertBatchIterate($table, array('idsite', 'url'), $data); - $this->_checkTableIsExpected($table, $data); + $this->checkTableIsExpected($table, $data); // If we insert AGAIN, expect to throw an error because the primary key already exists try { @@ -350,7 +350,7 @@ public function testTableInsertBatchIterate() } catch (Exception $e) { // However if we insert with keyword REPLACE, then the new data should be saved BatchInsert::tableInsertBatchIterate($table, array('idsite', 'url'), $data, $ignoreWhenDuplicate = true); - $this->_checkTableIsExpected($table, $data); + $this->checkTableIsExpected($table, $data); return; } $this->fail('Exception expected'); @@ -364,7 +364,7 @@ public function testTableInsertBatchBlob() $dateLabel = '2011-03-31'; $table = ArchiveTableCreator::getBlobTable(Date::factory($dateLabel)); - $data = $this->_getBlobDataInsert(); + $data = $this->getBlobDataInsert(); try { $didWeUseBulk = BatchInsert::tableInsertBatch( $table, @@ -376,16 +376,16 @@ public function testTableInsertBatchBlob() } catch (Exception $e) { $didWeUseBulk = $e->getMessage(); } - $this->_checkLoadDataInFileWasUsed($didWeUseBulk); + $this->checkLoadDataInFileWasUsed($didWeUseBulk); // If bulk wasn't used the exception was caught and the INSERT didn't work if ($didWeUseBulk === true) { - $this->_checkTableIsExpectedBlob($table, $data); + $this->checkTableIsExpectedBlob($table, $data); } // INSERT again the bulk. Because we use keyword LOCAL the data will be REPLACED automatically (see mysql doc) $didWeUseBulk = BatchInsert::tableInsertBatch($table, array('idarchive', 'name', 'idsite', 'date1', 'date2', 'period', 'ts_archived', 'value'), $data, $throw = false, $charset = 'latin1'); if ($didWeUseBulk === true) { - $this->_checkTableIsExpectedBlob($table, $data); + $this->checkTableIsExpectedBlob($table, $data); } } @@ -397,9 +397,9 @@ public function testTableInsertBatchIterateBlob() $dateLabel = '2011-03-31'; $table = ArchiveTableCreator::getBlobTable(Date::factory($dateLabel)); - $data = $this->_getBlobDataInsert(); + $data = $this->getBlobDataInsert(); BatchInsert::tableInsertBatchIterate($table, array('idarchive', 'name', 'idsite', 'date1', 'date2', 'period', 'ts_archived', 'value'), $data); - $this->_checkTableIsExpectedBlob($table, $data); + $this->checkTableIsExpectedBlob($table, $data); // If we insert AGAIN, expect to throw an error because the primary key already exist try { @@ -407,7 +407,7 @@ public function testTableInsertBatchIterateBlob() } catch (Exception $e) { // However if we insert with keyword REPLACE, then the new data should be saved BatchInsert::tableInsertBatchIterate($table, array('idarchive', 'name', 'idsite', 'date1', 'date2', 'period', 'ts_archived', 'value'), $data, $ignoreWhenDuplicate = true); - $this->_checkTableIsExpectedBlob($table, $data); + $this->checkTableIsExpectedBlob($table, $data); return; } $this->fail('Exception expected'); @@ -430,11 +430,11 @@ public function test_aggregateNumericMetrics_aggregatesCorrectly() ], ]; - $site = $this->_createWebsite('UTC'); + $site = $this->createWebsite('UTC'); foreach ($allMetrics as $date => $metrics) { /** @var ArchiveWriter $archiveWriter */ - list($archiveProcessor, $archiveWriter, $params) = $this->_createArchiveProcessorInst('day', $date, $site->getId()); + list($archiveProcessor, $archiveWriter, $params) = $this->createArchiveProcessorInst('day', $date, $site->getId()); $archiveWriter->initNewArchive(); $archiveProcessor->insertNumericRecords($metrics); @@ -443,7 +443,7 @@ public function test_aggregateNumericMetrics_aggregatesCorrectly() } /** @var ArchiveProcessor $archiveProcessor */ - list($archiveProcessor, $archiveWriter, $params) = $this->_createArchiveProcessorInst('week', '2015-02-03', $site->getId()); + list($archiveProcessor, $archiveWriter, $params) = $this->createArchiveProcessorInst('week', '2015-02-03', $site->getId()); $archiveWriter->initNewArchive(); $archiveProcessor->captureInserts(); @@ -484,11 +484,11 @@ public function test_aggregateNumericMetrics_handlesPartialArchives() ], ]; - $site = $this->_createWebsite('UTC'); + $site = $this->createWebsite('UTC'); foreach ($allMetrics as $date => $metrics) { /** @var ArchiveWriter $archiveWriter */ - list($archiveProcessor, $archiveWriter) = $this->_createArchiveProcessorInst('day', $date, $site->getId()); + list($archiveProcessor, $archiveWriter) = $this->createArchiveProcessorInst('day', $date, $site->getId()); $archiveWriter->initNewArchive(); $archiveProcessor->insertNumericRecords($metrics); @@ -497,7 +497,7 @@ public function test_aggregateNumericMetrics_handlesPartialArchives() } /** @var ArchiveProcessor $archiveProcessor */ - list($archiveProcessor, $archiveWriter, $params) = $this->_createArchiveProcessorInst('week', '2015-02-03', $site->getId(), 'nb_visits', 'VisitsSummary'); + list($archiveProcessor, $archiveWriter, $params) = $this->createArchiveProcessorInst('week', '2015-02-03', $site->getId(), 'nb_visits', 'VisitsSummary'); $params->setIsPartialArchive(true); $idArchive = $archiveWriter->initNewArchive(); @@ -543,11 +543,11 @@ public function test_aggregateDataTableRecords_aggregatesCorrectly() '2015-02-05' => $table3, ]; - $site = $this->_createWebsite('UTC'); + $site = $this->createWebsite('UTC'); foreach ($tables as $date => $table) { /** @var ArchiveWriter $archiveWriter */ - list($archiveProcessor, $archiveWriter) = $this->_createArchiveProcessorInst('day', $date, $site->getId()); + list($archiveProcessor, $archiveWriter) = $this->createArchiveProcessorInst('day', $date, $site->getId()); $archiveWriter->initNewArchive(); $tableSerialized = $table->getSerialized(); @@ -556,7 +556,7 @@ public function test_aggregateDataTableRecords_aggregatesCorrectly() $archiveWriter->finalizeArchive(); } - list($archiveProcessor, $archiveWriter) = $this->_createArchiveProcessorInst('week', '2015-02-03', $site->getId()); + list($archiveProcessor, $archiveWriter) = $this->createArchiveProcessorInst('week', '2015-02-03', $site->getId()); $archiveWriter->initNewArchive(); $archiveProcessor->captureInserts(); @@ -609,11 +609,11 @@ public function test_aggregateDataTableRecords_handlesPartialArchives() '2015-02-05' => $table3, ]; - $site = $this->_createWebsite('UTC'); + $site = $this->createWebsite('UTC'); foreach ($tables as $date => $table) { /** @var ArchiveWriter $archiveWriter */ - list($archiveProcessor, $archiveWriter) = $this->_createArchiveProcessorInst('day', $date, $site->getId()); + list($archiveProcessor, $archiveWriter) = $this->createArchiveProcessorInst('day', $date, $site->getId()); $archiveWriter->initNewArchive(); $tableSerialized = $table->getSerialized(); @@ -623,7 +623,7 @@ public function test_aggregateDataTableRecords_handlesPartialArchives() } /** @var ArchiveProcessor $archiveProcessor */ - list($archiveProcessor, $archiveWriter, $params) = $this->_createArchiveProcessorInst('week', '2015-02-03', $site->getId(), 'Actions_test_value', 'VisitsSummary'); + list($archiveProcessor, $archiveWriter, $params) = $this->createArchiveProcessorInst('week', '2015-02-03', $site->getId(), 'Actions_test_value', 'VisitsSummary'); $params->setIsPartialArchive(true); $idArchive = $archiveWriter->initNewArchive(); @@ -663,11 +663,11 @@ public function test_aggregateDataTableRecords_handlesNegativeOneLabels() '2015-02-04' => $table2, ]; - $site = $this->_createWebsite('UTC'); + $site = $this->createWebsite('UTC'); foreach ($tables as $date => $table) { /** @var ArchiveWriter $archiveWriter */ - list($archiveProcessor, $archiveWriter) = $this->_createArchiveProcessorInst('day', $date, $site->getId()); + list($archiveProcessor, $archiveWriter) = $this->createArchiveProcessorInst('day', $date, $site->getId()); $archiveWriter->initNewArchive(); $tableSerialized = $table->getSerialized(); @@ -676,7 +676,7 @@ public function test_aggregateDataTableRecords_handlesNegativeOneLabels() $archiveWriter->finalizeArchive(); } - list($archiveProcessor, $archiveWriter) = $this->_createArchiveProcessorInst('week', '2015-02-03', $site->getId()); + list($archiveProcessor, $archiveWriter) = $this->createArchiveProcessorInst('week', '2015-02-03', $site->getId()); $archiveWriter->initNewArchive(); $archiveProcessor->captureInserts(); @@ -712,7 +712,7 @@ public function test_aggregateDataTableRecords_handlesNegativeOneLabels() $this->assertEquals($expectedXml, $capturedInsertTable); } - protected function _checkTableIsExpected($table, $data) + protected function checkTableIsExpected($table, $data) { $fetched = Db::fetchAll('SELECT * FROM ' . $table); @@ -722,7 +722,7 @@ protected function _checkTableIsExpected($table, $data) } } - protected function _checkTableIsExpectedBlob($table, $data) + protected function checkTableIsExpectedBlob($table, $data) { $fetched = Db::fetchAll('SELECT * FROM ' . $table); foreach ($data as $id => $row) { @@ -745,7 +745,7 @@ protected function _checkTableIsExpectedBlob($table, $data) * PRIMARY KEY(idsite, url) * ) */ - protected function _getDataInsert() + protected function getDataInsert() { return array( array(1, 'test'), @@ -772,7 +772,7 @@ protected function _getDataInsert() /** * see archive_blob table */ - protected function _getBlobDataInsert() + protected function getBlobDataInsert() { $ts = '2011-03-31 17:48:00'; $str = ''; diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php index 3389e24288d..c7ccb5444ff 100644 --- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php @@ -155,18 +155,18 @@ public function test_screenshotsStoredInLfs() public function testCheckThatConfigurationValuesAreProductionValues() { - $this->_checkEqual(array('Debug' => 'always_archive_data_day'), '0'); - $this->_checkEqual(array('Debug' => 'always_archive_data_period'), '0'); - $this->_checkEqual(array('Debug' => 'enable_sql_profiler'), '0'); - $this->_checkEqual(array('General' => 'time_before_today_archive_considered_outdated'), '900'); - $this->_checkEqual(array('General' => 'enable_browser_archiving_triggering'), '1'); - $this->_checkEqual(array('General' => 'default_language'), 'en'); - $this->_checkEqual(array('Tracker' => 'record_statistics'), '1'); - $this->_checkEqual(array('Tracker' => 'visit_standard_length'), '1800'); - $this->_checkEqual(array('Tracker' => 'trust_visitors_cookies'), '0'); - $this->_checkEqual(array('log' => 'log_level'), 'WARN'); - $this->_checkEqual(array('log' => 'log_writers'), array('screen')); - $this->_checkEqual(array('log' => 'logger_api_call'), null); + $this->checkEqual(array('Debug' => 'always_archive_data_day'), '0'); + $this->checkEqual(array('Debug' => 'always_archive_data_period'), '0'); + $this->checkEqual(array('Debug' => 'enable_sql_profiler'), '0'); + $this->checkEqual(array('General' => 'time_before_today_archive_considered_outdated'), '900'); + $this->checkEqual(array('General' => 'enable_browser_archiving_triggering'), '1'); + $this->checkEqual(array('General' => 'default_language'), 'en'); + $this->checkEqual(array('Tracker' => 'record_statistics'), '1'); + $this->checkEqual(array('Tracker' => 'visit_standard_length'), '1800'); + $this->checkEqual(array('Tracker' => 'trust_visitors_cookies'), '0'); + $this->checkEqual(array('log' => 'log_level'), 'WARN'); + $this->checkEqual(array('log' => 'log_writers'), array('screen')); + $this->checkEqual(array('log' => 'logger_api_call'), null); $this->assertFalse(defined('DEBUG_FORCE_SCHEDULED_TASKS')); @@ -176,7 +176,7 @@ public function testCheckThatConfigurationValuesAreProductionValues() $this->assertTrue(false !== strpos($content, $expected), 'index.php should contain: ' . $expected); } - private function _checkEqual($key, $valueExpected) + private function checkEqual($key, $valueExpected) { $section = key($key); $optionName = current($key); diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php index 2c4ebbd52e1..ad836f60fa0 100644 --- a/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php +++ b/tests/PHPUnit/Unit/DataTable/Renderer/CSVTest.php @@ -32,7 +32,7 @@ public function setUp(): void * - datatableSimple * - normal datatable with 2 row (including columns and metadata) */ - protected function _getDataTableTest() + protected function getDataTableTest() { $dataTable = new DataTable(); @@ -56,7 +56,7 @@ protected function _getDataTableTest() return $dataTable; } - protected function _getDataTableSimpleTest() + protected function getDataTableSimpleTest() { $array = array('max_actions' => 14.0, 'nb_uniq_visitors' => 57.0, 'nb_visits' => 66.0, 'nb_actions' => 151.0, 'sum_visit_length' => 5118.0, 'bounce_count' => 44.0,); @@ -65,7 +65,7 @@ protected function _getDataTableSimpleTest() return $table; } - protected function _getDataTableSimpleOneRowTest() + protected function getDataTableSimpleOneRowTest() { $array = array('nb_visits' => 14.0); @@ -74,13 +74,13 @@ protected function _getDataTableSimpleOneRowTest() return $table; } - protected function _getDataTableEmpty() + protected function getDataTableEmpty() { $table = new DataTable(); return $table; } - protected function _getDataTableSimpleOneZeroRowTest() + protected function getDataTableSimpleOneZeroRowTest() { $array = array('nb_visits' => 0); $table = new Simple(); @@ -88,7 +88,7 @@ protected function _getDataTableSimpleOneZeroRowTest() return $table; } - protected function _getDataTableSimpleOneFalseRowTest() + protected function getDataTableSimpleOneFalseRowTest() { $array = array('is_excluded' => false); $table = new Simple(); @@ -96,7 +96,7 @@ protected function _getDataTableSimpleOneFalseRowTest() return $table; } - protected function _getDataTableHavingAnArrayInRowMetadata() + protected function getDataTableHavingAnArrayInRowMetadata() { $array = array( array(Row::COLUMNS => array('label' => 'sub1', 'count' => 1)), @@ -115,7 +115,7 @@ protected function _getDataTableHavingAnArrayInRowMetadata() public function testCSVTest1() { - $dataTable = $this->_getDataTableTest(); + $dataTable = $this->getDataTableTest(); $render = new Csv(); $render->setTable($dataTable); @@ -131,7 +131,7 @@ public function testCSVTest1() public function testCSVTest2() { - $dataTable = $this->_getDataTableSimpleTest(); + $dataTable = $this->getDataTableSimpleTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -143,7 +143,7 @@ public function testCSVTest2() public function testCSVTest3() { - $dataTable = $this->_getDataTableSimpleOneRowTest(); + $dataTable = $this->getDataTableSimpleOneRowTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -155,7 +155,7 @@ public function testCSVTest3() public function testCSVTest5() { - $dataTable = $this->_getDataTableSimpleOneZeroRowTest(); + $dataTable = $this->getDataTableSimpleOneZeroRowTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -167,7 +167,7 @@ public function testCSVTest5() public function testCSVTest4() { - $dataTable = $this->_getDataTableEmpty(); + $dataTable = $this->getDataTableEmpty(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -179,7 +179,7 @@ public function testCSVTest4() public function testCSVTest6() { - $dataTable = $this->_getDataTableSimpleOneFalseRowTest(); + $dataTable = $this->getDataTableSimpleOneFalseRowTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -191,7 +191,7 @@ public function testCSVTest6() public function testCSVRendererCorrectlyEscapesHeadersAndValues() { - $dataTable = $this->_getDataTableSimpleWithCommasInCells(); + $dataTable = $this->getDataTableSimpleWithCommasInCells(); $render = new Csv(); $render->setTable($dataTable); $render->setSeparator('#'); @@ -206,7 +206,7 @@ public function testCSVRendererCorrectlyEscapesHeadersAndValues() public function testCSVTest7_shouldNotRenderMetadataThatContainsAnArray() { - $dataTable = $this->_getDataTableHavingAnArrayInRowMetadata(); + $dataTable = $this->getDataTableHavingAnArrayInRowMetadata(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -227,7 +227,7 @@ public function testCSVTest7_shouldNotRenderMetadataThatContainsAnArray() * DATA OF DATATABLE_ARRAY * ------------------------- */ - protected function _getDataTableMapTest() + protected function getDataTableMapTest() { $array1 = array( array(Row::COLUMNS => array('label' => 'Google', 'nb_uniq_visitors' => 11, 'nb_visits' => 11,), @@ -262,7 +262,7 @@ protected function _getDataTableMapTest() return $table; } - protected function _getDataTableSimpleMapTest() + protected function getDataTableSimpleMapTest() { $array1 = array('max_actions' => 14.0, 'nb_uniq_visitors' => 57.0,); $table1 = new Simple(); @@ -283,7 +283,7 @@ protected function _getDataTableSimpleMapTest() return $table; } - protected function _getDataTableSimpleOneRowMapTest() + protected function getDataTableSimpleOneRowMapTest() { $array1 = array('nb_visits' => 14.0); $table1 = new Simple(); @@ -303,34 +303,34 @@ protected function _getDataTableSimpleOneRowMapTest() return $table; } - protected function _getDataTableMap_containsDataTableMap_normal() + protected function getDataTableMap_containsDataTableMap_normal() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableMapTest(), 'idSite'); + $table->addTable($this->getDataTableMapTest(), 'idSite'); return $table; } - protected function _getDataTableMap_containsDataTableMap_simple() + protected function getDataTableMap_containsDataTableMap_simple() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableSimpleMapTest(), 'idSite'); + $table->addTable($this->getDataTableSimpleMapTest(), 'idSite'); return $table; } - protected function _getDataTableMap_containsDataTableMap_simpleOneRow() + protected function getDataTableMap_containsDataTableMap_simpleOneRow() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableSimpleOneRowMapTest(), 'idSite'); + $table->addTable($this->getDataTableSimpleOneRowMapTest(), 'idSite'); return $table; } public function testCSVMapTest1() { - $dataTable = $this->_getDataTableMapTest(); + $dataTable = $this->getDataTableMapTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -347,7 +347,7 @@ public function testCSVMapTest1() public function testCSVMapTest2() { - $dataTable = $this->_getDataTableSimpleMapTest(); + $dataTable = $this->getDataTableSimpleMapTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -360,7 +360,7 @@ public function testCSVMapTest2() public function testCSVMapTest3() { - $dataTable = $this->_getDataTableSimpleOneRowMapTest(); + $dataTable = $this->getDataTableSimpleOneRowMapTest(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -372,7 +372,7 @@ public function testCSVMapTest3() public function testCSVMapisMadeOfMapTest1() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_normal(); + $dataTable = $this->getDataTableMap_containsDataTableMap_normal(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -389,7 +389,7 @@ public function testCSVMapisMadeOfMapTest1() public function testCSVMapIsMadeOfMapTest2() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_simple(); + $dataTable = $this->getDataTableMap_containsDataTableMap_simple(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -402,7 +402,7 @@ public function testCSVMapIsMadeOfMapTest2() public function testCSVMapIsMadeOfMapTest3() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_simpleOneRow(); + $dataTable = $this->getDataTableMap_containsDataTableMap_simpleOneRow(); $render = new Csv(); $render->setTable($dataTable); $render->convertToUnicode = false; @@ -466,7 +466,7 @@ public function testRenderArray4() $this->assertEquals($expected, $render->render()); } - private function _getDataTableSimpleWithCommasInCells() + private function getDataTableSimpleWithCommasInCells() { $table = new DataTable(); $table->addRowsFromSimpleArray(array( diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php index accc5fcc964..95ec71e7753 100644 --- a/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php +++ b/tests/PHPUnit/Unit/DataTable/Renderer/JSONTest.php @@ -32,7 +32,7 @@ public function setUp(): void * - datatableSimple * - normal datatable with 2 row (including columns and metadata) */ - protected function _getDataTableTest() + protected function getDataTableTest() { $dataTable = new DataTable(); @@ -56,7 +56,7 @@ protected function _getDataTableTest() return $dataTable; } - protected function _getDataTableSimpleTest() + protected function getDataTableSimpleTest() { $array = array('max_actions' => 14.0, 'nb_uniq_visitors' => 57.0, 'nb_visits' => 66.0, 'nb_actions' => 151.0, 'sum_visit_length' => 5118.0, 'bounce_count' => 44.0,); @@ -65,7 +65,7 @@ protected function _getDataTableSimpleTest() return $table; } - protected function _getDataTableSimpleOneRowTest() + protected function getDataTableSimpleOneRowTest() { $array = array('nb_visits' => 14.0); @@ -74,13 +74,13 @@ protected function _getDataTableSimpleOneRowTest() return $table; } - protected function _getDataTableEmpty() + protected function getDataTableEmpty() { $table = new DataTable(); return $table; } - protected function _getDataTableSimpleOneZeroRowTest() + protected function getDataTableSimpleOneZeroRowTest() { $array = array('nb_visits' => 0); $table = new Simple(); @@ -88,7 +88,7 @@ protected function _getDataTableSimpleOneZeroRowTest() return $table; } - protected function _getDataTableSimpleOneFalseRowTest() + protected function getDataTableSimpleOneFalseRowTest() { $array = array('is_excluded' => false); $table = new Simple(); @@ -99,7 +99,7 @@ protected function _getDataTableSimpleOneFalseRowTest() public function testJSONTest1() { - $dataTable = $this->_getDataTableTest(); + $dataTable = $this->getDataTableTest(); $render = new Json(); $render->setTable($dataTable); $render->setRenderSubTables(true); @@ -112,7 +112,7 @@ public function testJSONTest1() public function testJSONTest2() { - $dataTable = $this->_getDataTableSimpleTest(); + $dataTable = $this->getDataTableSimpleTest(); $render = new Json(); $render->setTable($dataTable); $expected = '{"max_actions":14,"nb_uniq_visitors":57,"nb_visits":66,"nb_actions":151,"sum_visit_length":5118,"bounce_count":44}'; @@ -123,7 +123,7 @@ public function testJSONTest2() public function testJSONTest3() { - $dataTable = $this->_getDataTableSimpleOneRowTest(); + $dataTable = $this->getDataTableSimpleOneRowTest(); $render = new Json(); $render->setTable($dataTable); $expected = '{"value":14}'; @@ -133,7 +133,7 @@ public function testJSONTest3() public function testJSONTest4() { - $dataTable = $this->_getDataTableEmpty(); + $dataTable = $this->getDataTableEmpty(); $render = new Json(); $render->setTable($dataTable); $expected = '[]'; @@ -143,7 +143,7 @@ public function testJSONTest4() public function testJSONTest5() { - $dataTable = $this->_getDataTableSimpleOneZeroRowTest(); + $dataTable = $this->getDataTableSimpleOneZeroRowTest(); $render = new Json(); $render->setTable($dataTable); $expected = '{"value":0}'; @@ -153,7 +153,7 @@ public function testJSONTest5() public function testJSONTest6() { - $dataTable = $this->_getDataTableSimpleOneFalseRowTest(); + $dataTable = $this->getDataTableSimpleOneFalseRowTest(); $render = new Json(); $render->setTable($dataTable); $expected = '{"value":false}'; @@ -165,7 +165,7 @@ public function testJSONTest6() * ------------------------- */ - protected function _getDataTableMapTest() + protected function getDataTableMapTest() { $array1 = array( array(Row::COLUMNS => array('label' => 'Google', 'nb_uniq_visitors' => 11, 'nb_visits' => 11,), @@ -200,7 +200,7 @@ protected function _getDataTableMapTest() return $table; } - protected function _getDataTableSimpleMapTest() + protected function getDataTableSimpleMapTest() { $array1 = array('max_actions' => 14.0, 'nb_uniq_visitors' => 57.0,); $table1 = new Simple(); @@ -221,7 +221,7 @@ protected function _getDataTableSimpleMapTest() return $table; } - protected function _getDataTableSimpleOneRowMapTest() + protected function getDataTableSimpleOneRowMapTest() { $array1 = array('nb_visits' => 14.0); $table1 = new Simple(); @@ -241,34 +241,34 @@ protected function _getDataTableSimpleOneRowMapTest() return $table; } - protected function _getDataTableMap_containsDataTableMap_normal() + protected function getDataTableMap_containsDataTableMap_normal() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableMapTest(), 'idSite'); + $table->addTable($this->getDataTableMapTest(), 'idSite'); return $table; } - protected function _getDataTableMap_containsDataTableMap_simple() + protected function getDataTableMap_containsDataTableMap_simple() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableSimpleMapTest(), 'idSite'); + $table->addTable($this->getDataTableSimpleMapTest(), 'idSite'); return $table; } - protected function _getDataTableMap_containsDataTableMap_simpleOneRow() + protected function getDataTableMap_containsDataTableMap_simpleOneRow() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableSimpleOneRowMapTest(), 'idSite'); + $table->addTable($this->getDataTableSimpleOneRowMapTest(), 'idSite'); return $table; } public function testJSONArrayTest1() { - $dataTable = $this->_getDataTableMapTest(); + $dataTable = $this->getDataTableMapTest(); $render = new Json(); $render->setTable($dataTable); $rendered = $render->render(); @@ -280,7 +280,7 @@ public function testJSONArrayTest1() public function testJSONMapTest2() { - $dataTable = $this->_getDataTableSimpleMapTest(); + $dataTable = $this->getDataTableSimpleMapTest(); $render = new Json(); $render->setTable($dataTable); $rendered = $render->render(); @@ -293,7 +293,7 @@ public function testJSONMapTest2() public function testJSONMapTest3() { - $dataTable = $this->_getDataTableSimpleOneRowMapTest(); + $dataTable = $this->getDataTableSimpleOneRowMapTest(); $render = new Json(); $render->setTable($dataTable); $rendered = $render->render(); @@ -305,7 +305,7 @@ public function testJSONMapTest3() public function testJSONMapIsMadeOfMapTest1() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_normal(); + $dataTable = $this->getDataTableMap_containsDataTableMap_normal(); $render = new Json(); $render->setTable($dataTable); $rendered = $render->render(); @@ -316,7 +316,7 @@ public function testJSONMapIsMadeOfMapTest1() public function testJSONMapIsMadeOfMapTest2() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_simple(); + $dataTable = $this->getDataTableMap_containsDataTableMap_simple(); $render = new Json(); $render->setTable($dataTable); $rendered = $render->render(); @@ -329,7 +329,7 @@ public function testJSONMapIsMadeOfMapTest2() public function testJSONMapIsMadeOfMapTest3() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_simpleOneRow(); + $dataTable = $this->getDataTableMap_containsDataTableMap_simpleOneRow(); $render = new Json(); $render->setTable($dataTable); diff --git a/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php b/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php index e0bfaacda6c..62fe6ccf0c1 100644 --- a/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php +++ b/tests/PHPUnit/Unit/DataTable/Renderer/XMLTest.php @@ -32,7 +32,7 @@ public function setUp(): void * - datatableSimple * - normal datatable with 2 row (including columns and metadata) */ - protected function _getDataTableTest() + protected function getDataTableTest() { $dataTable = new DataTable(); @@ -56,7 +56,7 @@ protected function _getDataTableTest() return $dataTable; } - protected function _getDataTableSimpleTest() + protected function getDataTableSimpleTest() { $array = array('max_actions' => 14.0, 'nb_uniq_visitors' => 57.0, 'nb_visits' => 66.0, 'nb_actions' => 151.0, 'sum_visit_length' => 5118.0, 'bounce_count' => 44.0,); @@ -65,7 +65,7 @@ protected function _getDataTableSimpleTest() return $table; } - protected function _getDataTableSimpleOneRowTest() + protected function getDataTableSimpleOneRowTest() { $array = array('nb_visits' => 14.0); @@ -74,13 +74,13 @@ protected function _getDataTableSimpleOneRowTest() return $table; } - protected function _getDataTableEmpty() + protected function getDataTableEmpty() { $table = new DataTable(); return $table; } - protected function _getDataTableSimpleOneZeroRowTest() + protected function getDataTableSimpleOneZeroRowTest() { $array = array('nb_visits' => 0); $table = new Simple(); @@ -88,7 +88,7 @@ protected function _getDataTableSimpleOneZeroRowTest() return $table; } - protected function _getDataTableSimpleOneFalseRowTest() + protected function getDataTableSimpleOneFalseRowTest() { $array = array('is_excluded' => false); $table = new Simple(); @@ -99,7 +99,7 @@ protected function _getDataTableSimpleOneFalseRowTest() public function testXMLTest1() { - $dataTable = $this->_getDataTableTest(); + $dataTable = $this->getDataTableTest(); $render = new Xml(); $render->setTable($dataTable); $render->setRenderSubTables(true); @@ -156,7 +156,7 @@ public function testXMLTest1() public function testXMLTest2() { - $dataTable = $this->_getDataTableSimpleTest(); + $dataTable = $this->getDataTableSimpleTest(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -174,7 +174,7 @@ public function testXMLTest2() public function testXMLTest3() { - $dataTable = $this->_getDataTableSimpleOneRowTest(); + $dataTable = $this->getDataTableSimpleOneRowTest(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -185,7 +185,7 @@ public function testXMLTest3() public function testXMLTest4() { - $dataTable = $this->_getDataTableEmpty(); + $dataTable = $this->getDataTableEmpty(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -196,7 +196,7 @@ public function testXMLTest4() public function testXMLTest5() { - $dataTable = $this->_getDataTableSimpleOneZeroRowTest(); + $dataTable = $this->getDataTableSimpleOneZeroRowTest(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -207,7 +207,7 @@ public function testXMLTest5() public function testXMLTest6() { - $dataTable = $this->_getDataTableSimpleOneFalseRowTest(); + $dataTable = $this->getDataTableSimpleOneFalseRowTest(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -218,7 +218,7 @@ public function testXMLTest6() public function testXMLRendererSuccessfullyRendersWhenSimpleDataTableColumnsHaveInvalidXmlCharacters() { - $dataTable = $this->_getDataTableSimpleWithInvalidChars(); + $dataTable = $this->getDataTableSimpleWithInvalidChars(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -233,7 +233,7 @@ public function testXMLRendererSuccessfullyRendersWhenSimpleDataTableColumnsHave public function testXMLRendererSuccessfullyRendersWhenDataTableColumnsHaveInvalidXmlCharacters() { - $dataTable = $this->_getDataTableWithInvalidChars(); + $dataTable = $this->getDataTableWithInvalidChars(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -252,7 +252,7 @@ public function testXMLRendererSuccessfullyRendersWhenDataTableColumnsHaveInvali * ------------------------- */ - protected function _getDataTableMapTest() + protected function getDataTableMapTest() { $array1 = array( array(Row::COLUMNS => array('label' => 'Google', 'nb_uniq_visitors' => 11, 'nb_visits' => 11,), @@ -287,7 +287,7 @@ protected function _getDataTableMapTest() return $table; } - protected function _getDataTableSimpleMapTest() + protected function getDataTableSimpleMapTest() { $array1 = array('max_actions' => 14.0, 'nb_uniq_visitors' => 57.0,); $table1 = new Simple(); @@ -308,7 +308,7 @@ protected function _getDataTableSimpleMapTest() return $table; } - protected function _getDataTableSimpleOneRowMapTest() + protected function getDataTableSimpleOneRowMapTest() { $array1 = array('nb_visits' => 14.0); $table1 = new Simple(); @@ -328,34 +328,34 @@ protected function _getDataTableSimpleOneRowMapTest() return $table; } - protected function _getDataTableMap_containsDataTableMap_normal() + protected function getDataTableMap_containsDataTableMap_normal() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableMapTest(), 'idSite'); + $table->addTable($this->getDataTableMapTest(), 'idSite'); return $table; } - protected function _getDataTableMap_containsDataTableMap_simple() + protected function getDataTableMap_containsDataTableMap_simple() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableSimpleMapTest(), 'idSite'); + $table->addTable($this->getDataTableSimpleMapTest(), 'idSite'); return $table; } - protected function _getDataTableMap_containsDataTableMap_simpleOneRow() + protected function getDataTableMap_containsDataTableMap_simpleOneRow() { $table = new DataTable\Map(); $table->setKeyName('parentArrayKey'); - $table->addTable($this->_getDataTableSimpleOneRowMapTest(), 'idSite'); + $table->addTable($this->getDataTableSimpleOneRowMapTest(), 'idSite'); return $table; } public function testXMLMapTest1() { - $dataTable = $this->_getDataTableMapTest(); + $dataTable = $this->getDataTableMapTest(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -400,7 +400,7 @@ public function testXMLMapTest1() public function testXMLArrayIsMadeOfMapTest1() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_normal(); + $dataTable = $this->getDataTableMap_containsDataTableMap_normal(); $render = new Xml(); $render->setTable($dataTable); @@ -449,7 +449,7 @@ public function testXMLArrayIsMadeOfMapTest1() public function testXMLMapTest2() { - $dataTable = $this->_getDataTableSimpleMapTest(); + $dataTable = $this->getDataTableSimpleMapTest(); $render = new Xml(); $render->setTable($dataTable); @@ -471,7 +471,7 @@ public function testXMLMapTest2() public function testXMLArrayIsMadeOfMapTest2() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_simple(); + $dataTable = $this->getDataTableMap_containsDataTableMap_simple(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -495,7 +495,7 @@ public function testXMLArrayIsMadeOfMapTest2() public function testXMLMapTest3() { - $dataTable = $this->_getDataTableSimpleOneRowMapTest(); + $dataTable = $this->getDataTableSimpleOneRowMapTest(); $render = new Xml(); $render->setTable($dataTable); @@ -512,7 +512,7 @@ public function testXMLMapTest3() public function testXMLArrayIsMadeOfMapTest3() { - $dataTable = $this->_getDataTableMap_containsDataTableMap_simpleOneRow(); + $dataTable = $this->getDataTableMap_containsDataTableMap_simpleOneRow(); $render = new Xml(); $render->setTable($dataTable); $expected = ' @@ -690,7 +690,7 @@ public function test_render_withRowsWithDataTableMetadataInSimpleTable() $this->assertEquals($expected, $actual); } - private function _getDataTableSimpleWithInvalidChars() + private function getDataTableSimpleWithInvalidChars() { $table = new DataTable\Simple(); $table->addRowsFromSimpleArray( @@ -699,7 +699,7 @@ private function _getDataTableSimpleWithInvalidChars() return $table; } - private function _getDataTableWithInvalidChars() + private function getDataTableWithInvalidChars() { $table = new DataTable(); $table->addRowsFromSimpleArray( diff --git a/tests/PHPUnit/Unit/DataTableTest.php b/tests/PHPUnit/Unit/DataTableTest.php index a1ad26caece..88bee62c054 100644 --- a/tests/PHPUnit/Unit/DataTableTest.php +++ b/tests/PHPUnit/Unit/DataTableTest.php @@ -25,7 +25,7 @@ class DataTableTest extends \PHPUnit\Framework\TestCase { public function testApplyFilter() { - $table = $this->_getDataTable1ForTest(); + $table = $this->getDataTable1ForTest(); $this->assertEquals(4, $table->getRowsCount()); $table->filter('Limit', array(2, 2)); $this->assertEquals(2, $table->getRowsCount()); @@ -33,7 +33,7 @@ public function testApplyFilter() $this->assertEquals(1, $table->getRowsCount()); } - protected function _getSimpleTestDataTable() + protected function getSimpleTestDataTable() { $table = new DataTable(); $table->addRowsFromArray( @@ -48,7 +48,7 @@ protected function _getSimpleTestDataTable() return $table; } - protected function _getSimpleTestDataTable2() + protected function getSimpleTestDataTable2() { $table = new DataTable(); $table->addRowsFromArray( @@ -65,8 +65,8 @@ protected function _getSimpleTestDataTable2() public function testMultiFilter() { - $table = $this->_getSimpleTestDataTable(); - $table2 = $this->_getSimpleTestDataTable2(); + $table = $this->getSimpleTestDataTable(); + $table2 = $this->getSimpleTestDataTable2(); $result = $table->multiFilter([$table2], function ($thisTable, $otherTable) { $thisTable->addDataTable($otherTable); @@ -89,7 +89,7 @@ public function testMultiFilter() public function testRenameColumn() { - $table = $this->_getSimpleTestDataTable(); + $table = $this->getSimpleTestDataTable(); $this->assertEquals(array(10, 90, 100, 200), $table->getColumn('count')); $this->assertEquals(200, $table->getTotalsRow()->getColumn('count')); $table->renameColumn('count', 'renamed'); @@ -100,7 +100,7 @@ public function testRenameColumn() public function testDeleteColumn() { - $table = $this->_getSimpleTestDataTable(); + $table = $this->getSimpleTestDataTable(); $this->assertEquals(array(10, 90, 100, 200), $table->getColumn('count')); $table->deleteColumn('count'); $this->assertEquals(array(false, false, false, false), $table->getColumn('count')); @@ -109,7 +109,7 @@ public function testDeleteColumn() public function testDeleteRow() { - $table = $this->_getSimpleTestDataTable(); + $table = $this->getSimpleTestDataTable(); // normal row $idToDelete = 1; @@ -126,7 +126,7 @@ public function testDeleteRow() public function testGetLastRow() { - $table = $this->_getSimpleTestDataTable(); + $table = $this->getSimpleTestDataTable(); $rowsCount = $table->getRowsCount(); $this->assertEquals($table->getLastRow(), $table->getRowFromId(DataTable::ID_SUMMARY_ROW)); @@ -137,15 +137,15 @@ public function testGetLastRow() public function testGetRowFromIdSubDataTable() { - $table1 = $this->_getDataTable1ForTest(); + $table1 = $this->getDataTable1ForTest(); $idTable1 = $table1->getId(); - $table2 = $this->_getDataTable2ForTest(); + $table2 = $this->getDataTable2ForTest(); $this->assertFalse($table2->getRowFromIdSubDataTable($idTable1)); $table2->getFirstRow()->setSubtable($table1); $this->assertEquals($table2->getRowFromIdSubDataTable($idTable1), $table2->getFirstRow()); - $table3 = $this->_getDataTable1ForTest(); + $table3 = $this->getDataTable1ForTest(); $idTable3 = $table3->getId(); $table2->getLastRow()->setSubtable($table3); $this->assertEquals($table2->getRowFromIdSubDataTable($idTable3), $table2->getLastRow()); @@ -832,7 +832,7 @@ private function addManyRows(DataTable $table, $numRows) */ public function testAddSimpleNoRowTable2() { - $table = $this->_getDataTable1ForTest(); + $table = $this->getDataTable1ForTest(); $tableEmpty = new DataTable(); $tableAfter = clone $table; $tableAfter->addDataTable($tableEmpty); @@ -844,7 +844,7 @@ public function testAddSimpleNoRowTable2() */ public function testAddSimpleNoRowTable1() { - $table = $this->_getDataTable1ForTest(); + $table = $this->getDataTable1ForTest(); $tableEmpty = new DataTable(); $tableEmpty->addDataTable($table); $this->assertTrue(DataTable::isEqual($tableEmpty, $table)); @@ -855,12 +855,12 @@ public function testAddSimpleNoRowTable1() */ public function testAddSimpleNoCommonRow() { - $table1 = $this->_getDataTable1ForTest(); - $table2 = $this->_getDataTable2ForTest(); + $table1 = $this->getDataTable1ForTest(); + $table2 = $this->getDataTable2ForTest(); $table1->addDataTable($table2); - $rowsExpected = array_merge($this->_getRowsDataTable1ForTest(), $this->_getRowsDataTable2ForTest()); + $rowsExpected = array_merge($this->getRowsDataTable1ForTest(), $this->getRowsDataTable2ForTest()); $tableExpected = new DataTable(); $tableExpected->addRowsFromArray($rowsExpected); @@ -1143,8 +1143,8 @@ public function testSubDataTableIsDestructed() public function test_serializeFails_onSubTableNotFound() { // create a simple table with a subtable - $table1 = $this->_getDataTable1ForTest(); - $table2 = $this->_getDataTable2ForTest(); + $table1 = $this->getDataTable1ForTest(); + $table2 = $this->getDataTable2ForTest(); $table2->getFirstRow()->setSubtable($table1); $idSubtable = 1; // subtableIds are consecutive, we cannot use $table->getId() @@ -1184,7 +1184,7 @@ public function test_serializeFails_onSubTableNotFound() public function testMergeSubtablesKeepsMetadata() { - $dataTable = $this->_getDataTable1ForTest(); + $dataTable = $this->getDataTable1ForTest(); $dataTable->setMetadata('additionalMetadata', 'test'); $dataTable = $dataTable->mergeSubtables(); $this->assertEquals('test', $dataTable->getMetadata('additionalMetadata')); @@ -1329,23 +1329,23 @@ private function createDataTable($rows) return $useless1; } - protected function _getDataTable1ForTest() + protected function getDataTable1ForTest() { - $rows = $this->_getRowsDataTable1ForTest(); + $rows = $this->getRowsDataTable1ForTest(); $table = new DataTable(); $table->addRowsFromArray($rows); return $table; } - protected function _getDataTable2ForTest() + protected function getDataTable2ForTest() { - $rows = $this->_getRowsDataTable2ForTest(); + $rows = $this->getRowsDataTable2ForTest(); $table = new DataTable(); $table->addRowsFromArray($rows); return $table; } - protected function _getRowsDataTable1ForTest() + protected function getRowsDataTable1ForTest() { $rows = array( array(Row::COLUMNS => array('label' => 'google', 'visits' => 1)), @@ -1357,7 +1357,7 @@ protected function _getRowsDataTable1ForTest() return $rows; } - protected function _getRowsDataTable2ForTest() + protected function getRowsDataTable2ForTest() { $rows = array( array(Row::COLUMNS => array('label' => 'test', 'visits' => 1)), diff --git a/tests/PHPUnit/Unit/Period/RangeTest.php b/tests/PHPUnit/Unit/Period/RangeTest.php index d3ede4a10d2..f1d4796845b 100644 --- a/tests/PHPUnit/Unit/Period/RangeTest.php +++ b/tests/PHPUnit/Unit/Period/RangeTest.php @@ -552,12 +552,12 @@ public function testRangeLastmonth_onLastDayOfMonth() $end = Date::factory('2013-10-31'); $range = new Range('month', 'last10', 'UTC', $end); - $correct = array(); + $correct = []; for ($i = 0; $i < 10; $i++) { $date = $end->subMonth($i); - $week = new Month($date); + $month = new Month($date); - $correct[] = implode(',', $week->toString()); + $correct[] = implode(',', $month->toString()); } $correct = array_reverse($correct); @@ -565,18 +565,18 @@ public function testRangeLastmonth_onLastDayOfMonth() $this->assertEquals($correct, $range->toString()); } - public function _testRangePreviousmonth_onFirstOfMonth() + public function testRangePreviousmonthOnFirstOfMonth() { $end = Date::factory('2013-11-01'); $range = new Range('month', 'previous10', 'UTC', $end); $end = $end->subMonth(1); - $correct = array(); + $correct = []; for ($i = 0; $i < 10; $i++) { $date = $end->subMonth($i); - $week = new Month($date); + $month = new Month($date); - $correct[] = $week->toString(); + $correct[] = implode(',', $month->toString()); } $correct = array_reverse($correct); @@ -584,17 +584,17 @@ public function _testRangePreviousmonth_onFirstOfMonth() $this->assertEquals($correct, $range->toString()); } - public function _testRangeLastmonth_onFirstOfMonth() + public function testRangeLastmonthOnFirstOfMonth() { $end = Date::factory('2013-11-01'); $range = new Range('month', 'last10', 'UTC', $end); - $correct = array(); + $correct = []; for ($i = 0; $i < 10; $i++) { $date = $end->subMonth($i); - $week = new Month($date); + $month = new Month($date); - $correct[] = $week->toString(); + $correct[] = implode(',', $month->toString()); } $correct = array_reverse($correct);