Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Coding Style] Use camel case for method names in more core plugin tests #22157

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions plugins/Insights/tests/Integration/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));

Expand All @@ -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'));

Expand All @@ -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));

Expand All @@ -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));

Expand All @@ -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'));

Expand All @@ -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'));

Expand All @@ -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));

Expand All @@ -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'));

Expand All @@ -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'));

Expand All @@ -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'));

Expand All @@ -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'));
Expand Down
26 changes: 13 additions & 13 deletions plugins/Insights/tests/Integration/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -53,15 +53,15 @@ 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');

$this->assertEquals('Actions', $report['module']);
$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);
Expand All @@ -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);
Expand All @@ -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');

Expand All @@ -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'));
Expand All @@ -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);
Expand All @@ -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);
Expand Down
32 changes: 16 additions & 16 deletions plugins/Insights/tests/Unit/InsightReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -162,7 +162,7 @@ public function provideLimitTestData()
);
}

public function test_generateInsight_NoMovers()
public function testGenerateInsightNoMovers()
{
$report = $this->generateInsight(-1, 2, 2, 20, -20);

Expand All @@ -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);

Expand All @@ -189,7 +189,7 @@ public function provideMinImpactMoversTestData()
);
}

public function test_generateInsight_NoNew()
public function testGenerateInsightNoNew()
{
$report = $this->generateInsight(2, -1, 2, 17, -17);

Expand All @@ -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);

Expand All @@ -217,7 +217,7 @@ public function provideMinImpactNewTestData()
);
}

public function test_generateInsight_NoDisappeared()
public function testGenerateInsightNoDisappeared()
{
$report = $this->generateInsight(2, 2, -1, 17, -17);

Expand All @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Loading
Loading