From 2cc4c327f974b77f50229453aebb3f49d888812a Mon Sep 17 00:00:00 2001 From: sgiehl Date: Wed, 24 Apr 2024 08:53:41 +0200 Subject: [PATCH 1/2] [Coding Style] Use camel case for method names in more core plugin tests --- .../Insights/tests/Integration/ApiTest.php | 28 +++---- .../Insights/tests/Integration/ModelTest.php | 26 +++---- .../Insights/tests/Unit/InsightReportTest.php | 32 ++++---- plugins/Installation/tests/System/APITest.php | 8 +- .../tests/Integration/ModelTest.php | 10 +-- plugins/Live/tests/Integration/ModelTest.php | 74 +++++++++---------- plugins/Live/tests/System/ApiCounterTest.php | 16 ++-- plugins/Login/tests/Integration/APITest.php | 6 +- plugins/Login/tests/Integration/LoginTest.php | 62 ++++++++-------- plugins/Login/tests/Integration/ModelTest.php | 18 ++--- .../Integration/PasswordVerifierTest.php | 16 ++-- .../Security/BruteForceDetectionTest.php | 24 +++--- .../Integration/SessionInitializerTest.php | 4 +- .../tests/Integration/SystemSettingsTest.php | 26 +++---- .../Marketplace/tests/Integration/ApiTest.php | 46 ++++++------ .../tests/Integration/ClientTest.php | 4 +- .../tests/Integration/EnvironmentTest.php | 16 ++-- .../Integration/Input/PluginNameTest.php | 4 +- .../tests/Integration/LicenseKeyTest.php | 12 +-- .../Plugins/InvalidLicensesTest.php | 36 ++++----- .../tests/Integration/PluginsTest.php | 4 +- .../tests/Integration/ServiceTest.php | 6 +- .../Integration/UpdateCommunicationTest.php | 14 ++-- .../tests/System/Api/ClientTest.php | 26 +++---- .../tests/System/Api/ServiceTest.php | 26 +++---- .../Marketplace/tests/Unit/ConsumerTest.php | 14 ++-- .../tests/System/TrackerLoggingTest.php | 6 +- .../Formatter/LineMessageFormatterTest.php | 20 +---- .../Unit/Processor/ClassNameProcessorTest.php | 5 +- .../ExceptionToTextProcessorTest.php | 43 +++++------ .../Unit/Processor/RequestIdProcessorTest.php | 10 +-- .../Unit/Processor/SprintfProcessorTest.php | 15 +--- .../Unit/Processor/TokenProcessorTest.php | 12 +-- 33 files changed, 312 insertions(+), 357 deletions(-) diff --git a/plugins/Insights/tests/Integration/ApiTest.php b/plugins/Insights/tests/Integration/ApiTest.php index 49ba8034c21..4e7a6b051c7 100644 --- a/plugins/Insights/tests/Integration/ApiTest.php +++ b/plugins/Insights/tests/Integration/ApiTest.php @@ -62,7 +62,7 @@ public function tearDown(): void * '/New1', +5 // 100% * '/New2' +2 // 100% */ - public function test_getInsights_ShouldReturnCorrectMetadata() + public function testGetInsightsShouldReturnCorrectMetadata() { $insights = $this->requestInsights(array()); $metadata = $insights->getAllTableMetadata(); @@ -125,7 +125,7 @@ public function test_getInsights_ShouldReturnCorrectMetadata() $this->assertEqualsWithDelta($expectedMetadata, $metadata, 0.0001); } - public function test_getInsights_ShouldGoBackInPastDependingOnComparedToParameter() + public function testGetInsightsShouldGoBackInPastDependingOnComparedToParameter() { $insights = $this->requestInsights(array('comparedToXPeriods' => 3)); @@ -134,7 +134,7 @@ public function test_getInsights_ShouldGoBackInPastDependingOnComparedToParamete $this->assertEquals('2010-12-11', $metadata['lastDate']); } - public function test_getInsights_ShouldGoBackInPastDependingOnPeriod() + public function testGetInsightsShouldGoBackInPastDependingOnPeriod() { $insights = $this->requestInsights(array('period' => 'month')); @@ -143,7 +143,7 @@ public function test_getInsights_ShouldGoBackInPastDependingOnPeriod() $this->assertEquals('2010-11-14', $metadata['lastDate']); } - public function test_getInsights_ShouldReturnAllRowsIfMinValuesArelow() + public function testGetInsightsShouldReturnAllRowsIfMinValuesArelow() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 1)); @@ -159,21 +159,21 @@ public function test_getInsights_ShouldReturnAllRowsIfMinValuesArelow() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldReturnReturnNothingIfminImpactPercentIsTooHigh() + public function testGetInsightsShouldReturnReturnNothingIfminImpactPercentIsTooHigh() { $insights = $this->requestInsights(array('minImpactPercent' => 10000, 'minGrowthPercent' => 0)); $this->assertRows(array(), $insights); } - public function test_getInsights_ShouldReturnReturnNothingIfMinGrowthIsHigh() + public function testGetInsightsShouldReturnReturnNothingIfMinGrowthIsHigh() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 10000)); $this->assertRows(array(), $insights); } - public function test_getInsights_ShouldOrderAbsoluteByDefault() + public function testGetInsightsShouldOrderAbsoluteByDefault() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 0)); @@ -189,7 +189,7 @@ public function test_getInsights_ShouldOrderAbsoluteByDefault() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldBeAbleToOrderRelative() + public function testGetInsightsShouldBeAbleToOrderRelative() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 0, 'orderBy' => 'relative')); @@ -205,7 +205,7 @@ public function test_getInsights_ShouldBeAbleToOrderRelative() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldBeAbleToOrderByImportance() + public function testGetInsightsShouldBeAbleToOrderByImportance() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 0, 'orderBy' => 'importance')); @@ -221,7 +221,7 @@ public function test_getInsights_ShouldBeAbleToOrderByImportance() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldApplyTheLimit() + public function testGetInsightsShouldApplyTheLimit() { $insights = $this->requestInsights(array('limitIncreaser' => 1, 'limitDecreaser' => 1)); @@ -232,7 +232,7 @@ public function test_getInsights_ShouldApplyTheLimit() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldBeAbleToShowOnlyMovers() + public function testGetInsightsShouldBeAbleToShowOnlyMovers() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 0, 'filterBy' => 'movers')); @@ -244,7 +244,7 @@ public function test_getInsights_ShouldBeAbleToShowOnlyMovers() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldBeAbleToShowOnlyNew() + public function testGetInsightsShouldBeAbleToShowOnlyNew() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 0, 'filterBy' => 'new')); @@ -255,7 +255,7 @@ public function test_getInsights_ShouldBeAbleToShowOnlyNew() $this->assertRows($expectedLabels, $insights); } - public function test_getInsights_ShouldBeAbleToShowOnlyDisappeared() + public function testGetInsightsShouldBeAbleToShowOnlyDisappeared() { $insights = $this->requestInsights(array('minImpactPercent' => 0, 'minGrowthPercent' => 0, 'filterBy' => 'disappeared')); @@ -266,7 +266,7 @@ public function test_getInsights_ShouldBeAbleToShowOnlyDisappeared() $this->assertRows($expectedLabels, $insights); } - public function test_canGenerateInsights() + public function testCanGenerateInsights() { $this->assertTrue($this->api->canGenerateInsights('2012-12-12', 'day')); $this->assertTrue($this->api->canGenerateInsights('2012-12-12', 'week')); diff --git a/plugins/Insights/tests/Integration/ModelTest.php b/plugins/Insights/tests/Integration/ModelTest.php index 25a4956ac50..4fa877ecb77 100644 --- a/plugins/Insights/tests/Integration/ModelTest.php +++ b/plugins/Insights/tests/Integration/ModelTest.php @@ -39,7 +39,7 @@ public function setUp(): void $this->model = StaticContainer::getContainer()->make('Piwik\Plugins\Insights\Model'); } - public function test_requestReport_shouldReturnTheDataTableOfTheReport_AndContainReportTotals() + public function testRequestReportShouldReturnTheDataTableOfTheReportAndContainReportTotals() { $idSite = self::$fixture->idSite; $date = self::$fixture->date1; @@ -53,7 +53,7 @@ public function test_requestReport_shouldReturnTheDataTableOfTheReport_AndContai $this->assertEquals(50, $totals[$metric]); } - public function test_getReportByUniqueId_shouldReturnReport() + public function testGetReportByUniqueIdShouldReturnReport() { $report = $this->model->getReportByUniqueId(self::$fixture->idSite, 'Actions_getPageUrls'); @@ -61,7 +61,7 @@ public function test_getReportByUniqueId_shouldReturnReport() $this->assertEquals('getPageUrls', $report['action']); } - public function test_getLastDate_shouldReturnTheLastDateDependingOnPeriod() + public function testGetLastDateShouldReturnTheLastDateDependingOnPeriod() { $date = $this->model->getLastDate('2012-12-12', 'day', 1); $this->assertEquals('2012-12-11', $date); @@ -82,7 +82,7 @@ public function test_getLastDate_shouldReturnTheLastDateDependingOnPeriod() $this->assertEquals('2012-11-01', $date); } - public function test_getLastDate_shouldReturnTheLastDateDependingOnComparedTo() + public function testGetLastDateShouldReturnTheLastDateDependingOnComparedTo() { $date = $this->model->getLastDate('2012-12-12', 'day', 1); $this->assertEquals('2012-12-11', $date); @@ -94,7 +94,7 @@ public function test_getLastDate_shouldReturnTheLastDateDependingOnComparedTo() $this->assertEquals('2012-12-05', $date); } - public function test_getMetricTotalValue_shouldReturnTheTotalValueFromMetadata() + public function testGetMetricTotalValueShouldReturnTheTotalValueFromMetadata() { $table = $this->getTableWithTotal('17'); @@ -104,7 +104,7 @@ public function test_getMetricTotalValue_shouldReturnTheTotalValueFromMetadata() self::assertIsInt($total); } - public function test_getMetricTotalValue_shouldReturnZeroIfMetricHasNoTotal() + public function testGetMetricTotalValueShouldReturnZeroIfMetricHasNoTotal() { $table = new DataTable(); $table->setMetadata('totals', array('nb_visits' => '17')); @@ -114,14 +114,14 @@ public function test_getMetricTotalValue_shouldReturnZeroIfMetricHasNoTotal() $this->assertEquals(0, $total); } - public function test_getLastDate_shouldThrowExceptionIfNotPossibleToGetLastDate() + public function testGetLastDateShouldThrowExceptionIfNotPossibleToGetLastDate() { $this->expectException(\Exception::class); $this->model->getLastDate('last10', 'day', 1); } - public function test_getTotalValue_shouldCalculateTotals() + public function testGetTotalValueShouldCalculateTotals() { $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'nb_visits', false); $this->assertEquals(50, $total); @@ -130,33 +130,33 @@ public function test_getTotalValue_shouldCalculateTotals() $this->assertEquals(59, $total); } - public function test_getTotalValue_shouldCalculateTotalsAndApplySegment() + public function testGetTotalValueShouldCalculateTotalsAndApplySegment() { $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'nb_visits', 'resolution==1000x1001'); $this->assertEquals(1, $total); } - public function test_getTotalValue_shouldReturnZero_IfColumnDoesNotExist() + public function testGetTotalValueShouldReturnZeroIfColumnDoesNotExist() { $total = $this->model->getTotalValue(self::$fixture->idSite, 'day', self::$fixture->date1, 'unknown_ColUmn', false); $this->assertEquals(0, $total); } - public function test_getRelevantTotalValue_shouldReturnTotalValue_IfMetricTotalIsHighEnough() + public function testGetRelevantTotalValueShouldReturnTotalValueIfMetricTotalIsHighEnough() { $table = $this->getTableWithTotal(25); $total = $this->model->getRelevantTotalValue($table, 'nb_visits', 50); $this->assertEquals(50, $total); } - public function test_getRelevantTotalValue_shouldReturnMetricTotal_IfMetricTotalIsHigherThanTotalValue() + public function testGetRelevantTotalValueShouldReturnMetricTotalIfMetricTotalIsHigherThanTotalValue() { $table = $this->getTableWithTotal(80); $total = $this->model->getRelevantTotalValue($table, 'nb_visits', 50); $this->assertEquals(80, $total); } - public function test_getRelevantTotalValue_shouldReturnMetricTotal_IfMetricTotalIsTooLow() + public function testGetRelevantTotalValueShouldReturnMetricTotalIfMetricTotalIsTooLow() { $table = $this->getTableWithTotal(24); $total = $this->model->getRelevantTotalValue($table, 'nb_visits', 50); diff --git a/plugins/Insights/tests/Unit/InsightReportTest.php b/plugins/Insights/tests/Unit/InsightReportTest.php index ed9004a0e86..85e6d8b89bb 100644 --- a/plugins/Insights/tests/Unit/InsightReportTest.php +++ b/plugins/Insights/tests/Unit/InsightReportTest.php @@ -94,7 +94,7 @@ public function setUp(): void /** * @dataProvider provideOrderTestData */ - public function test_generateInsight_Order($orderBy, $expectedOrder) + public function testGenerateInsightOrder($orderBy, $expectedOrder) { $report = $this->generateInsight(2, 2, 2, 17, -17, $orderBy); @@ -110,7 +110,7 @@ public function provideOrderTestData() ); } - public function test_generateInsight_Order_ShouldThrowException_IfInvalid() + public function testGenerateInsightOrderShouldThrowExceptionIfInvalid() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Unsupported orderBy'); @@ -121,7 +121,7 @@ public function test_generateInsight_Order_ShouldThrowException_IfInvalid() /** * @dataProvider provideMinGrowthTestData */ - public function test_generateInsight_MinGrowth($minGrowthPositive, $minGrowthNegative, $expectedOrder) + public function testGenerateInsightMinGrowth($minGrowthPositive, $minGrowthNegative, $expectedOrder) { $report = $this->generateInsight(2, 2, 2, $minGrowthPositive, $minGrowthNegative, InsightReport::ORDER_BY_ABSOLUTE); $this->assertOrder($report, $expectedOrder); @@ -145,7 +145,7 @@ public function provideMinGrowthTestData() /** * @dataProvider provideLimitTestData */ - public function test_generateInsight_Limit($limitIncrease, $limitDecrease, $expectedOrder) + public function testGenerateInsightLimit($limitIncrease, $limitDecrease, $expectedOrder) { $report = $this->generateInsight(2, 2, 2, 20, -20, InsightReport::ORDER_BY_ABSOLUTE, $limitIncrease, $limitDecrease); @@ -162,7 +162,7 @@ public function provideLimitTestData() ); } - public function test_generateInsight_NoMovers() + public function testGenerateInsightNoMovers() { $report = $this->generateInsight(-1, 2, 2, 20, -20); @@ -172,7 +172,7 @@ public function test_generateInsight_NoMovers() /** * @dataProvider provideMinImpactMoversTestData */ - public function test_generateInsight_MinImpactMovers($minMoversPercent, $expectedOrder) + public function testGenerateInsightMinImpactMovers($minMoversPercent, $expectedOrder) { $report = $this->generateInsight($minMoversPercent, -1, -1, 17, -17); @@ -189,7 +189,7 @@ public function provideMinImpactMoversTestData() ); } - public function test_generateInsight_NoNew() + public function testGenerateInsightNoNew() { $report = $this->generateInsight(2, -1, 2, 17, -17); @@ -199,7 +199,7 @@ public function test_generateInsight_NoNew() /** * @dataProvider provideMinImpactNewTestData */ - public function test_generateInsight_MinImpactNew($minNewPercent, $expectedOrder) + public function testGenerateInsightMinImpactNew($minNewPercent, $expectedOrder) { $report = $this->generateInsight(-1, $minNewPercent, -1, 17, -17); @@ -217,7 +217,7 @@ public function provideMinImpactNewTestData() ); } - public function test_generateInsight_NoDisappeared() + public function testGenerateInsightNoDisappeared() { $report = $this->generateInsight(2, 2, -1, 17, -17); @@ -227,7 +227,7 @@ public function test_generateInsight_NoDisappeared() /** * @dataProvider provideMinImpactDisappearedData */ - public function test_generateInsight_MinDisappeared($minDisappearedPercent, $expectedOrder) + public function testGenerateInsightMinDisappeared($minDisappearedPercent, $expectedOrder) { $report = $this->generateInsight(-1, -1, $minDisappearedPercent, 17, -17); $this->assertOrder($report, $expectedOrder); @@ -245,7 +245,7 @@ public function provideMinImpactDisappearedData() ); } - public function test_generateInsights_ShouldSetCorrectMetadata() + public function testGenerateInsightsShouldSetCorrectMetadata() { $report = $this->generateInsight(2, 4, 8, 17, -21); $metadata = $report->getAllTableMetadata(); @@ -277,7 +277,7 @@ public function test_generateInsights_ShouldSetCorrectMetadata() $this->assertEquals($expectedMetadata, $metadata); } - public function test_markMoversAndShakers() + public function testMarkMoversAndShakers() { $report = $this->generateInsight(2, 2, 2, 5, -5); $this->insightReport->markMoversAndShakers($report, $this->currentTable, $this->pastTable, 160, 100); @@ -289,7 +289,7 @@ public function test_markMoversAndShakers() $this->assertMoversAndShakers($report, $movers, $nonMovers); } - public function test_markMoversAndShakers_shouldAddMetadata() + public function testMarkMoversAndShakersShouldAddMetadata() { $report = $this->generateInsight(2, 2, 2, 5, -5); $this->insightReport->markMoversAndShakers($report, $this->currentTable, $this->pastTable, 200, 100); @@ -302,7 +302,7 @@ public function test_markMoversAndShakers_shouldAddMetadata() $this->assertEquals(100, $metadata['evolutionTotal']); } - public function test_generateMoversAndShakers() + public function testGenerateMoversAndShakers() { // increase by 60% --> minGrowth 80% $report = $this->generateMoverAndShaker(160, 100); @@ -334,7 +334,7 @@ private function assertMoversAndShakers(DataTable $report, $movers, $nonMovers) } } - public function test_generateMoversAndShakers_Metadata() + public function testGenerateMoversAndShakersMetadata() { $report = $this->generateMoverAndShaker(150, 50); $metadata = $report->getAllTableMetadata(); @@ -361,7 +361,7 @@ public function test_generateMoversAndShakers_Metadata() $this->assertEquals(-50, $metadata['evolutionTotal']); } - public function test_generateMoversAndShakers_ParameterCalculation() + public function testGenerateMoversAndShakersParameterCalculation() { $report = $this->generateMoverAndShaker(3000, 50); // evolution of 5900% $metadata = $report->getAllTableMetadata(); diff --git a/plugins/Installation/tests/System/APITest.php b/plugins/Installation/tests/System/APITest.php index 97063550e8e..e974b19c3d1 100644 --- a/plugins/Installation/tests/System/APITest.php +++ b/plugins/Installation/tests/System/APITest.php @@ -34,13 +34,13 @@ public static function setUpBeforeClass(): void $testingEnvironment->save(); } - public function test_shouldReturnHttp500_IfWrongDbInfo() + public function testShouldReturnHttp500IfWrongDbInfo() { $response = $this->sendHttpRequest($this->getUrl()); $this->assertEquals(500, $response['status']); } - public function test_shouldReturnValidApiResponse_IfWrongDbInfo_formatXML() + public function testShouldReturnValidApiResponseIfWrongDbInfoFormatXML() { $response = $this->sendHttpRequest($this->getUrl()); @@ -51,7 +51,7 @@ public function test_shouldReturnValidApiResponse_IfWrongDbInfo_formatXML() $this->assertStringEndsWith('', $data); } - public function test_shouldReturnValidApiResponse_IfWrongDbInfo_formatJSON() + public function testShouldReturnValidApiResponseIfWrongDbInfoFormatJSON() { $response = $this->sendHttpRequest($this->getUrl() . '&format=json'); @@ -61,7 +61,7 @@ public function test_shouldReturnValidApiResponse_IfWrongDbInfo_formatJSON() self::assertStringContainsString('Database access denied', $data); } - public function test_shouldReturnEmptyResultWhenNotInstalledAndDispatchIsDisabled() + public function testShouldReturnEmptyResultWhenNotInstalledAndDispatchIsDisabled() { $url = Fixture::getTestRootUrl() . 'nodispatchnotinstalled.php'; $response = $this->sendHttpRequest($url); diff --git a/plugins/LanguagesManager/tests/Integration/ModelTest.php b/plugins/LanguagesManager/tests/Integration/ModelTest.php index ad23a2fbd84..1d8dd5ec9b1 100644 --- a/plugins/LanguagesManager/tests/Integration/ModelTest.php +++ b/plugins/LanguagesManager/tests/Integration/ModelTest.php @@ -32,7 +32,7 @@ public function setUp(): void parent::setUp(); } - public function test_install_ShouldNotFailAndActuallyCreateTheDatabases() + public function testInstallShouldNotFailAndActuallyCreateTheDatabases() { $this->assertContainTables(array('user_language')); @@ -40,7 +40,7 @@ public function test_install_ShouldNotFailAndActuallyCreateTheDatabases() $this->assertCount(3, $columns); } - public function test_uninstall_ShouldNotFailAndRemovesAllAlertTables() + public function testUninstallShouldNotFailAndRemovesAllAlertTables() { Model::uninstall(); @@ -49,7 +49,7 @@ public function test_uninstall_ShouldNotFailAndRemovesAllAlertTables() Model::install(); } - public function test_handlesUserLanguageEntriesCorrectly() + public function testHandlesUserLanguageEntriesCorrectly() { $this->model->setLanguageForUser('admin', 'de'); @@ -62,7 +62,7 @@ public function test_handlesUserLanguageEntriesCorrectly() $this->assertTableEntryCount(0); } - public function test_handlesUserTimeFormatEntriesCorrectly() + public function testHandlesUserTimeFormatEntriesCorrectly() { $this->model->set12HourClock('admin', false); @@ -75,7 +75,7 @@ public function test_handlesUserTimeFormatEntriesCorrectly() $this->assertTableEntryCount(0); } - public function test_handlesUserLanguageAndTimeFormatEntriesCorrectly() + public function testHandlesUserLanguageAndTimeFormatEntriesCorrectly() { $this->model->setLanguageForUser('admin', 'de'); diff --git a/plugins/Live/tests/Integration/ModelTest.php b/plugins/Live/tests/Integration/ModelTest.php index 424929dd757..ed3f76a0b98 100644 --- a/plugins/Live/tests/Integration/ModelTest.php +++ b/plugins/Live/tests/Integration/ModelTest.php @@ -37,7 +37,7 @@ public function setUp(): void Fixture::createWebsite('2010-01-01'); } - public function test_getStandAndEndDate_usesNowWhenDateOutOfRange() + public function testGetStandAndEndDateUsesNowWhenDateOutOfRange() { $model = new Model(); list($dateStart, $dateEnd) = $model->getStartAndEndDate($idSite = 1, 'year', '2025-01-01'); @@ -49,7 +49,7 @@ public function test_getStandAndEndDate_usesNowWhenDateOutOfRange() $this->assertNotEquals($dateStart->getDatetime(), $dateEnd->getDatetime()); } - public function test_getStandAndEndDate_usesNowWhenEndDateOutOfRange() + public function testGetStandAndEndDateUsesNowWhenEndDateOutOfRange() { $model = new Model(); list($dateStart, $dateEnd) = $model->getStartAndEndDate($idSite = 1, 'year', date('Y') . '-01-01'); @@ -73,7 +73,7 @@ private function getValidNowDates() return $validDates; } - public function test_handleMaxExecutionTimeError_doesNotThrowExceptionWhenNotExceededTime() + public function testHandleMaxExecutionTimeErrorDoesNotThrowExceptionWhenNotExceededTime() { self::expectNotToPerformAssertions(); @@ -89,7 +89,7 @@ public function test_handleMaxExecutionTimeError_doesNotThrowExceptionWhenNotExc Model::handleMaxExecutionTimeError($db, $e, $segment, $dateStart, $dateEnd, $minTimestamp, $limit, [$sql, $bind]); } - public function test_handleMaxExecutionTimeError_whenTimeIsExceeded_noReasonFound() + public function testHandleMaxExecutionTimeErrorWhenTimeIsExceededNoReasonFound() { $this->expectException(\Piwik\Plugins\Live\Exception\MaxExecutionTimeExceededException::class); $this->expectExceptionMessage('Live_QueryMaxExecutionTimeExceeded Live_QueryMaxExecutionTimeExceededReasonUnknown'); @@ -106,7 +106,7 @@ public function test_handleMaxExecutionTimeError_whenTimeIsExceeded_noReasonFoun Model::handleMaxExecutionTimeError($db, $e, $segment, $dateStart, $dateEnd, $minTimestamp, $limit, [$sql, $bind]); } - public function test_handleMaxExecutionTimeError_whenTimeIsExceeded_manyReasonsFound() + public function testHandleMaxExecutionTimeErrorWhenTimeIsExceededManyReasonsFound() { $this->expectException(\Piwik\Plugins\Live\Exception\MaxExecutionTimeExceededException::class); $this->expectExceptionMessage('Live_QueryMaxExecutionTimeExceeded Live_QueryMaxExecutionTimeExceededReasonDateRange Live_QueryMaxExecutionTimeExceededReasonSegment Live_QueryMaxExecutionTimeExceededLimit'); @@ -121,7 +121,7 @@ public function test_handleMaxExecutionTimeError_whenTimeIsExceeded_manyReasonsF Model::handleMaxExecutionTimeError($db, $e, $segment, $dateStart, $dateEnd, $minTimestamp, $limit, ['param' => 'value']); } - public function test_getLastMinutesCounterForQuery_maxExecutionTime() + public function testGetLastMinutesCounterForQueryMaxExecutionTime() { if (SystemTestCase::isMysqli()) { $this->markTestSkipped('max_execution_time not supported on mysqli'); @@ -138,7 +138,7 @@ public function test_getLastMinutesCounterForQuery_maxExecutionTime() $model->getNumVisits(1, 999999, ''); } - public function test_queryAdjacentVisitorId_maxExecutionTime() + public function testQueryAdjacentVisitorIdMaxExecutionTime() { if (SystemTestCase::isMysqli()) { $this->markTestSkipped('max_execution_time not supported on mysqli'); @@ -154,7 +154,7 @@ public function test_queryAdjacentVisitorId_maxExecutionTime() $model->queryAdjacentVisitorId(1, '1234567812345678', Date::yesterday()->getDatetime(), '', true); } - public function test_getStandAndEndDate() + public function testGetStandAndEndDate() { $model = new Model(); list($dateStart, $dateEnd) = $model->getStartAndEndDate($idSite = 1, 'year', '2018-02-01'); @@ -163,55 +163,55 @@ public function test_getStandAndEndDate() $this->assertEquals('2019-01-01 00:00:00', $dateEnd->getDatetime()); } - public function test_isLookingAtMoreThanOneDay_whenNoDateSet() + public function testIsLookingAtMoreThanOneDayWhenNoDateSet() { $model = new Model(); $this->assertTrue($model->isLookingAtMoreThanOneDay(null, null, null)); } - public function test_isLookingAtMoreThanOneDay_whenNoStartDateSet() + public function testIsLookingAtMoreThanOneDayWhenNoStartDateSet() { $model = new Model(); $this->assertTrue($model->isLookingAtMoreThanOneDay(null, Date::now(), null)); } - public function test_isLookingAtMoreThanOneDay_whenNoStartDateSetAndMinTimestampIsOld() + public function testIsLookingAtMoreThanOneDayWhenNoStartDateSetAndMinTimestampIsOld() { $model = new Model(); $this->assertTrue($model->isLookingAtMoreThanOneDay(null, Date::now(), Date::now()->subDay(5)->getTimestamp())); } - public function test_isLookingAtMoreThanOneDay_whenNoStartDateSetButMinTimestampIsRecent() + public function testIsLookingAtMoreThanOneDayWhenNoStartDateSetButMinTimestampIsRecent() { $model = new Model(); $this->assertFalse($model->isLookingAtMoreThanOneDay(null, Date::now(), Date::now()->subHour(5)->getTimestamp())); } - public function test_isLookingAtMoreThanOneDay_whenNoEndDateIsSet_StartDateIsOld() + public function testIsLookingAtMoreThanOneDayWhenNoEndDateIsSetStartDateIsOld() { $model = new Model(); $this->assertTrue($model->isLookingAtMoreThanOneDay(Date::now()->subDay(5), null, null)); } - public function test_isLookingAtMoreThanOneDay_whenNoEndDateIsSet_StartDateIsRecent() + public function testIsLookingAtMoreThanOneDayWhenNoEndDateIsSetStartDateIsRecent() { $model = new Model(); $this->assertFalse($model->isLookingAtMoreThanOneDay(Date::now()->subHour(5), null, null)); } - public function test_isLookingAtMoreThanOneDay_whenStartAndEndDateIsSet_onlyOneDay() + public function testIsLookingAtMoreThanOneDayWhenStartAndEndDateIsSetOnlyOneDay() { $model = new Model(); $this->assertFalse($model->isLookingAtMoreThanOneDay(Date::yesterday()->subDay(1), Date::yesterday(), null)); } - public function test_isLookingAtMoreThanOneDay_whenStartAndEndDateIsSet_moreThanOneDay() + public function testIsLookingAtMoreThanOneDayWhenStartAndEndDateIsSetMoreThanOneDay() { $model = new Model(); $this->assertTrue($model->isLookingAtMoreThanOneDay(Date::yesterday()->subDay(2), Date::yesterday(), null)); } - public function test_makeLogVisitsQueryString() + public function testMakeLogVisitsQueryString() { $model = new Model(); list($dateStart, $dateEnd) = $model->getStartAndEndDate($idSite = 1, 'month', '2010-01-01'); @@ -242,7 +242,7 @@ public function test_makeLogVisitsQueryString() $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedBind), SegmentTest::removeExtraWhiteSpaces($bind)); } - public function test_makeLogVisitsQueryString_withMultipleIdSites() + public function testMakeLogVisitsQueryStringWithMultipleIdSites() { Piwik::addAction('Live.API.getIdSitesString', function (&$idSites) { $idSites = array(2,3,4); @@ -279,7 +279,7 @@ public function test_makeLogVisitsQueryString_withMultipleIdSites() $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedBind), SegmentTest::removeExtraWhiteSpaces($bind)); } - public function test_makeLogVisitsQueryStringWithOffset() + public function testMakeLogVisitsQueryStringWithOffset() { $model = new Model(); @@ -312,7 +312,7 @@ public function test_makeLogVisitsQueryStringWithOffset() } - public function test_makeLogVisitsQueryString_whenSegment() + public function testMakeLogVisitsQueryStringWhenSegment() { $model = new Model(); list($dateStart, $dateEnd) = $model->getStartAndEndDate($idSite = 1, 'month', '2010-01-01'); @@ -350,7 +350,7 @@ public function test_makeLogVisitsQueryString_whenSegment() $this->assertEquals(SegmentTest::removeExtraWhiteSpaces($expectedBind), SegmentTest::removeExtraWhiteSpaces($bind)); } - public function test_makeLogVisitsQueryString_addsMaxExecutionHintIfConfigured() + public function testMakeLogVisitsQueryStringAddsMaxExecutionHintIfConfigured() { $this->setMaxExecutionTime(30); @@ -375,7 +375,7 @@ public function test_makeLogVisitsQueryString_addsMaxExecutionHintIfConfigured() $this->assertStringStartsWith($expectedSql, trim($sql)); } - public function test_makeLogVisitsQueryString_doesNotAddsMaxExecutionHintForVisitorIds() + public function testMakeLogVisitsQueryStringDoesNotAddsMaxExecutionHintForVisitorIds() { $this->setMaxExecutionTime(30); @@ -400,105 +400,105 @@ public function test_makeLogVisitsQueryString_doesNotAddsMaxExecutionHintForVisi $this->assertStringStartsWith($expectedSql, trim($sql)); } - public function test_splitDatesIntoMultipleQueries_notMoreThanADayUsesOnlyOneQuery() + public function testSplitDatesIntoMultipleQueriesNotMoreThanADayUsesOnlyOneQuery() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-01-02 00:00:00', $limit = 5, $offset = 0); $this->assertEquals(array('2010-01-01 00:00:00 2010-01-02 00:00:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_notMoreThanADayUsesOnlyOneQueryDesc() + public function testSplitDatesIntoMultipleQueriesNotMoreThanADayUsesOnlyOneQueryDesc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-01-02 00:00:00', $limit = 5, $offset = 0, 'asc'); $this->assertEquals(array('2010-01-01 00:00:00 2010-01-02 00:00:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanADayLessThanAWeek() + public function testSplitDatesIntoMultipleQueriesMoreThanADayLessThanAWeek() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-01-02 00:01:00', $limit = 5, $offset = 0); $this->assertEquals(array('2010-01-01 00:01:00 2010-01-02 00:01:00', '2010-01-01 00:00:00 2010-01-01 00:00:59'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanADayLessThanAWeekAsc() + public function testSplitDatesIntoMultipleQueriesMoreThanADayLessThanAWeekAsc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-01-02 00:01:00', $limit = 5, $offset = 0, 'asc'); $this->assertEquals(array('2010-01-01 00:00:00 2010-01-01 23:59:59', '2010-01-02 00:00:00 2010-01-02 00:01:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanAWeekLessThanMonth() + public function testSplitDatesIntoMultipleQueriesMoreThanAWeekLessThanMonth() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-01-20 04:01:00', $limit = 5, $offset = 0); $this->assertEquals(array('2010-01-19 04:01:00 2010-01-20 04:01:00', '2010-01-12 04:01:00 2010-01-19 04:00:59', '2010-01-01 00:00:00 2010-01-12 04:00:59'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanAWeekLessThanMonthAsc() + public function testSplitDatesIntoMultipleQueriesMoreThanAWeekLessThanMonthAsc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-01-20 04:01:00', $limit = 5, $offset = 0, 'asc'); $this->assertEquals(array('2010-01-01 00:00:00 2010-01-01 23:59:59', '2010-01-02 00:00:00 2010-01-08 23:59:59', '2010-01-09 00:00:00 2010-01-20 04:01:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanMonthLessThanYear() + public function testSplitDatesIntoMultipleQueriesMoreThanMonthLessThanYear() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-02-20 04:01:00', $limit = 5, $offset = 0); $this->assertEquals(array('2010-02-19 04:01:00 2010-02-20 04:01:00', '2010-02-12 04:01:00 2010-02-19 04:00:59', '2010-01-13 04:01:00 2010-02-12 04:00:59', '2010-01-01 00:00:00 2010-01-13 04:00:59'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanMonthLessThanYearAsc() + public function testSplitDatesIntoMultipleQueriesMoreThanMonthLessThanYearAsc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2010-02-20 04:01:00', $limit = 5, $offset = 0, 'asc'); $this->assertEquals(array('2010-01-01 00:00:00 2010-01-01 23:59:59', '2010-01-02 00:00:00 2010-01-08 23:59:59', '2010-01-09 00:00:00 2010-02-07 23:59:59', '2010-02-08 00:00:00 2010-02-20 04:01:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanYear() + public function testSplitDatesIntoMultipleQueriesMoreThanYear() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2012-02-20 04:01:00', $limit = 5, $offset = 0); $this->assertEquals(array('2012-02-19 04:01:00 2012-02-20 04:01:00', '2012-02-12 04:01:00 2012-02-19 04:00:59', '2012-01-13 04:01:00 2012-02-12 04:00:59', '2011-01-01 04:01:00 2012-01-13 04:00:59', '2010-01-01 00:00:00 2011-01-01 04:00:59'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanYearAsc() + public function testSplitDatesIntoMultipleQueriesMoreThanYearAsc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2012-02-20 04:01:00', $limit = 5, $offset = 0, 'asc'); $this->assertEquals(array('2010-01-01 00:00:00 2010-01-01 23:59:59', '2010-01-02 00:00:00 2010-01-08 23:59:59', '2010-01-09 00:00:00 2010-02-07 23:59:59', '2010-02-08 00:00:00 2011-02-07 23:59:59', '2011-02-08 00:00:00 2012-02-20 04:01:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanYear_withOffsetUsesLessQueries() + public function testSplitDatesIntoMultipleQueriesMoreThanYearWithOffsetUsesLessQueries() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2012-02-20 04:01:00', $limit = 5, $offset = 5); $this->assertEquals(array('2012-02-19 04:01:00 2012-02-20 04:01:00', '2012-02-12 04:01:00 2012-02-19 04:00:59', '2010-01-01 00:00:00 2012-02-12 04:00:59'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanYear_withOffsetUsesLessQueriesAsc() + public function testSplitDatesIntoMultipleQueriesMoreThanYearWithOffsetUsesLessQueriesAsc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 04:01:00', '2012-02-20 00:00:00', $limit = 5, $offset = 5, 'asc'); $this->assertEquals(array('2010-01-01 04:01:00 2010-01-02 04:00:59', '2010-01-02 04:01:00 2010-01-09 04:00:59', '2010-01-09 04:01:00 2012-02-20 00:00:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanYear_noLimitDoesntUseMultipleQueries() + public function testSplitDatesIntoMultipleQueriesMoreThanYearNoLimitDoesntUseMultipleQueries() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 00:00:00', '2012-02-20 04:01:00', $limit = 0, $offset = 0); $this->assertEquals(array('2010-01-01 00:00:00 2012-02-20 04:01:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_moreThanYear_noLimitDoesntUseMultipleQueriesAsc() + public function testSplitDatesIntoMultipleQueriesMoreThanYearNoLimitDoesntUseMultipleQueriesAsc() { $dates = $this->splitDatesIntoMultipleQueries('2010-01-01 04:01:00', '2012-02-20 00:00:00', $limit = 0, $offset = 0, 'asc'); $this->assertEquals(array('2010-01-01 04:01:00 2012-02-20 00:00:00'), $dates); } - public function test_splitDatesIntoMultipleQueries_noStartDate() + public function testSplitDatesIntoMultipleQueriesNoStartDate() { $dates = $this->splitDatesIntoMultipleQueries(false, '2012-02-20 04:01:00', $limit = 5, $offset = 0); diff --git a/plugins/Live/tests/System/ApiCounterTest.php b/plugins/Live/tests/System/ApiCounterTest.php index dab68962f73..9ba110f6ef1 100644 --- a/plugins/Live/tests/System/ApiCounterTest.php +++ b/plugins/Live/tests/System/ApiCounterTest.php @@ -51,7 +51,7 @@ public function setUp(): void $this->createSite(); } - public function test_GetCounters_ShouldFail_IfUserHasNoPermission() + public function testGetCountersShouldFailIfUserHasNoPermission() { $this->expectException(\Exception::class); $this->expectExceptionMessage('checkUserHasViewAccess Fake exception'); @@ -60,14 +60,14 @@ public function test_GetCounters_ShouldFail_IfUserHasNoPermission() $this->api->getCounters($this->idSite, 5); } - public function test_GetCounters_ShouldReturnZeroForAllCounters_IfThereAreNoVisitsEtc() + public function testGetCountersShouldReturnZeroForAllCountersIfThereAreNoVisitsEtc() { $counters = $this->api->getCounters($this->idSite, 5); $this->assertEquals($this->buildCounter(0, 0, 0, 0), $counters); } - public function test_GetCounters_ShouldOnlyReturnResultsOfLastMinutes() + public function testGetCountersShouldOnlyReturnResultsOfLastMinutes() { $this->trackSomeVisits(); @@ -94,33 +94,33 @@ public function getInvalidLastMinutesValues() ]; } - public function test_GetCounters_ShouldHideAllColumnsIfRequested() + public function testGetCountersShouldHideAllColumnsIfRequested() { $exampleCounter = $this->buildCounter(0, 0, 0, 0); $counters = $this->api->getCounters($this->idSite, 5, false, array(), array_keys($exampleCounter[0])); $this->assertEquals(array(array()), $counters); } - public function test_GetCounters_ShouldHideSomeColumnsIfRequested() + public function testGetCountersShouldHideSomeColumnsIfRequested() { $counters = $this->api->getCounters($this->idSite, 20, false, array(), array('visitsConverted', 'visitors')); $this->assertEquals(array(array('visits' => 24, 'actions' => 60)), $counters); } - public function test_GetCounters_ShouldShowAllColumnsIfRequested() + public function testGetCountersShouldShowAllColumnsIfRequested() { $counter = $this->buildCounter(24, 60, 20, 40); $counters = $this->api->getCounters($this->idSite, 20, false, array_keys($counter[0])); $this->assertEquals($counter, $counters); } - public function test_GetCounters_ShouldShowSomeColumnsIfRequested() + public function testGetCountersShouldShowSomeColumnsIfRequested() { $counters = $this->api->getCounters($this->idSite, 20, false, array('visits', 'actions')); $this->assertEquals(array(array('visits' => 24, 'actions' => 60)), $counters); } - public function test_GetCounters_ShouldHideColumnIfGivenInShowAndHide() + public function testGetCountersShouldHideColumnIfGivenInShowAndHide() { $counters = $this->api->getCounters($this->idSite, 20, false, array('visits', 'actions'), array('actions')); $this->assertEquals(array(array('visits' => 24)), $counters); diff --git a/plugins/Login/tests/Integration/APITest.php b/plugins/Login/tests/Integration/APITest.php index f964a29b856..c93cb447673 100644 --- a/plugins/Login/tests/Integration/APITest.php +++ b/plugins/Login/tests/Integration/APITest.php @@ -32,7 +32,7 @@ public function setUp(): void $this->api = API::getInstance(); } - public function test_unblockBruteForceIPs_requiresSuperUser() + public function testUnblockBruteForceIPsRequiresSuperUser() { $this->expectException(\Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -41,14 +41,14 @@ public function test_unblockBruteForceIPs_requiresSuperUser() $this->api->unblockBruteForceIPs(); } - public function test_unblockBruteForceIPs_doesNotFailWhenNothingToRemove() + public function testUnblockBruteForceIPsDoesNotFailWhenNothingToRemove() { self::expectNotToPerformAssertions(); $this->api->unblockBruteForceIPs(); } - public function test_unblockBruteForceIPs_removesBlockedIps() + public function testUnblockBruteForceIPsRemovesBlockedIps() { $bruteForce = StaticContainer::get('Piwik\Plugins\Login\Security\BruteForceDetection'); $bruteForce->addFailedAttempt('127.2.3.4'); diff --git a/plugins/Login/tests/Integration/LoginTest.php b/plugins/Login/tests/Integration/LoginTest.php index 5b2024c1903..39e89583b20 100644 --- a/plugins/Login/tests/Integration/LoginTest.php +++ b/plugins/Login/tests/Integration/LoginTest.php @@ -43,14 +43,14 @@ public function setUp(): void $this->auth = new Auth(); } - public function test_authenticate_failureNoLoginNoTokenAuth() + public function testAuthenticateFailureNoLoginNoTokenAuth() { // no login; no token auth $rc = $this->auth->authenticate(); $this->assertFailedLogin($rc); } - public function test_authenticate_failureEmptyLoginNoTokenAuth() + public function testAuthenticateFailureEmptyLoginNoTokenAuth() { // empty login; no token auth $this->auth->setLogin(''); @@ -58,7 +58,7 @@ public function test_authenticate_failureEmptyLoginNoTokenAuth() $this->assertFailedLogin($rc); } - public function test_authenticate_failureNonExistentUser() + public function testAuthenticateFailureNonExistentUser() { // non-existent user $this->auth->setLogin('nobody'); @@ -66,14 +66,14 @@ public function test_authenticate_failureNonExistentUser() $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousNotExisting() + public function testAuthenticateFailureAnonymousNotExisting() { // anonymous user doesn't exist yet $rc = $this->authenticate($login = 'anonymous', $authToken = ''); $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousNotExistentEmptyLogin() + public function testAuthenticateFailureAnonymousNotExistentEmptyLogin() { // empty login; anonymous user doesn't exist yet $rc = $this->authenticate($login = '', $authToken = 'anonymous'); @@ -81,21 +81,21 @@ public function test_authenticate_failureAnonymousNotExistentEmptyLogin() $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousNotExistentEmptyLoginWithTokenAuth() + public function testAuthenticateFailureAnonymousNotExistentEmptyLoginWithTokenAuth() { // API authentication; anonymous user doesn't exist yet $rc = $this->authenticate($login = null, $authToken = 'anonymous'); $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousNotExistentWithLoginAndTokenAuth() + public function testAuthenticateFailureAnonymousNotExistentWithLoginAndTokenAuth() { // anonymous user doesn't exist yet $rc = $this->authenticate($login = 'anonymous', $authToken = 'anonymous'); $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousWithLogin() + public function testAuthenticateFailureAnonymousWithLogin() { DbHelper::createAnonymousUser(); @@ -104,7 +104,7 @@ public function test_authenticate_failureAnonymousWithLogin() $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousEmptyLoginWithTokenAuth() + public function testAuthenticateFailureAnonymousEmptyLoginWithTokenAuth() { DbHelper::createAnonymousUser(); @@ -113,7 +113,7 @@ public function test_authenticate_failureAnonymousEmptyLoginWithTokenAuth() $this->assertFailedLogin($rc); } - public function test_authenticate_failureAnonymousLoginTokenAuthMissmatch() + public function testAuthenticateFailureAnonymousLoginTokenAuthMissmatch() { DbHelper::createAnonymousUser(); @@ -122,7 +122,7 @@ public function test_authenticate_failureAnonymousLoginTokenAuthMissmatch() $this->assertFailedLogin($rc); } - public function test_authenticate_successAnonymousWithTokenAuth() + public function testAuthenticateSuccessAnonymousWithTokenAuth() { DbHelper::createAnonymousUser(); @@ -131,7 +131,7 @@ public function test_authenticate_successAnonymousWithTokenAuth() $this->assertUserLogin($rc, $login = 'anonymous', $tokenLength = 9); } - public function test_authenticate_successAnonymous() + public function testAuthenticateSuccessAnonymous() { DbHelper::createAnonymousUser(); @@ -140,7 +140,7 @@ public function test_authenticate_successAnonymous() $this->assertUserLogin($rc, $login = 'anonymous', $tokenLength = 9); } - public function test_authenticate_failureUserEmptyTokenAuth() + public function testAuthenticateFailureUserEmptyTokenAuth() { $user = $this->setUpUser(); @@ -149,7 +149,7 @@ public function test_authenticate_failureUserEmptyTokenAuth() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserInvalidTokenAuth() + public function testAuthenticateFailureUserInvalidTokenAuth() { $user = $this->setUpUser(); @@ -158,7 +158,7 @@ public function test_authenticate_failureUserInvalidTokenAuth() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserInvalidTokenAuth2() + public function testAuthenticateFailureUserInvalidTokenAuth2() { $user = $this->setUpUser(); @@ -167,7 +167,7 @@ public function test_authenticate_failureUserInvalidTokenAuth2() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserEmptyLogin() + public function testAuthenticateFailureUserEmptyLogin() { $user = $this->setUpUser(); @@ -176,7 +176,7 @@ public function test_authenticate_failureUserEmptyLogin() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserWithSuperUserAccessEmptyLogin() + public function testAuthenticateFailureUserWithSuperUserAccessEmptyLogin() { $user = $this->setUpUser(); $this->setUpSuperUserAccessViaDb(); @@ -186,7 +186,7 @@ public function test_authenticate_failureUserWithSuperUserAccessEmptyLogin() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserLoginTokenAuthMissmatch() + public function testAuthenticateFailureUserLoginTokenAuthMissmatch() { $this->setUpUser(); @@ -195,7 +195,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserLoginTokenAuthMissmatch2() + public function testAuthenticateFailureUserLoginTokenAuthMissmatch2() { $user = $this->setUpUser(); @@ -204,7 +204,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch2() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserLoginTokenAuthMissmatch3() + public function testAuthenticateFailureUserLoginTokenAuthMissmatch3() { $user = $this->setUpUser(); @@ -213,7 +213,7 @@ public function test_authenticate_failureUserLoginTokenAuthMissmatch3() $this->assertFailedLogin($rc); } - public function test_authenticate_failureUserWithSuperUserAccessLoginTokenAuthMissmatch() + public function testAuthenticateFailureUserWithSuperUserAccessLoginTokenAuthMissmatch() { $user = $this->setUpUser(); $this->setUpSuperUserAccessViaDb(); @@ -223,7 +223,7 @@ public function test_authenticate_failureUserWithSuperUserAccessLoginTokenAuthMi $this->assertFailedLogin($rc); } - public function test_authenticate_successUserTokenAuth() + public function testAuthenticateSuccessUserTokenAuth() { $user = $this->setUpUser(); @@ -232,7 +232,7 @@ public function test_authenticate_successUserTokenAuth() $this->assertUserLogin($rc); } - public function test_authenticate_successUserWithSuperUserAccessByTokenAuth() + public function testAuthenticateSuccessUserWithSuperUserAccessByTokenAuth() { $user = $this->setUpUser(); $this->setUpSuperUserAccessViaDb(); @@ -242,7 +242,7 @@ public function test_authenticate_successUserWithSuperUserAccessByTokenAuth() $this->assertSuperUserLogin($rc, 'user'); } - public function test_authenticate_successUserLoginAndTokenAuthWithAnonymous() + public function testAuthenticateSuccessUserLoginAndTokenAuthWithAnonymous() { DbHelper::createAnonymousUser(); @@ -253,7 +253,7 @@ public function test_authenticate_successUserLoginAndTokenAuthWithAnonymous() $this->assertUserLogin($rc, 'anonymous', strlen('anonymous')); } - public function test_authenticate_successUserLoginAndTokenAuth() + public function testAuthenticateSuccessUserLoginAndTokenAuth() { $user = $this->setUpUser(); @@ -262,7 +262,7 @@ public function test_authenticate_successUserLoginAndTokenAuth() $this->assertUserLogin($rc); } - public function test_authenticate_successUserWithSuperUserAccessLoginAndTokenAuth() + public function testAuthenticateSuccessUserWithSuperUserAccessLoginAndTokenAuth() { $user = $this->setUpUser(); $this->setUpSuperUserAccessViaDb(); @@ -272,7 +272,7 @@ public function test_authenticate_successUserWithSuperUserAccessLoginAndTokenAut $this->assertSuperUserLogin($rc, 'user'); } - public function test_authenticate_successWithValidPassword() + public function testAuthenticateSuccessWithValidPassword() { $user = $this->setUpUser(); $this->auth->setLogin($user['login']); @@ -285,7 +285,7 @@ public function test_authenticate_successWithValidPassword() $this->assertTrue(ctype_xdigit($rc->getTokenAuth())); } - public function test_authenticate_successWithSuperUserPassword() + public function testAuthenticateSuccessWithSuperUserPassword() { $user = $this->setUpUser(); $this->setUpSuperUserAccessViaDb(); @@ -297,7 +297,7 @@ public function test_authenticate_successWithSuperUserPassword() $this->assertSuperUserLogin($rc, 'user'); } - public function test_authenticate_failsWithInvalidPassword() + public function testAuthenticateFailsWithInvalidPassword() { $user = $this->setUpUser(); $this->auth->setLogin($user['login']); @@ -307,7 +307,7 @@ public function test_authenticate_failsWithInvalidPassword() $this->assertFailedLogin($rc); } - public function test_authenticate_prioritizesPasswordAuthentication() + public function testAuthenticatePrioritizesPasswordAuthentication() { $user = $this->setUpUser(); $this->auth->setLogin($user['login']); @@ -326,7 +326,7 @@ public function test_authenticate_prioritizesPasswordAuthentication() * @group Plugins * @see https://github.com/piwik/piwik/issues/8548 */ - public function test_authenticate_withPasswordIsCaseInsensitiveForLogin() + public function testAuthenticateWithPasswordIsCaseInsensitiveForLogin() { $user = $this->setUpUser(); $this->auth->setLogin('uSeR'); diff --git a/plugins/Login/tests/Integration/ModelTest.php b/plugins/Login/tests/Integration/ModelTest.php index c457ff63291..7e350eaf918 100644 --- a/plugins/Login/tests/Integration/ModelTest.php +++ b/plugins/Login/tests/Integration/ModelTest.php @@ -30,7 +30,7 @@ public function setUp(): void $this->testInstance = new Model(); } - public function test_getTotalLoginAttemptsInLastHourForLogin_returnsDistinctCountOfIpForTheRightLogin() + public function testGetTotalLoginAttemptsInLastHourForLoginReturnsDistinctCountOfIpForTheRightLogin() { Date::$now = strtotime('2020-02-03 05:00:00'); @@ -46,7 +46,7 @@ public function test_getTotalLoginAttemptsInLastHourForLogin_returnsDistinctCoun $this->assertEquals(2, $count); } - public function test_getTotalLoginAttemptsInlastHourForLogin_returnsZeroIfAllAttemptsAreBeforeLastHour() + public function testGetTotalLoginAttemptsInlastHourForLoginReturnsZeroIfAllAttemptsAreBeforeLastHour() { Date::$now = strtotime('2020-02-03 05:00:00'); @@ -62,7 +62,7 @@ public function test_getTotalLoginAttemptsInlastHourForLogin_returnsZeroIfAllAtt $this->assertEquals(0, $count); } - public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfJsonValueIsBroken() + public function testHasNotifiedUserAboutSuspiciousLoginsReturnsFalseIfJsonValueIsBroken() { $optionName = 'BruteForceDetection.suspiciousLoginCountNotified.theuser'; Option::set($optionName, 'aslkdfjsadlkfj'); @@ -71,7 +71,7 @@ public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfJsonValu $this->assertFalse($result); } - public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfJsonValueIsNegative() + public function testHasNotifiedUserAboutSuspiciousLoginsReturnsFalseIfJsonValueIsNegative() { $optionName = 'BruteForceDetection.suspiciousLoginCountNotified.theuser'; Option::set($optionName, '-5'); @@ -80,13 +80,13 @@ public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfJsonValu $this->assertFalse($result); } - public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfThereWasNoLastTimeSent() + public function testHasNotifiedUserAboutSuspiciousLoginsReturnsFalseIfThereWasNoLastTimeSent() { $result = $this->testInstance->hasNotifiedUserAboutSuspiciousLogins('theuser'); $this->assertFalse($result); } - public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfLastTimeSentIsBeforeTwoWeeks() + public function testHasNotifiedUserAboutSuspiciousLoginsReturnsFalseIfLastTimeSentIsBeforeTwoWeeks() { $optionName = 'BruteForceDetection.suspiciousLoginCountNotified.theuser'; Option::set($optionName, \Piwik\Date::now()->subWeek(3)->getTimestamp()); @@ -95,7 +95,7 @@ public function test_hasNotifiedUserAboutSuspiciousLogins_returnsFalseIfLastTime $this->assertFalse($result); } - public function test_hasNotifiedUserAboutSuspiciousLogins_returnsTrueIfLastTimeSentIsWithinTwoWeeks() + public function testHasNotifiedUserAboutSuspiciousLoginsReturnsTrueIfLastTimeSentIsWithinTwoWeeks() { $optionName = 'BruteForceDetection.suspiciousLoginCountNotified.theuser'; Option::set($optionName, \Piwik\Date::now()->subWeek(1)->getTimestamp()); @@ -104,7 +104,7 @@ public function test_hasNotifiedUserAboutSuspiciousLogins_returnsTrueIfLastTimeS $this->assertTrue($result); } - public function test_getDistinctIpsAttemptingLoginsInLastHour_returnsCountOfDistinctIpsOfFailedLoginsForUserInLastHour() + public function testGetDistinctIpsAttemptingLoginsInLastHourReturnsCountOfDistinctIpsOfFailedLoginsForUserInLastHour() { Date::$now = strtotime('2020-02-03 05:00:00'); @@ -120,7 +120,7 @@ public function test_getDistinctIpsAttemptingLoginsInLastHour_returnsCountOfDist $this->assertEquals(3, $count); } - public function test_markSuspiciousLoginsNotifiedEmailSent_setsTheOptionValueToNow() + public function testMarkSuspiciousLoginsNotifiedEmailSentSetsTheOptionValueToNow() { Date::$now = strtotime('2020-02-03 05:00:00'); diff --git a/plugins/Login/tests/Integration/PasswordVerifierTest.php b/plugins/Login/tests/Integration/PasswordVerifierTest.php index 8db809c7226..d82e41d0657 100644 --- a/plugins/Login/tests/Integration/PasswordVerifierTest.php +++ b/plugins/Login/tests/Integration/PasswordVerifierTest.php @@ -38,22 +38,22 @@ public function setUp(): void $this->verifier->setDisableRedirect(); } - public function test_hasBeenVerified_byDefaultNotVerified() + public function testHasBeenVerifiedByDefaultNotVerified() { $this->assertFalse($this->verifier->hasBeenVerified()); } - public function test_hasBeenVerifiedAndHalfTimeValid_byDefaultNotVerified() + public function testHasBeenVerifiedAndHalfTimeValidByDefaultNotVerified() { $this->assertFalse($this->verifier->hasBeenVerifiedAndHalfTimeValid()); } - public function test_hasPasswordVerifyBeenRequested_byDefaultNotRequested() + public function testHasPasswordVerifyBeenRequestedByDefaultNotRequested() { $this->assertFalse($this->verifier->hasPasswordVerifyBeenRequested()); } - public function test_requirePasswordVerifiedRecently() + public function testRequirePasswordVerifiedRecently() { $this->assertNull($this->requirePasswordVerify()); $this->assertTrue($this->verifier->hasPasswordVerifyBeenRequested()); @@ -61,7 +61,7 @@ public function test_requirePasswordVerifiedRecently() $this->assertFalse($this->verifier->hasBeenVerifiedAndHalfTimeValid()); } - public function test_setPasswordVerifiedCorrectly() + public function testSetPasswordVerifiedCorrectly() { $this->assertNull($this->requirePasswordVerify()); $this->assertFalse($this->verifier->hasBeenVerified()); @@ -74,7 +74,7 @@ public function test_setPasswordVerifiedCorrectly() $this->assertTrue($this->requirePasswordVerify()); // no need to redirect } - public function test_setPasswordVerifiedCorrectly_requiresAPasswordToBeRequestedToBeValid() + public function testSetPasswordVerifiedCorrectlyRequiresAPasswordToBeRequestedToBeValid() { $this->verifier->setPasswordVerifiedCorrectly(); @@ -83,7 +83,7 @@ public function test_setPasswordVerifiedCorrectly_requiresAPasswordToBeRequested $this->assertNull($this->requirePasswordVerify()); } - public function test_setPasswordVerifiedCorrectly_expiresAfter15Min() + public function testSetPasswordVerifiedCorrectlyExpiresAfter15Min() { $this->assertNull($this->requirePasswordVerify()); $this->assertFalse($this->verifier->hasBeenVerified()); @@ -114,7 +114,7 @@ public function test_setPasswordVerifiedCorrectly_expiresAfter15Min() $this->assertNull($this->requirePasswordVerify()); // no need to redirect } - public function test_forgetVerifiedPassword() + public function testForgetVerifiedPassword() { $this->requirePasswordVerify(); $this->verifier->setPasswordVerifiedCorrectly(); diff --git a/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php b/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php index 5b00af051d5..22722cdb54f 100644 --- a/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php +++ b/plugins/Login/tests/Integration/Security/BruteForceDetectionTest.php @@ -73,12 +73,12 @@ public function setUp(): void $this->detection = new CustomBruteForceDetection($this->settings, new \Piwik\Plugins\Login\Model()); } - public function test_isEnabled_isEnabledByDefault() + public function testIsEnabledIsEnabledByDefault() { $this->assertTrue($this->detection->isEnabled()); } - public function test_addFailedAttempt_addsEntries() + public function testAddFailedAttemptAddsEntries() { $this->addFailedLoginInPast('127.0.0.1', 1); $this->addFailedLoginInPast('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 2); @@ -122,7 +122,7 @@ public function test_addFailedAttempt_addsEntries() $this->assertEquals($expected, $entries); } - public function test_unblockIp_onlyRemovesRecentEntriesOfIp() + public function testUnblockIpOnlyRemovesRecentEntriesOfIp() { $now = $this->detection->getNow(); $this->addFailedLoginInPast('127.0.0.1', 1); @@ -163,7 +163,7 @@ public function test_unblockIp_onlyRemovesRecentEntriesOfIp() $this->assertEquals($expected, $entries); } - public function test_cleanupOldEntries_onlyRemovesOldEntries() + public function testCleanupOldEntriesOnlyRemovesOldEntries() { $now = $this->detection->getNow(); // these should be kept cause they are recent @@ -207,12 +207,12 @@ public function test_cleanupOldEntries_onlyRemovesOldEntries() $this->assertEquals($expected, $entries); } - public function test_getCurrentlyBlockedIps_noIpBlockedWhenNonAdded() + public function testGetCurrentlyBlockedIpsNoIpBlockedWhenNonAdded() { $this->assertEquals(array(), $this->detection->getCurrentlyBlockedIps()); } - public function test_getCurrentlyBlockedIps_noIpBlockedWhenOnlyRecentOnesAdded() + public function testGetCurrentlyBlockedIpsNoIpBlockedWhenOnlyRecentOnesAdded() { $this->detection->addFailedAttempt('127.0.0.1'); $this->detection->addFailedAttempt('2001:0db8:85a3:0000:0000:8a2e:0370:7334'); @@ -223,7 +223,7 @@ public function test_getCurrentlyBlockedIps_noIpBlockedWhenOnlyRecentOnesAdded() $this->assertEquals(array(), $this->detection->getCurrentlyBlockedIps()); } - public function test_getCurrentlyBlockedIps_isAllowedToLogin_onlyBlockedWhenMaxAttemptsReached() + public function testGetCurrentlyBlockedIpsIsAllowedToLoginOnlyBlockedWhenMaxAttemptsReached() { $this->addFailedLoginInPast('127.0.0.1', 1); $this->addFailedLoginInPast('2001:0db8:85a3:0000:0000:8a2e:0370:7334', 2); @@ -252,7 +252,7 @@ public function test_getCurrentlyBlockedIps_isAllowedToLogin_onlyBlockedWhenMaxA $this->assertTrue($this->detection->isAllowedToLogin('127.0.0.1')); } - public function test_getCurrentlyBlockedIps_isAllowedToLogin_whitelistedIpCanAlwaysLoginAndIsNeverBlocked() + public function testGetCurrentlyBlockedIpsIsAllowedToLoginWhitelistedIpCanAlwaysLoginAndIsNeverBlocked() { for ($i = 0; $i < 20; $i++) { $this->addFailedLoginInPast('10.99.99.99', 1); @@ -264,14 +264,14 @@ public function test_getCurrentlyBlockedIps_isAllowedToLogin_whitelistedIpCanAlw $this->assertFalse($this->detection->isAllowedToLogin('127.0.0.1')); } - public function test_getCurrentlyBlockedIps_isAllowedToLogin_blacklistedIpCanNeverLogIn_EvenWhenNoFailedAttempts() + public function testGetCurrentlyBlockedIpsIsAllowedToLoginBlacklistedIpCanNeverLogInEvenWhenNoFailedAttempts() { $this->assertEquals(array(), $this->detection->getCurrentlyBlockedIps()); $this->assertEquals(array(), $this->detection->getAll()); $this->assertFalse($this->detection->isAllowedToLogin('10.55.55.55')); } - public function test_isUserLoginBlocked_returnsTrueIfThereAreMoreThanTheThresholdNumOfAttempts() + public function testIsUserLoginBlockedReturnsTrueIfThereAreMoreThanTheThresholdNumOfAttempts() { $this->detection->setNow(Date::now()); @@ -286,7 +286,7 @@ public function test_isUserLoginBlocked_returnsTrueIfThereAreMoreThanTheThreshol $this->assertNull($sentMail); // user does not exist so no mail sent } - public function test_isUserLoginBlocked_sendsEmailIfLoginIsForRealUser() + public function testIsUserLoginBlockedSendsEmailIfLoginIsForRealUser() { $this->detection->setNow(Date::now()); @@ -306,7 +306,7 @@ public function test_isUserLoginBlocked_sendsEmailIfLoginIsForRealUser() $this->assertEquals(['someemail@email.com' => ''], $sentMail->getRecipients()); } - public function test_isUserLoginBlocked_returnsFalseIfThereAreLessThanTheThresholdNumOfAttempts() + public function testIsUserLoginBlockedReturnsFalseIfThereAreLessThanTheThresholdNumOfAttempts() { $this->detection->setNow(Date::now()); diff --git a/plugins/Login/tests/Integration/SessionInitializerTest.php b/plugins/Login/tests/Integration/SessionInitializerTest.php index 0a08a872849..0c1e8c086ec 100644 --- a/plugins/Login/tests/Integration/SessionInitializerTest.php +++ b/plugins/Login/tests/Integration/SessionInitializerTest.php @@ -31,7 +31,7 @@ public function setUp(): void StaticContainer::get(Auth::class); } - public function test_initSession_CreatesCookie_WhenAuthenticationIsSuccessful() + public function testInitSessionCreatesCookieWhenAuthenticationIsSuccessful() { $this->assertAuthCookieIsAbsent(); @@ -42,7 +42,7 @@ public function test_initSession_CreatesCookie_WhenAuthenticationIsSuccessful() $this->assertAuthCookieIsCreated($sessionInitializer->cookie); } - public function test_initSession_DeletesCookie_WhenAuthenticationFailed() + public function testInitSessionDeletesCookieWhenAuthenticationFailed() { $this->createAuthCookie(); diff --git a/plugins/Login/tests/Integration/SystemSettingsTest.php b/plugins/Login/tests/Integration/SystemSettingsTest.php index c6f1c719c9b..2f8e98ecd1f 100644 --- a/plugins/Login/tests/Integration/SystemSettingsTest.php +++ b/plugins/Login/tests/Integration/SystemSettingsTest.php @@ -38,33 +38,33 @@ public function setUp(): void $this->settings = new SystemSettings(); } - public function test_enableBruteForceDetection_isEnabledByDefault() + public function testEnableBruteForceDetectionIsEnabledByDefault() { $this->assertTrue($this->settings->enableBruteForceDetection->getValue()); } - public function test_loginAttemptsTimeRange_hasCorrectDefaultValue() + public function testLoginAttemptsTimeRangeHasCorrectDefaultValue() { $this->assertSame(60, $this->settings->loginAttemptsTimeRange->getValue()); } - public function test_maxFailedLoginsPerMinutes_hasCorrectDefaultValue() + public function testMaxFailedLoginsPerMinutesHasCorrectDefaultValue() { $this->assertSame(20, $this->settings->maxFailedLoginsPerMinutes->getValue()); } - public function test_whitelisteBruteForceIps_hasNoIpWhitelisted() + public function testWhitelisteBruteForceIpsHasNoIpWhitelisted() { $this->assertSame([], $this->settings->whitelisteBruteForceIps->getValue()); } - public function test_whitelisteBruteForceIps_CanSuccessfullySetVariousIpsAndRanges() + public function testWhitelisteBruteForceIpsCanSuccessfullySetVariousIpsAndRanges() { $this->settings->whitelisteBruteForceIps->setValue($this->exampleIps); $this->assertSame($this->exampleIps, $this->settings->whitelisteBruteForceIps->getValue()); } - public function test_whitelisteBruteForceIps_failsWhenContainsInvalidValue() + public function testWhitelisteBruteForceIpsFailsWhenContainsInvalidValue() { $this->expectException(\Exception::class); $this->expectExceptionMessage('SitesManager_ExceptionInvalidIPFormat'); @@ -74,7 +74,7 @@ public function test_whitelisteBruteForceIps_failsWhenContainsInvalidValue() )); } - public function test_isWhitelistedIp_doesNotWhitelistAnyIpsByDefault() + public function testIsWhitelistedIpDoesNotWhitelistAnyIpsByDefault() { $this->assertFalse($this->settings->isWhitelistedIp('127.0.0.1')); } @@ -82,25 +82,25 @@ public function test_isWhitelistedIp_doesNotWhitelistAnyIpsByDefault() /** * @dataProvider getIpListedDataProvider */ - public function test_isWhitelistedIp_isIpInList($expected, $ip) + public function testIsWhitelistedIpIsIpInList($expected, $ip) { $this->settings->whitelisteBruteForceIps->setValue($this->exampleIps); $this->assertSame($expected, $this->settings->isWhitelistedIp($ip)); $this->assertFalse($this->settings->isBlacklistedIp($ip)); } - public function test_blacklistedBruteForceIps_hasNoIpWhitelisted() + public function testBlacklistedBruteForceIpsHasNoIpWhitelisted() { $this->assertSame([], $this->settings->blacklistedBruteForceIps->getValue()); } - public function test_blacklistedBruteForceIps_CanSuccessfullySetVariousIpsAndRanges() + public function testBlacklistedBruteForceIpsCanSuccessfullySetVariousIpsAndRanges() { $this->settings->blacklistedBruteForceIps->setValue($this->exampleIps); $this->assertSame($this->exampleIps, $this->settings->blacklistedBruteForceIps->getValue()); } - public function test_blacklistedBruteForceIps_failsWhenContainsInvalidValue() + public function testBlacklistedBruteForceIpsFailsWhenContainsInvalidValue() { $this->expectException(\Exception::class); $this->expectExceptionMessage('SitesManager_ExceptionInvalidIPFormat'); @@ -113,7 +113,7 @@ public function test_blacklistedBruteForceIps_failsWhenContainsInvalidValue() /** * @dataProvider getIpListedDataProvider */ - public function test_isBlacklistedIp_isIpInList($expected, $ip) + public function testIsBlacklistedIpIsIpInList($expected, $ip) { $this->settings->blacklistedBruteForceIps->setValue($this->exampleIps); $this->assertSame($expected, $this->settings->isBlacklistedIp($ip)); @@ -137,7 +137,7 @@ public function getIpListedDataProvider() ); } - public function test_isBlacklistedIp_doesNotWhitelistAnyIpsByDefault() + public function testIsBlacklistedIpDoesNotWhitelistAnyIpsByDefault() { $this->assertFalse($this->settings->isBlacklistedIp('127.0.0.1')); } diff --git a/plugins/Marketplace/tests/Integration/ApiTest.php b/plugins/Marketplace/tests/Integration/ApiTest.php index 751934b683b..a288501b34c 100644 --- a/plugins/Marketplace/tests/Integration/ApiTest.php +++ b/plugins/Marketplace/tests/Integration/ApiTest.php @@ -53,7 +53,7 @@ public function setUp(): void $this->setSuperUser(); } - public function test_createAccount_shouldSucceedIfMarketplaceCallsDidNotFail(): void + public function testCreateAccountShouldSucceedIfMarketplaceCallsDidNotFail(): void { $this->assertNotHasLicenseKey(); @@ -74,7 +74,7 @@ public function test_createAccount_shouldSucceedIfMarketplaceCallsDidNotFail(): $this->assertHasLicenseKey(); } - public function test_createAccount_requiresSuperUserAccess_IfUser() + public function testCreateAccountRequiresSuperUserAccessIfUser() { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -83,7 +83,7 @@ public function test_createAccount_requiresSuperUserAccess_IfUser() $this->api->createAccount('test@matomo.org'); } - public function test_createAccount_requiresSuperUserAccess_IfAnonymous(): void + public function testCreateAccountRequiresSuperUserAccessIfAnonymous(): void { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -92,7 +92,7 @@ public function test_createAccount_requiresSuperUserAccess_IfAnonymous(): void $this->api->createAccount('test@matomo.org'); } - public function test_createAccount_shouldThrowException_ifLicenseKeyIsAlreadySet(): void + public function testCreateAccountShouldThrowExceptionIfLicenseKeyIsAlreadySet(): void { $this->buildLicenseKey()->set('key'); @@ -102,7 +102,7 @@ public function test_createAccount_shouldThrowException_ifLicenseKeyIsAlreadySet $this->api->createAccount('test@matomo.org'); } - public function test_createAccount_shouldThrowException_ifEmailIsEmpty(): void + public function testCreateAccountShouldThrowExceptionIfEmailIsEmpty(): void { $this->expectException(Exception::class); $this->expectExceptionMessage('General_ValidatorErrorEmptyValue'); @@ -110,7 +110,7 @@ public function test_createAccount_shouldThrowException_ifEmailIsEmpty(): void $this->api->createAccount(''); } - public function test_createAccount_shouldThrowException_ifEmailIsInvalid(): void + public function testCreateAccountShouldThrowExceptionIfEmailIsInvalid(): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Marketplace_CreateAccountErrorEmailInvalid'); @@ -118,7 +118,7 @@ public function test_createAccount_shouldThrowException_ifEmailIsInvalid(): void $this->api->createAccount('invalid.email@'); } - public function test_createAccount_shouldThrowException_ifEmailIsNotAllowed(): void + public function testCreateAccountShouldThrowExceptionIfEmailIsNotAllowed(): void { $settings = StaticContainer::get(SystemSettings::class); $settings->allowedEmailDomains->setValue(['example.org']); @@ -132,7 +132,7 @@ public function test_createAccount_shouldThrowException_ifEmailIsNotAllowed(): v /** * @dataProvider dataCreateAccountErrorDownloadResponses */ - public function test_createAccount_shouldThrowException_ifSomethingGoesWrong( + public function testCreateAccountShouldThrowExceptionIfSomethingGoesWrong( array $responseInfo, string $expectedException, string $expectedExceptionMessage @@ -200,7 +200,7 @@ public function dataCreateAccountErrorDownloadResponses(): iterable ]; } - public function test_deleteLicenseKey_requiresSuperUserAccess_IfUser() + public function testDeleteLicenseKeyRequiresSuperUserAccessIfUser() { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -209,7 +209,7 @@ public function test_deleteLicenseKey_requiresSuperUserAccess_IfUser() $this->api->deleteLicenseKey(); } - public function test_deleteLicenseKey_requiresSuperUserAccess_IfAnonymous() + public function testDeleteLicenseKeyRequiresSuperUserAccessIfAnonymous() { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -218,7 +218,7 @@ public function test_deleteLicenseKey_requiresSuperUserAccess_IfAnonymous() $this->api->deleteLicenseKey(); } - public function test_deleteLicenseKey_shouldRemoveAnExistingKey() + public function testDeleteLicenseKeyShouldRemoveAnExistingKey() { $this->buildLicenseKey()->set('key'); $this->assertHasLicenseKey(); @@ -228,7 +228,7 @@ public function test_deleteLicenseKey_shouldRemoveAnExistingKey() $this->assertNotHasLicenseKey(); } - public function test_saveLicenseKey_requiresSuperUserAccess_IfUser() + public function testSaveLicenseKeyRequiresSuperUserAccessIfUser() { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -237,7 +237,7 @@ public function test_saveLicenseKey_requiresSuperUserAccess_IfUser() $this->api->saveLicenseKey('key'); } - public function test_saveLicenseKey_requiresSuperUserAccess_IfAnonymous() + public function testSaveLicenseKeyRequiresSuperUserAccessIfAnonymous() { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -246,7 +246,7 @@ public function test_saveLicenseKey_requiresSuperUserAccess_IfAnonymous() $this->api->saveLicenseKey('key'); } - public function test_saveLicenseKey_shouldThrowException_IfTokenIsNotValid() + public function testSaveLicenseKeyShouldThrowExceptionIfTokenIsNotValid() { $this->expectException(Exception::class); $this->expectExceptionMessage('Marketplace_ExceptionLinceseKeyIsNotValid'); @@ -255,7 +255,7 @@ public function test_saveLicenseKey_shouldThrowException_IfTokenIsNotValid() $this->api->saveLicenseKey('key'); } - public function test_saveLicenseKey_shouldCallTheApiTheCorrectWay() + public function testSaveLicenseKeyShouldCallTheApiTheCorrectWay() { $this->service->returnFixture('v2.0_consumer-access_token-valid_but_expired.json'); @@ -271,7 +271,7 @@ public function test_saveLicenseKey_shouldCallTheApiTheCorrectWay() $this->assertNotHasLicenseKey(); } - public function test_saveLicenseKey_shouldActuallySaveToken_IfValid() + public function testSaveLicenseKeyShouldActuallySaveTokenIfValid() { $this->service->returnFixture('v2.0_consumer_validate-access_token-consumer1_paid2_custom1.json'); $success = $this->api->saveLicenseKey('123licensekey'); @@ -281,7 +281,7 @@ public function test_saveLicenseKey_shouldActuallySaveToken_IfValid() $this->assertSame('123licensekey', $this->buildLicenseKey()->get()); } - public function test_saveLicenseKey_shouldThrowException_IfConnectionToMarketplaceFailed() + public function testSaveLicenseKeyShouldThrowExceptionIfConnectionToMarketplaceFailed() { $this->expectException(ServiceException::class); $this->expectExceptionMessage('Host not reachable'); @@ -290,7 +290,7 @@ public function test_saveLicenseKey_shouldThrowException_IfConnectionToMarketpla $this->api->saveLicenseKey('123licensekey'); } - public function test_startFreeTrial_requiresSuperUserAccess_IfUser() + public function testStartFreeTrialRequiresSuperUserAccessIfUser() { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -299,7 +299,7 @@ public function test_startFreeTrial_requiresSuperUserAccess_IfUser() $this->api->startFreeTrial('testPlugin'); } - public function test_startFreeTrial_requiresSuperUserAccess_IfAnonymous(): void + public function testStartFreeTrialRequiresSuperUserAccessIfAnonymous(): void { $this->expectException(Exception::class); $this->expectExceptionMessage('checkUserHasSuperUserAccess'); @@ -308,7 +308,7 @@ public function test_startFreeTrial_requiresSuperUserAccess_IfAnonymous(): void $this->api->startFreeTrial('testPlugin'); } - public function test_startFreeTrial_requiresValidPluginName(): void + public function testStartFreeTrialRequiresValidPluginName(): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid plugin name given'); @@ -316,7 +316,7 @@ public function test_startFreeTrial_requiresValidPluginName(): void $this->api->startFreeTrial('this/is/not/valid'); } - public function test_startFreeTrial_shouldThrowException_ifMarketplaceRequestEncountersHttpError(): void + public function testStartFreeTrialShouldThrowExceptionIfMarketplaceRequestEncountersHttpError(): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Host not reachable'); @@ -325,7 +325,7 @@ public function test_startFreeTrial_shouldThrowException_ifMarketplaceRequestEnc $this->api->startFreeTrial('testPlugin'); } - public function test_startFreeTrial_shouldSucceedIfMarketplaceCallsDidNotFail(): void + public function testStartFreeTrialShouldSucceedIfMarketplaceCallsDidNotFail(): void { $pluginName = 'testPlugin'; $expectedAction = 'plugins/' . $pluginName . '/freeTrial'; @@ -346,7 +346,7 @@ public function test_startFreeTrial_shouldSucceedIfMarketplaceCallsDidNotFail(): /** * @dataProvider dataStartFreeTrialErrorDownloadResponses */ - public function test_startFreeTrial_shouldThrowException_ifSomethingGoesWrong( + public function testStartFreeTrialShouldThrowExceptionIfSomethingGoesWrong( array $responseInfo, string $expectedException, string $expectedExceptionMessage diff --git a/plugins/Marketplace/tests/Integration/ClientTest.php b/plugins/Marketplace/tests/Integration/ClientTest.php index ac1ed0b9ac8..cc671c29988 100644 --- a/plugins/Marketplace/tests/Integration/ClientTest.php +++ b/plugins/Marketplace/tests/Integration/ClientTest.php @@ -41,7 +41,7 @@ public function setUp(): void $this->client = $this->buildClient(); } - public function test_download() + public function testDownload() { $this->service->returnFixture('v2.0_plugins_TreemapVisualization_info.json'); @@ -55,7 +55,7 @@ public function test_download() $this->assertStringEndsWith('.zip', $file); } - public function test_getPluginInfo_shouldThrowException_IfNotAllowedToRequestPlugin() + public function testGetPluginInfoShouldThrowExceptionIfNotAllowedToRequestPlugin() { $this->expectException(\Piwik\Plugins\Marketplace\Api\Exception::class); $this->expectExceptionMessage('Requested plugin does not exist.'); diff --git a/plugins/Marketplace/tests/Integration/EnvironmentTest.php b/plugins/Marketplace/tests/Integration/EnvironmentTest.php index 09c41a028f1..3aace2dad0b 100644 --- a/plugins/Marketplace/tests/Integration/EnvironmentTest.php +++ b/plugins/Marketplace/tests/Integration/EnvironmentTest.php @@ -44,44 +44,44 @@ public function setUp(): void $this->environment = new Environment($releaseChannes); } - public function test_getPhpVersion() + public function testGetPhpVersion() { $phpVersion = explode('-', phpversion()); // cater for pre-release versions like 8.3.0-dev $this->assertTrue(version_compare($phpVersion[0], $this->environment->getPhpVersion(), '>=')); } - public function test_getPiwikVersion() + public function testGetPiwikVersion() { $this->assertEquals(Version::VERSION, $this->environment->getPiwikVersion()); } - public function test_setPiwikVersion_OverwritesCurrentPiwikVersion() + public function testSetPiwikVersionOverwritesCurrentPiwikVersion() { $this->environment->setPiwikVersion('1.12.0'); $this->assertSame('1.12.0', $this->environment->getPiwikVersion()); } - public function test_getNumUsers() + public function testGetNumUsers() { $this->assertSame(1, $this->environment->getNumUsers()); } - public function test_getNumWebsites() + public function testGetNumWebsites() { $this->assertSame(3, $this->environment->getNumWebsites()); } - public function test_getMySQLVersion() + public function testGetMySQLVersion() { $this->assertNotEmpty($this->environment->getMySQLVersion()); } - public function test_getReleaseChannel() + public function testGetReleaseChannel() { $this->assertEquals('latest_stable', $this->environment->getReleaseChannel()); } - public function test_doesPreferStable() + public function testDoesPreferStable() { $this->assertTrue($this->environment->doesPreferStable()); } diff --git a/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php b/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php index 35f1f824fbc..5e90b9917a2 100644 --- a/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php +++ b/plugins/Marketplace/tests/Integration/Input/PluginNameTest.php @@ -25,7 +25,7 @@ public function tearDown(): void unset($_GET['pluginName']); } - public function test_findsPluginName() + public function testFindsPluginName() { $this->setPluginName('CoreFooBar'); @@ -33,7 +33,7 @@ public function test_findsPluginName() $this->assertSame('CoreFooBar', $pluginName->getPluginName()); } - public function test_throws_exception_ifInvalidName() + public function testThrowsExceptionIfInvalidName() { $this->expectException(\Exception::class); $this->expectExceptionMessage('Invalid plugin name given'); diff --git a/plugins/Marketplace/tests/Integration/LicenseKeyTest.php b/plugins/Marketplace/tests/Integration/LicenseKeyTest.php index dcdeabc79fe..52042996ee6 100644 --- a/plugins/Marketplace/tests/Integration/LicenseKeyTest.php +++ b/plugins/Marketplace/tests/Integration/LicenseKeyTest.php @@ -32,13 +32,13 @@ public function setUp(): void $this->licenseKey = $this->buildLicenseKey(); } - public function test_get_noLicenseKeyIsSetByDefault() + public function testGetNoLicenseKeyIsSetByDefault() { $this->assertFalse($this->licenseKey->get()); $this->assertFalse($this->licenseKey->has()); } - public function test_set_get_persistsALicenseKey() + public function testSetGetPersistsALicenseKey() { $key = 'foobarBaz'; $this->licenseKey->set($key); @@ -48,7 +48,7 @@ public function test_set_get_persistsALicenseKey() $this->assertPersistedLicenseKeyEquals($key); } - public function test_set_shouldOverwriteAnExistingKey() + public function testSetShouldOverwriteAnExistingKey() { $this->setExampleLicenseKey(); @@ -58,7 +58,7 @@ public function test_set_shouldOverwriteAnExistingKey() $this->assertPersistedLicenseKeyEquals($key); } - public function test_set_deletesAnExistingLicenseKey_IfValueIsFalse() + public function testSetDeletesAnExistingLicenseKeyIfValueIsFalse() { $this->setExampleLicenseKey(); @@ -66,7 +66,7 @@ public function test_set_deletesAnExistingLicenseKey_IfValueIsFalse() $this->assertFalse($this->licenseKey->has()); } - public function test_set_deletesAnExistingLicenseKey_IfValueIsNotSet() + public function testSetDeletesAnExistingLicenseKeyIfValueIsNotSet() { $this->setExampleLicenseKey(); @@ -74,7 +74,7 @@ public function test_set_deletesAnExistingLicenseKey_IfValueIsNotSet() $this->assertFalse($this->licenseKey->has()); } - public function test_has_detectsWhetherANonEmptyKeyIsSet() + public function testHasDetectsWhetherANonEmptyKeyIsSet() { $this->assertNotHasPersistedLicenseKey(); $this->setExampleLicenseKey(); diff --git a/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php b/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php index c7350ad1780..1dad3b5bca6 100644 --- a/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php +++ b/plugins/Marketplace/tests/Integration/Plugins/InvalidLicensesTest.php @@ -64,7 +64,7 @@ public function tearDown(): void parent::tearDown(); } - public function test_getNamesOfExpiredPaidPlugins_validLicenses_noPaidPluginActivated() + public function testGetNamesOfExpiredPaidPluginsValidLicensesNoPaidPluginActivated() { $expired = $this->buildWithValidLicense(); $expired->setPluginIsActivated(false); @@ -74,7 +74,7 @@ public function test_getNamesOfExpiredPaidPlugins_validLicenses_noPaidPluginActi $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_noLicenses_noPaidPluginActivated() + public function testGetNamesOfExpiredPaidPluginsNoLicensesNoPaidPluginActivated() { $expired = $this->buildWithNoLicense(); $expired->setPluginIsActivated(false); @@ -87,7 +87,7 @@ public function test_getNamesOfExpiredPaidPlugins_noLicenses_noPaidPluginActivat $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_invalidLicenses_noPaidPluginActivated() + public function testGetNamesOfExpiredPaidPluginsInvalidLicensesNoPaidPluginActivated() { $expired = $this->buildWithExpiredLicense(); $expired->setPluginIsActivated(false); @@ -100,7 +100,7 @@ public function test_getNamesOfExpiredPaidPlugins_invalidLicenses_noPaidPluginAc $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_exceededLicenses_noPaidPluginActivated() + public function testGetNamesOfExpiredPaidPluginsExceededLicensesNoPaidPluginActivated() { $expired = $this->buildWithExceededLicense(); $expired->setPluginIsActivated(false); @@ -110,7 +110,7 @@ public function test_getNamesOfExpiredPaidPlugins_exceededLicenses_noPaidPluginA $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_validLicenses() + public function testGetNamesOfExpiredPaidPluginsValidLicenses() { $expired = $this->buildWithValidLicense(); @@ -119,7 +119,7 @@ public function test_getNamesOfExpiredPaidPlugins_validLicenses() $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_noLicenses() + public function testGetNamesOfExpiredPaidPluginsNoLicenses() { $expired = $this->buildWithNoLicense(); @@ -131,7 +131,7 @@ public function test_getNamesOfExpiredPaidPlugins_noLicenses() $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_invalidLicenses() + public function testGetNamesOfExpiredPaidPluginsInvalidLicenses() { $expired = $this->buildWithExpiredLicense(); @@ -143,7 +143,7 @@ public function test_getNamesOfExpiredPaidPlugins_invalidLicenses() $this->assertSame($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_exceededLicenses() + public function testGetNamesOfExpiredPaidPluginsExceededLicenses() { $expired = $this->buildWithExceededLicense(); @@ -154,7 +154,7 @@ public function test_getNamesOfExpiredPaidPlugins_exceededLicenses() $this->assertEquals($expected, $expired->getPluginNamesOfInvalidLicenses()); } - public function test_getNamesOfExpiredPaidPlugins_shouldCacheAnyResult() + public function testGetNamesOfExpiredPaidPluginsShouldCacheAnyResult() { $this->assertFalse($this->cache->contains($this->cacheKey)); @@ -167,7 +167,7 @@ public function test_getNamesOfExpiredPaidPlugins_shouldCacheAnyResult() $this->assertSame($expected, $this->cache->fetch($this->cacheKey)); } - public function test_getNamesOfExpiredPaidPlugins_shouldCache_IfNotValidLicenseKeyButPaidPluginsInstalled() + public function testGetNamesOfExpiredPaidPluginsShouldCacheIfNotValidLicenseKeyButPaidPluginsInstalled() { $this->buildWithExpiredLicense()->getPluginNamesOfInvalidLicenses(); @@ -179,7 +179,7 @@ public function test_getNamesOfExpiredPaidPlugins_shouldCache_IfNotValidLicenseK $this->assertSame($expected, $this->cache->fetch($this->cacheKey)); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_validLicenses_noPaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesValidLicensesNoPaidPluginActivated() { $expired = $this->buildWithValidLicense(); $expired->setPluginIsActivated(false); @@ -189,7 +189,7 @@ public function test_getMessageExceededLicenses_getMessageExpiredLicenses_validL $this->assertNull($expired->getMessageNoLicense()); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_invalidLicenses_noPaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesInvalidLicensesNoPaidPluginActivated() { $expired = $this->buildWithExpiredLicense(); $expired->setPluginIsActivated(false); @@ -199,7 +199,7 @@ public function test_getMessageExceededLicenses_getMessageExpiredLicenses_invali $this->assertNull($expired->getMessageNoLicense()); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_exceededLicenses_noPaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesExceededLicensesNoPaidPluginActivated() { $expired = $this->buildWithExceededLicense(); $expired->setPluginIsActivated(false); @@ -208,7 +208,7 @@ public function test_getMessageExceededLicenses_getMessageExpiredLicenses_exceed $this->assertNull($expired->getMessageNoLicense()); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_validLicenses_PaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesValidLicensesPaidPluginActivated() { $expired = $this->buildWithValidLicense(); @@ -217,7 +217,7 @@ public function test_getMessageExceededLicenses_getMessageExpiredLicenses_validL $this->assertNull($expired->getMessageNoLicense()); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_noLicenses_PaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesNoLicensesPaidPluginActivated() { // in theory we would need to show a warning as there is no license, but this can also happen if there's some random // error and the user actually has a license, eg if the request aborted when fetching consumer etc @@ -228,7 +228,7 @@ public function test_getMessageExceededLicenses_getMessageExpiredLicenses_noLice $this->assertEquals('The following plugins have been deactivated because you are using them without a license: PaidPlugin1.
To resolve this issue either update your license key, get a subscription now or deactivate the plugin.
View your plugin subscriptions.', $expired->getMessageNoLicense()); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_invalidLicenses_PaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesInvalidLicensesPaidPluginActivated() { $expired = $this->buildWithExpiredLicense(); @@ -236,14 +236,14 @@ public function test_getMessageExceededLicenses_getMessageExpiredLicenses_invali $this->assertEquals('The licenses for the following plugins are expired: PaidPlugin1.
You will no longer receive any updates for these plugins. To resolve this issue either renew your subscription now, or deactivate the plugin if you no longer use it.
View your plugin subscriptions.', $expired->getMessageExpiredLicenses()); } - public function test_getMessageExceededLicenses_getMessageExpiredLicenses_exceededLicenses_PaidPluginActivated() + public function testGetMessageExceededLicensesGetMessageExpiredLicensesExceededLicensesPaidPluginActivated() { $expired = $this->buildWithExceededLicense(); $this->assertEquals('The licenses for the following plugins are no longer valid as the number of authorized users for the license is exceeded: PaidPlugin2.
You will not be able to download updates for these plugins. To resolve this issue either delete some users or upgrade the subscription now.
View your plugin subscriptions.', $expired->getMessageExceededLicenses()); $this->assertEquals('The licenses for the following plugins are expired: PaidPlugin1.
You will no longer receive any updates for these plugins. To resolve this issue either renew your subscription now, or deactivate the plugin if you no longer use it.
View your plugin subscriptions.', $expired->getMessageExpiredLicenses()); } - public function test_getMessageMissingLicenses_getMessageMissingLicenses_PaidPluginActivated() + public function testGetMessageMissingLicensesGetMessageMissingLicensesPaidPluginActivated() { $expired = $this->buildWithNoLicense(); $this->assertEquals('The following plugins have been deactivated because you are using them without a license: PaidPlugin1.
To resolve this issue either update your license key, get a subscription now or deactivate the plugin.
View your plugin subscriptions.', $expired->getMessageNoLicense()); diff --git a/plugins/Marketplace/tests/Integration/PluginsTest.php b/plugins/Marketplace/tests/Integration/PluginsTest.php index 00505d667df..7d19d084f1b 100644 --- a/plugins/Marketplace/tests/Integration/PluginsTest.php +++ b/plugins/Marketplace/tests/Integration/PluginsTest.php @@ -362,7 +362,7 @@ public function getPluginInfoShouldSetFreeTrialEligibilityTestData(): iterable ]; } - public function testSearchPlugins_WithSearchAndNoPluginsFound_shouldCallCorrectApi() + public function testSearchPluginsWithSearchAndNoPluginsFoundShouldCallCorrectApi() { $this->service->returnFixture('v2.0_plugins-query-nomatchforthisquery.json'); $this->plugins->setPluginsHavingUpdateCache([]); @@ -387,7 +387,7 @@ public function testSearchPlugins_WithSearchAndNoPluginsFound_shouldCallCorrectA $this->assertSame($params, $this->service->params); } - public function testSearchThemes_ShouldCallCorrectApi() + public function testSearchThemesShouldCallCorrectApi() { $this->service->returnFixture('v2.0_themes.json'); $this->plugins->setPluginsHavingUpdateCache([]); diff --git a/plugins/Marketplace/tests/Integration/ServiceTest.php b/plugins/Marketplace/tests/Integration/ServiceTest.php index dfc25356dd8..a32bf84eec6 100644 --- a/plugins/Marketplace/tests/Integration/ServiceTest.php +++ b/plugins/Marketplace/tests/Integration/ServiceTest.php @@ -32,7 +32,7 @@ public function setUp(): void $this->service = new TestService(); } - public function test_fetch_throwsApiError_WhenMarketplaceReturnsAnError() + public function testFetchThrowsApiErrorWhenMarketplaceReturnsAnError() { $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class); $this->expectExceptionCode(101); @@ -42,7 +42,7 @@ public function test_fetch_throwsApiError_WhenMarketplaceReturnsAnError() $this->service->fetch('plugins/CustomPlugin1/info', array()); } - public function test_fetch_throwsHttpError_WhenMarketplaceReturnsNoResultWhichMeansHttpError() + public function testFetchThrowsHttpErrorWhenMarketplaceReturnsNoResultWhichMeansHttpError() { $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class); $this->expectExceptionCode(100); @@ -54,7 +54,7 @@ public function test_fetch_throwsHttpError_WhenMarketplaceReturnsNoResultWhichMe $this->service->fetch('plugins/CustomPlugin1/info', array()); } - public function test_fetch_jsonDecodesTheHttpResponse() + public function testFetchJsonDecodesTheHttpResponse() { $this->service->returnFixture('v2.0_consumer-access_token-consumer1_paid2_custom1.json'); $consumer = $this->service->fetch('consumer', array()); diff --git a/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php b/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php index 3981b9e7715..7aa4466d210 100644 --- a/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php +++ b/plugins/Marketplace/tests/Integration/UpdateCommunicationTest.php @@ -45,7 +45,7 @@ public function setUp(): void $this->updateCommunication = new UpdateCommunication($this->settings); } - public function test_canBeEnabled() + public function testCanBeEnabled() { $this->assertTrue(UpdateCommunication::canBeEnabled()); @@ -56,7 +56,7 @@ public function test_canBeEnabled() $this->assertTrue(UpdateCommunication::canBeEnabled()); } - public function test_isEnabled_shouldReturnFalse_IfCannotBeEnabled() + public function testIsEnabledShouldReturnFalseIfCannotBeEnabled() { $this->assertTrue($this->updateCommunication->isEnabled()); @@ -64,7 +64,7 @@ public function test_isEnabled_shouldReturnFalse_IfCannotBeEnabled() $this->assertFalse($this->updateCommunication->isEnabled()); } - public function test_sendNotificationIfUpdatesAvailable_shouldNotSendNotification_IfNoUpdateAvailable() + public function testSendNotificationIfUpdatesAvailableShouldNotSendNotificationIfNoUpdateAvailable() { $mock = $this->getCommunicationMock(array()); $mock->expects($this->never())->method('sendEmailNotification'); @@ -74,7 +74,7 @@ public function test_sendNotificationIfUpdatesAvailable_shouldNotSendNotificatio /** * @dataProvider provideSendNotificationData */ - public function test_sendNotificationIfUpdatesAvailable($latestVersion, $lastSentVersion, $expects, $expectedLastSentVersion) + public function testSendNotificationIfUpdatesAvailable($latestVersion, $lastSentVersion, $expects, $expectedLastSentVersion) { $pluginsHavingUpdate = array( array('name' => 'MyTest', 'latestVersion' => $latestVersion, 'isTheme' => false) @@ -98,14 +98,14 @@ public function provideSendNotificationData() ); } - public function test_sendNotificationIfUpdatesAvailable_ShouldSendOnlyOneEmail_IfMultipleUpdatesAreAvailable() + public function testSendNotificationIfUpdatesAvailableShouldSendOnlyOneEmailIfMultipleUpdatesAreAvailable() { $mock = $this->getCommunicationMockHavingManyUpdates(); $mock->expects($this->once())->method('sendEmailNotification'); $mock->sendNotificationIfUpdatesAvailable(); } - public function test_sendNotificationIfUpdatesAvailable_ShouldUpdateAllSentVersions_IfMultipleUpdatesAreAvailable() + public function testSendNotificationIfUpdatesAvailableShouldUpdateAllSentVersionsIfMultipleUpdatesAreAvailable() { $mock = $this->getCommunicationMockHavingManyUpdates(); $mock->expects($this->once())->method('sendEmailNotification'); @@ -116,7 +116,7 @@ public function test_sendNotificationIfUpdatesAvailable_ShouldUpdateAllSentVersi $this->assertEquals('31.0.0', $this->getLastSentVersion('MyTest3')); } - public function test_sendNotificationIfUpdatesAvailable_ShouldSendCorrectText() + public function testSendNotificationIfUpdatesAvailableShouldSendCorrectText() { $subject = 'CoreUpdater_NotificationSubjectAvailablePluginUpdate'; $rootUrl = Fixture::getTestRootUrl(); diff --git a/plugins/Marketplace/tests/System/Api/ClientTest.php b/plugins/Marketplace/tests/System/Api/ClientTest.php index 96ced70c0e4..b0ed1443233 100644 --- a/plugins/Marketplace/tests/System/Api/ClientTest.php +++ b/plugins/Marketplace/tests/System/Api/ClientTest.php @@ -50,7 +50,7 @@ public function setUp(): void $this->getCache()->flushAll(); } - public function test_getPluginInfo_existingPluginOnTheMarketplace() + public function testGetPluginInfoExistingPluginOnTheMarketplace() { $plugin = $this->client->getPluginInfo('SecurityInfo'); @@ -111,7 +111,7 @@ public function test_getPluginInfo_existingPluginOnTheMarketplace() $this->assertNotEmpty($lastVersion['download']); } - public function test_getPluginInfo_shouldThrowException_IfPluginDoesNotExistOnMarketplace() + public function testGetPluginInfoShouldThrowExceptionIfPluginDoesNotExistOnMarketplace() { $this->expectException(\Piwik\Plugins\Marketplace\Api\Exception::class); $this->expectExceptionMessage('Requested plugin does not exist.'); @@ -119,17 +119,17 @@ public function test_getPluginInfo_shouldThrowException_IfPluginDoesNotExistOnMa $this->client->getPluginInfo('NotExistingPlugIn'); } - public function test_getConsumer_shouldReturnNullAndNotThrowException_IfNotAuthorized() + public function testGetConsumerShouldReturnNullAndNotThrowExceptionIfNotAuthorized() { $this->assertNull($this->client->getConsumer()); } - public function test_isValidConsumer_shouldReturnFalseAndNotThrowException_IfNotAuthorized() + public function testIsValidConsumerShouldReturnFalseAndNotThrowExceptionIfNotAuthorized() { $this->assertFalse($this->client->isValidConsumer()); } - public function test_searchForPlugins_requestAll() + public function testSearchForPluginsRequestAll() { $plugins = $this->client->searchForPlugins($keywords = '', $query = '', $sort = '', $purchaseType = PurchaseType::TYPE_ALL); @@ -141,7 +141,7 @@ public function test_searchForPlugins_requestAll() } } - public function test_searchForPlugins_onlyFree() + public function testSearchForPluginsOnlyFree() { $plugins = $this->client->searchForPlugins($keywords = '', $query = '', $sort = '', $purchaseType = PurchaseType::TYPE_FREE); @@ -154,7 +154,7 @@ public function test_searchForPlugins_onlyFree() } } - public function test_searchForPlugins_onlyPaid() + public function testSearchForPluginsOnlyPaid() { $plugins = $this->client->searchForPlugins($keywords = '', $query = '', $sort = '', $purchaseType = PurchaseType::TYPE_PAID); @@ -168,7 +168,7 @@ public function test_searchForPlugins_onlyPaid() } } - public function test_searchForPlugins_withKeyword() + public function testSearchForPluginsWithKeyword() { $plugins = $this->client->searchForPlugins($keywords = 'login', $query = '', $sort = '', $purchaseType = PurchaseType::TYPE_ALL); @@ -180,7 +180,7 @@ public function test_searchForPlugins_withKeyword() } } - public function test_searchForThemes_requestAll() + public function testSearchForThemesRequestAll() { $plugins = $this->client->searchForThemes($keywords = '', $query = '', $sort = '', $purchaseType = PurchaseType::TYPE_ALL); @@ -193,7 +193,7 @@ public function test_searchForThemes_requestAll() } } - public function test_getDownloadUrl() + public function testGetDownloadUrl() { $url = $this->client->getDownloadUrl('SecurityInfo'); @@ -209,7 +209,7 @@ public function test_getDownloadUrl() $this->assertRegExp('/\d+\.\d+\.\d+/', $version); } - public function test_clientResponse_shouldBeCached() + public function testClientResponseShouldBeCached() { $params = array( 'keywords' => 'login', @@ -239,7 +239,7 @@ public function test_clientResponse_shouldBeCached() $this->assertGreaterThan(30, $cachedPlugins); } - public function test_cachedClientResponse_shouldBeReturned() + public function testCachedClientResponseShouldBeReturned() { $params = array( 'keywords' => 'login', @@ -263,7 +263,7 @@ public function test_cachedClientResponse_shouldBeReturned() $this->assertSame(array(array('name' => 'foobar')), $result); } - public function test_getInfoOfPluginsHavingUpdate() + public function testGetInfoOfPluginsHavingUpdate() { $service = new TestService($this->domain); $client = $this->buildClient($service); diff --git a/plugins/Marketplace/tests/System/Api/ServiceTest.php b/plugins/Marketplace/tests/System/Api/ServiceTest.php index fd682a61a9b..3a396618d76 100644 --- a/plugins/Marketplace/tests/System/Api/ServiceTest.php +++ b/plugins/Marketplace/tests/System/Api/ServiceTest.php @@ -24,26 +24,26 @@ class ServiceTest extends SystemTestCase { private $domain = 'http://plugins.piwik.org'; - public function test_shouldUseVersion2() + public function testShouldUseVersion2() { $service = $this->buildService(); $this->assertSame('2.0', $service->getVersion()); } - public function test_getDomain_shouldReturnPassedDomain() + public function testGetDomainShouldReturnPassedDomain() { $service = $this->buildService(); $this->assertSame($this->domain, $service->getDomain()); } - public function test_authenticate_getAccessToken_shouldSaveToken_IfOnlyHasAlNumValues() + public function testAuthenticateGetAccessTokenShouldSaveTokenIfOnlyHasAlNumValues() { $service = $this->buildService(); $service->authenticate('123456789abcdefghij'); $this->assertSame('123456789abcdefghij', $service->getAccessToken()); } - public function test_hasAccessToken() + public function testHasAccessToken() { $service = $this->buildService(); $this->assertFalse($service->hasAccessToken()); @@ -51,21 +51,21 @@ public function test_hasAccessToken() $this->assertTrue($service->hasAccessToken()); } - public function test_authenticate_getAccessToken_emptyTokenShouldUnsetToken() + public function testAuthenticateGetAccessTokenEmptyTokenShouldUnsetToken() { $service = $this->buildService(); $service->authenticate(''); $this->assertNull($service->getAccessToken()); } - public function test_authenticate_getAccessToken_invalidTokenContainingInvalidCharactersShouldBeIgnored() + public function testAuthenticateGetAccessTokenInvalidTokenContainingInvalidCharactersShouldBeIgnored() { $service = $this->buildService(); $service->authenticate('123_-4?'); $this->assertNull($service->getAccessToken()); } - public function test_fetch_shouldCallMarketplaceApiWithActionAndReturnArrays() + public function testFetchShouldCallMarketplaceApiWithActionAndReturnArrays() { $service = $this->buildService(); $response = $service->fetch('plugins', array()); @@ -78,7 +78,7 @@ public function test_fetch_shouldCallMarketplaceApiWithActionAndReturnArrays() } } - public function test_fetch_shouldCallMarketplaceApiWithGivenParamsAndReturnArrays() + public function testFetchShouldCallMarketplaceApiWithGivenParamsAndReturnArrays() { $keyword = 'login'; $service = $this->buildService(); @@ -90,7 +90,7 @@ public function test_fetch_shouldCallMarketplaceApiWithGivenParamsAndReturnArray } } - public function test_fetch_shouldThrowException_WhenNotBeingAuthenticated() + public function testFetchShouldThrowExceptionWhenNotBeingAuthenticated() { $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class); $this->expectExceptionCode(101); @@ -100,7 +100,7 @@ public function test_fetch_shouldThrowException_WhenNotBeingAuthenticated() $service->fetch('consumer', array()); } - public function test_fetch_shouldThrowException_WhenBeingAuthenticatedWithInvalidTokens() + public function testFetchShouldThrowExceptionWhenBeingAuthenticatedWithInvalidTokens() { $this->expectException(\Piwik\Plugins\Marketplace\Api\Service\Exception::class); $this->expectExceptionCode(101); @@ -111,7 +111,7 @@ public function test_fetch_shouldThrowException_WhenBeingAuthenticatedWithInvali $service->fetch('consumer', array()); } - public function test_download_shouldReturnRawResultForAbsoluteUrl() + public function testDownloadShouldReturnRawResultForAbsoluteUrl() { $service = $this->buildService(); $response = $service->download($this->domain . '/api/2.0/plugins'); @@ -121,7 +121,7 @@ public function test_download_shouldReturnRawResultForAbsoluteUrl() $this->assertStringStartsWith('{"plugins"', $response); } - public function test_download_shouldSaveResultInFileIfPathGiven() + public function testDownloadShouldSaveResultInFileIfPathGiven() { $path = StaticContainer::get('path.tmp') . '/marketplace_test_file.json'; @@ -139,7 +139,7 @@ public function test_download_shouldSaveResultInFileIfPathGiven() Filesystem::deleteFileIfExists($path); } - public function test_timeout_invalidService_ShouldFailIfNotReachable() + public function testTimeoutInvalidServiceShouldFailIfNotReachable() { // The exact exception may vary depending on the connection backend being used (curl, sockets, fopen, etc), so // we just check that some exception is thrown when the method is passed an invalid domain diff --git a/plugins/Marketplace/tests/Unit/ConsumerTest.php b/plugins/Marketplace/tests/Unit/ConsumerTest.php index fb148b327c8..822f23dd8c8 100644 --- a/plugins/Marketplace/tests/Unit/ConsumerTest.php +++ b/plugins/Marketplace/tests/Unit/ConsumerTest.php @@ -34,7 +34,7 @@ public function setUp(): void /** * @dataProvider getConsumerNotAuthenticated */ - public function test_isValidConsumer_shouldReturnFalse_WhenNotAuthenticedBecauseNoTokenSetOrInvalidToken($fixture) + public function testIsValidConsumerShouldReturnFalseWhenNotAuthenticedBecauseNoTokenSetOrInvalidToken($fixture) { $this->service->returnFixture($fixture); $this->assertFalse($this->buildConsumer()->isValidConsumer()); @@ -43,13 +43,13 @@ public function test_isValidConsumer_shouldReturnFalse_WhenNotAuthenticedBecause /** * @dataProvider getConsumerAuthenticated */ - public function test_isValidConsumer_shouldReturnTrue_WhenValidTokenGiven($fixture) + public function testIsValidConsumerShouldReturnTrueWhenValidTokenGiven($fixture) { $this->service->returnFixture($fixture); $this->assertTrue($this->buildConsumer()->isValidConsumer()); } - public function test_getConsumer_shouldReturnConsumerInformation_WhenValid() + public function testGetConsumerShouldReturnConsumerInformationWhenValid() { $this->service->returnFixture('v2.0_consumer-access_token-consumer1_paid2_custom1.json'); @@ -98,14 +98,14 @@ public function test_getConsumer_shouldReturnConsumerInformation_WhenValid() $this->assertEquals($expected, $this->buildConsumer()->getConsumer()); } - public function test_getConsumer_shouldNotReturnAnyInformationWhenNotAuthenticated() + public function testGetConsumerShouldNotReturnAnyInformationWhenNotAuthenticated() { $this->service->returnFixture('v2.0_consumer-access_token-notexistingtoken.json'); $this->assertSame(array(), $this->buildConsumer()->getConsumer()); } - public function test_getConsumer_shouldNotReturnInformationWhenAuthenticatedButNoLicense() + public function testGetConsumerShouldNotReturnInformationWhenAuthenticatedButNoLicense() { $this->service->returnFixture('v2.0_consumer-access_token-validbutnolicense.json'); @@ -134,14 +134,14 @@ public function getConsumerAuthenticated() ); } - public function test_buildInvalidLicenseKey() + public function testBuildInvalidLicenseKey() { $isValid = Consumer::buildNoLicense()->isValidConsumer(); $this->assertFalse($isValid); } - public function test_buildValidLicenseKey() + public function testBuildValidLicenseKey() { $isValid = Consumer::buildValidLicense()->isValidConsumer(); diff --git a/plugins/Monolog/tests/System/TrackerLoggingTest.php b/plugins/Monolog/tests/System/TrackerLoggingTest.php index afd2d984cd4..000355706f3 100644 --- a/plugins/Monolog/tests/System/TrackerLoggingTest.php +++ b/plugins/Monolog/tests/System/TrackerLoggingTest.php @@ -36,7 +36,7 @@ public function setUp(): void } } - public function test_shouldReturnDebugOutput_IfDebugIsEnabled() + public function testShouldReturnDebugOutputIfDebugIsEnabled() { $this->setTrackerConfig(array('debug' => '1')); @@ -44,7 +44,7 @@ public function test_shouldReturnDebugOutput_IfDebugIsEnabled() $this->assertTrackerResponseContainsLogOutput($tracker); } - public function test_shouldReturnDebugOutput_IfDebugOnDemandIsEnabled() + public function testShouldReturnDebugOutputIfDebugOnDemandIsEnabled() { $this->setTrackerConfig(array('debug_on_demand' => '1', 'debug' => 0)); @@ -53,7 +53,7 @@ public function test_shouldReturnDebugOutput_IfDebugOnDemandIsEnabled() $this->assertTrackerResponseContainsLogOutput($tracker); } - public function test_shouldNotReturnDebugOutput_IfDebugOnDemandIsDisabled() + public function testShouldNotReturnDebugOutputIfDebugOnDemandIsDisabled() { $this->setTrackerConfig(array('debug_on_demand' => '0', 'debug' => 0)); diff --git a/plugins/Monolog/tests/Unit/Formatter/LineMessageFormatterTest.php b/plugins/Monolog/tests/Unit/Formatter/LineMessageFormatterTest.php index 52c9aa67349..93f3b608a5a 100644 --- a/plugins/Monolog/tests/Unit/Formatter/LineMessageFormatterTest.php +++ b/plugins/Monolog/tests/Unit/Formatter/LineMessageFormatterTest.php @@ -18,10 +18,7 @@ */ class LineMessageFormatterTest extends \PHPUnit\Framework\TestCase { - /** - * @test - */ - public function it_should_format_with_placeholders() + public function testItShouldFormatWithPlaceholders() { $formatter = new LineMessageFormatter('%level% %tag% %datetime% %message%'); @@ -39,10 +36,7 @@ public function it_should_format_with_placeholders() $this->assertEquals($formatted, $formatter->format($record)); } - /** - * @test - */ - public function it_should_insert_request_id_if_defined() + public function testItShouldInsertRequestIdIfDefined() { $formatter = new LineMessageFormatter('%message%'); @@ -60,10 +54,7 @@ public function it_should_insert_request_id_if_defined() $this->assertEquals($formatted, $formatter->format($record)); } - /** - * @test - */ - public function it_should_indent_multiline_message() + public function testItShouldIndentMultilineMessage() { $formatter = new LineMessageFormatter('%level% %message%'); @@ -83,10 +74,7 @@ public function it_should_indent_multiline_message() $this->assertEquals($formatted, $formatter->format($record)); } - /** - * @test - */ - public function it_should_split_inline_line_breaks_into_many_messages_if_disabled() + public function testItShouldSplitInlineLineBreaksIntoManyMessagesIfDisabled() { $formatter = new LineMessageFormatter('%level% %message%', $allowInlineLineBreaks = false); diff --git a/plugins/Monolog/tests/Unit/Processor/ClassNameProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/ClassNameProcessorTest.php index d0ec2d3cf30..1b682b604de 100644 --- a/plugins/Monolog/tests/Unit/Processor/ClassNameProcessorTest.php +++ b/plugins/Monolog/tests/Unit/Processor/ClassNameProcessorTest.php @@ -17,10 +17,7 @@ */ class ClassNameProcessorTest extends \PHPUnit\Framework\TestCase { - /** - * @test - */ - public function it_should_append_classname_to_extra() + public function testItShouldAppendClassnameToExtra() { $processor = new ClassNameProcessor(); diff --git a/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php index ee52de583f4..aabd03fe11d 100644 --- a/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php +++ b/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php @@ -41,10 +41,7 @@ protected function tearDown(): void parent::tearDown(); } - /** - * @test - */ - public function it_should_skip_if_no_exception() + public function testItShouldSkipIfNoException() { $processor = new ExceptionToTextProcessor(); @@ -53,10 +50,7 @@ public function it_should_skip_if_no_exception() $this->assertEquals($record, $processor($record)); } - /** - * @test - */ - public function it_should_replace_message_with_formatted_exception() + public function testItShouldReplaceMessageWithFormattedException() { $processor = new ExceptionToTextProcessor(); Log::$debugBacktraceForTests = '[message and stack trace]'; @@ -82,10 +76,7 @@ public function it_should_replace_message_with_formatted_exception() $this->assertEquals(['context', 'message'], array_keys($result)); } - /** - * @test - */ - public function it_should_add_severity_for_errors() + public function testItShouldAddSeverityForErrors() { $processor = new ExceptionToTextProcessor(); Log::$debugBacktraceForTests = '[message and stack trace]'; @@ -109,7 +100,7 @@ public function it_should_add_severity_for_errors() $this->assertEquals($expected, $result); } - public function test_getMessageAndWholeBacktrace_doesNotPrintBacktraceIfInCliMode_AndNotCoreArchive() + public function testGetMessageAndWholeBacktraceDoesNotPrintBacktraceIfInCliModeAndNotCoreArchive() { $ex = new \Exception('test message'); @@ -125,7 +116,7 @@ public function test_getMessageAndWholeBacktrace_doesNotPrintBacktraceIfInCliMod $this->assertEquals($expected, $wholeTrace); } - public function test_getMessageAndWholeBacktrace_doesNotPrintBacktraceIfNotInCliMode_AndInCoreArchive() + public function testGetMessageAndWholeBacktraceDoesNotPrintBacktraceIfNotInCliModeAndInCoreArchive() { $ex = new \Exception('test message'); @@ -141,7 +132,7 @@ public function test_getMessageAndWholeBacktrace_doesNotPrintBacktraceIfNotInCli $this->assertEquals($expected, $wholeTrace); } - public function test_getMessageAndWholeBacktrace_printsBacktraceIfInCliMode_AndInCoreArchive_EvenIfGlobalVarIsNotSet() + public function testGetMessageAndWholeBacktracePrintsBacktraceIfInCliModeAndInCoreArchiveEvenIfGlobalVarIsNotSet() { $ex = new \Exception('test message'); @@ -154,7 +145,7 @@ public function test_getMessageAndWholeBacktrace_printsBacktraceIfInCliMode_AndI $expected = <<test_getMessageAndWholeBacktrace_printsBacktraceIfInCliMode_AndInCoreArchive_EvenIfGlobalVarIsNotSet() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktracePrintsBacktraceIfInCliModeAndInCoreArchiveEvenIfGlobalVarIsNotSet() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest)) @@ -171,7 +162,7 @@ public function test_getMessageAndWholeBacktrace_printsBacktraceIfInCliMode_AndI $this->assertEquals($this->handleNewerPHPUnitTrace($expected), $wholeTrace); } - public function test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_PRINT_ERROR_BACKTRACE_isDefined() + public function testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKPRINTERRORBACKTRACEIsDefined() { $ex = new \Exception('test message'); @@ -183,7 +174,7 @@ public function test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_PRINT_E $expected = <<test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_PRINT_ERROR_BACKTRACE_isDefined() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKPRINTERRORBACKTRACEisDefined() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest)) @@ -200,7 +191,7 @@ public function test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_PRINT_E $this->assertEquals($this->handleNewerPHPUnitTrace($expected), $wholeTrace); } - public function test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_TRACKER_DEBUG_globalIsSet() + public function testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKTRACKERDEBUGGlobalIsSet() { $ex = new \Exception('test message'); @@ -212,7 +203,7 @@ public function test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_TRACKER $expected = <<test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_TRACKER_DEBUG_globalIsSet() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKTRACKERDEBUGGlobalIsSet() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest)) @@ -229,7 +220,7 @@ public function test_getMessageAndWholeBacktrace_printsBacktraceIf_PIWIK_TRACKER $this->assertEquals($this->handleNewerPHPUnitTrace($expected), $wholeTrace); } - public function test_getMessageAndWholeBacktrace_handlesArrayInput_whenBacktraceIsEnabled() + public function testGetMessageAndWholeBacktraceHandlesArrayInputWhenBacktraceIsEnabled() { $GLOBALS['PIWIK_PRINT_ERROR_BACKTRACE'] = 1; @@ -248,7 +239,7 @@ public function test_getMessageAndWholeBacktrace_handlesArrayInput_whenBacktrace $this->assertEquals($expected, $wholeTrace); } - public function test_getMessageAndWholeBacktrace_handlesArrayInput_whenBacktraceIsDisabled() + public function testGetMessageAndWholeBacktraceHandlesArrayInputWhenBacktraceIsDisabled() { $exArray = [ 'message' => 'themessage', @@ -262,7 +253,7 @@ public function test_getMessageAndWholeBacktrace_handlesArrayInput_whenBacktrace $this->assertEquals($expected, $wholeTrace); } - public function test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionBacktraces() + public function testGetMessageAndWholeBacktraceShouldCombineCausedByExceptionBacktraces() { $ex1 = new \Exception('caused by 2'); $ex2 = new \Exception('caused by 1', 0, $ex1); @@ -276,7 +267,7 @@ public function test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionB $expected = <<test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionBacktraces() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktraceShouldCombineCausedByExceptionBacktraces() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest)) @@ -289,7 +280,7 @@ public function test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionB #10 /vendor/phpunit/phpunit/phpunit: PHPUnit\\TextUI\\Command::main() #11 {main}, caused by: caused by 1 -#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionBacktraces() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktraceShouldCombineCausedByExceptionBacktraces() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest)) @@ -302,7 +293,7 @@ public function test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionB #10 /vendor/phpunit/phpunit/phpunit: PHPUnit\\TextUI\\Command::main() #11 {main}, caused by: caused by 2 -#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->test_getMessageAndWholeBacktrace_shouldCombineCausedByExceptionBacktraces() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktraceShouldCombineCausedByExceptionBacktraces() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest)) diff --git a/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php index dc6ba75cffa..403dc856e2c 100644 --- a/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php +++ b/plugins/Monolog/tests/Unit/Processor/RequestIdProcessorTest.php @@ -31,10 +31,7 @@ public function tearDown(): void Common::$isCliMode = true; } - /** - * @test - */ - public function it_should_append_request_id_to_extra() + public function testItShouldAppendRequestIdToExtra() { $processor = new RequestIdProcessor(); @@ -45,10 +42,7 @@ public function it_should_append_request_id_to_extra() $this->assertNotEmpty($result['extra']['request_id']); } - /** - * @test - */ - public function request_id_should_stay_the_same() + public function testRequestIdShouldStayTheSame() { $processor = new RequestIdProcessor(); diff --git a/plugins/Monolog/tests/Unit/Processor/SprintfProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/SprintfProcessorTest.php index 5df5619303c..be35890c9bf 100644 --- a/plugins/Monolog/tests/Unit/Processor/SprintfProcessorTest.php +++ b/plugins/Monolog/tests/Unit/Processor/SprintfProcessorTest.php @@ -17,10 +17,7 @@ */ class SprintfProcessorTest extends \PHPUnit\Framework\TestCase { - /** - * @test - */ - public function it_should_replace_placeholders() + public function testItShouldReplacePlaceholders() { $result = $this->process(array( 'message' => 'Test %s and %s.', @@ -30,10 +27,7 @@ public function it_should_replace_placeholders() $this->assertEquals('Test here and there.', $result['message']); } - /** - * @test - */ - public function it_should_ignore_strings_without_placeholders() + public function testItShouldIgnoreStringsWithoutPlaceholders() { $result = $this->process(array( 'message' => 'Hello world!', @@ -43,10 +37,7 @@ public function it_should_ignore_strings_without_placeholders() $this->assertEquals('Hello world!', $result['message']); } - /** - * @test - */ - public function it_should_serialize_arrays() + public function testItShouldSerializeArrays() { $result = $this->process(array( 'message' => 'Error in the following modules: %s', diff --git a/plugins/Monolog/tests/Unit/Processor/TokenProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/TokenProcessorTest.php index b69cd36ccaf..df72cc66f27 100644 --- a/plugins/Monolog/tests/Unit/Processor/TokenProcessorTest.php +++ b/plugins/Monolog/tests/Unit/Processor/TokenProcessorTest.php @@ -17,10 +17,7 @@ */ class TokenProcessorTest extends \PHPUnit\Framework\TestCase { - /** - * @test - */ - public function it_should_remove_token() + public function testItShouldRemoveToken() { $result = $this->process(array( 'message' => '&token_auth=9b1cefc915ff6180071fb7dcd13ec5a4&trigger=archivephp', @@ -32,7 +29,7 @@ public function it_should_remove_token() /** * @test */ - public function it_should_remove_multiple_tokens() + public function testItShouldRemoveMultipleTokens() { $result = $this->process(array( 'message' => 'First token_auth=9b1cefc915ff6180071fb7dcd13ec5a4 and second token_auth=abec834efc915ff61801fb7dcd13ec', @@ -41,10 +38,7 @@ public function it_should_remove_multiple_tokens() $this->assertEquals('First token_auth=removed and second token_auth=removed', $result['message']); } - /** - * @test - */ - public function it_should_not_affect_other_strings() + public function testItShouldNotAffectOtherStrings() { $result = $this->process(array( 'message' => 'Please check your token_auth.', From 725045a27e721451b3615f2f8db750f49800cbbf Mon Sep 17 00:00:00 2001 From: Stefan Giehl Date: Wed, 24 Apr 2024 16:24:44 +0200 Subject: [PATCH 2/2] Update plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php Co-authored-by: Michal Kleiner --- .../tests/Unit/Processor/ExceptionToTextProcessorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php b/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php index aabd03fe11d..0122122383b 100644 --- a/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php +++ b/plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php @@ -174,7 +174,7 @@ public function testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKPRINTERRORB $expected = <<testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKPRINTERRORBACKTRACEisDefined() +#0 /vendor/phpunit/phpunit/src/Framework/TestCase.php: Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest->testGetMessageAndWholeBacktracePrintsBacktraceIfPIWIKPRINTERRORBACKTRACEIsDefined() #1 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestCase->runTest() #2 /vendor/phpunit/phpunit/src/Framework/TestResult.php: PHPUnit\\Framework\\TestCase->runBare() #3 /vendor/phpunit/phpunit/src/Framework/TestCase.php: PHPUnit\\Framework\\TestResult->run(Object(Piwik\\Plugins\\Monolog\\tests\\Unit\\Processor\\ExceptionToTextProcessorTest))