Skip to content

Commit

Permalink
[Coding Style] Enable rule PSR1.Methods.CamelCapsMethodName.NotCamelC…
Browse files Browse the repository at this point in the history
…aps (#22144)

* [Coding Style] Enable rule PSR1.Methods.CamelCapsMethodName.NotCamelCaps

* [Coding Style] Use camel case for method names in API plugin tests (#22145)

* [Coding Style] Use camel case for method names in Core* plugin tests (#22147)

* [Coding Style] Use camel case for method names in core Unit tests (#22149)

* [Coding Style] Use camel case for method names in Actions and BulkTracking plugin tests (#22146)

* [Coding Style] Use camel case for method names in CustomDimensions and CustomJSTracker plugin tests (#22148)

* [Coding Style] Use camel case for method names in core Integration tests (#22151)

* [Coding Style] Use camel case for method names in more core plugin tests (#22153)

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

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

* Update plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php

Co-authored-by: Michal Kleiner <[email protected]>

---------

Co-authored-by: Michal Kleiner <[email protected]>

* [Coding Style] Use camel case for method names in more core plugin tests (#22159)

* [Coding Style] Use camel case for method names in remaining tests (#22160)

* [Coding Style] Use camel case for method names in remaining tests

* rename expected test files

---------

Co-authored-by: Michal Kleiner <[email protected]>
  • Loading branch information
sgiehl and michalkleiner authored Apr 25, 2024
1 parent 884eb59 commit d6d72d1
Show file tree
Hide file tree
Showing 464 changed files with 3,428 additions and 3,508 deletions.
6 changes: 0 additions & 6 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
<exclude-pattern>plugins/*/Updates/*</exclude-pattern>
</rule>

<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<!-- Allow using method name without camel caps in tests as long as some methods are named test_* -->
<exclude-pattern>tests/PHPUnit/*</exclude-pattern>
<exclude-pattern>plugins/*/tests/*</exclude-pattern>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<!-- Allow using multiple classes in one file for tests -->
<exclude-pattern>tests/PHPUnit/*</exclude-pattern>
Expand Down
2 changes: 1 addition & 1 deletion plugins/API/tests/Integration/APITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function tearDown(): void
parent::tearDown();
}

public function test_getBulkRequest_IsAbleToHandleManyDifferentRequests()
public function testGetBulkRequestIsAbleToHandleManyDifferentRequests()
{
$token = Fixture::getTokenAuth();
$urls = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected static function beforeTableDataCached()
API::getInstance()->add('test segment', self::TEST_SEGMENT);
}

public function test_compareTables_shouldCompareTwoDataTablesCorrectly()
public function testCompareTablesShouldCompareTwoDataTablesCorrectly()
{
$table1 = $this->makeTable([
['label' => 'row1', 'nb_visits' => 5, 'nb_actions' => 10],
Expand Down Expand Up @@ -116,7 +116,7 @@ public function test_compareTables_shouldCompareTwoDataTablesCorrectly()
$this->assertEquals($expectedXml, $xmlContent);
}

public function test_compareTables_shouldUseFirstTableRowsForComparisons()
public function testCompareTablesShouldUseFirstTableRowsForComparisons()
{
$table1 = $this->makeTable([
['label' => 'row1', 'nb_visits' => 10, 'nb_actions' => 5],
Expand Down Expand Up @@ -177,7 +177,7 @@ public function test_compareTables_shouldUseFirstTableRowsForComparisons()
$this->assertEquals($expectedXml, $xmlContent);
}

public function test_compareTables_shouldCompareTwoDataTableMapsCorrectly()
public function testCompareTablesShouldCompareTwoDataTableMapsCorrectly()
{
$tableSet1 = $this->makeTableMap([
'2012-01-01' => [
Expand Down Expand Up @@ -324,7 +324,7 @@ public function test_compareTables_shouldCompareTwoDataTableMapsCorrectly()
$this->assertEquals($expectedXml, $xmlContent);
}

public function test_compareTables_shouldCompareTwoDataTaleMapsOfDifferentLengthsCorrectly_whenFirstIsLonger()
public function testCompareTablesShouldCompareTwoDataTaleMapsOfDifferentLengthsCorrectlyWhenFirstIsLonger()
{
$tableSet1 = $this->makeTableMap([
'2012-01-01' => [
Expand Down Expand Up @@ -465,7 +465,7 @@ public function test_compareTables_shouldCompareTwoDataTaleMapsOfDifferentLength
$this->assertEquals($expectedXml, $xmlContent);
}

public function test_compareTables_shouldCompareTwoDataTaleMapsOfDifferentLengthsCorrectly_whenFirstIsShorter()
public function testCompareTablesShouldCompareTwoDataTaleMapsOfDifferentLengthsCorrectlyWhenFirstIsShorter()
{
$tableSet1 = $this->makeTableMap([
'2012-01-01' => [
Expand Down
4 changes: 2 additions & 2 deletions plugins/API/tests/Integration/RowEvolutionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public function setUp(): void
Fixture::createWebsite('2014-01-01 00:00:00');
}

public function test_getRowEvolution_shouldTriggerAnException_IfReportHasNoDimension()
public function testGetRowEvolutionShouldTriggerAnExceptionIfReportHasNoDimension()
{
$this->expectException(\Exception::class);
$this->expectDeprecationMessage("Reports like VisitsSummary.get which do not have a dimension are not supported by row evolution");
$rowEvolution = new RowEvolution();
$rowEvolution->getRowEvolution(1, 'day', 'last7', 'VisitsSummary', 'get');
}

public function test_getRowEvolution_shouldNotTriggerAnException_IfReportHasADimension()
public function testGetRowEvolutionShouldNotTriggerAnExceptionIfReportHasADimension()
{
$rowEvolution = new RowEvolution();
$table = $rowEvolution->getRowEvolution(1, 'day', 'last7', 'Actions', 'getPageUrls');
Expand Down
26 changes: 13 additions & 13 deletions plugins/API/tests/Integration/RssRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,56 +37,56 @@ public function setUp(): void
$this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll', 'idSite' => $idSite));
}

public function test_renderSuccess_shouldIncludeMessage()
public function testRenderSuccessShouldIncludeMessage()
{
$response = $this->builder->renderSuccess('ok');

$this->assertEquals('Success:ok', $response);
}

public function test_renderException_shouldIncludeTheMessageAndNotExceptionMessage()
public function testRenderExceptionShouldIncludeTheMessageAndNotExceptionMessage()
{
$response = $this->builder->renderException("The error message", new \Exception('The other message'));

$this->assertEquals('Error: The error message', $response);
}

public function test_renderObject_shouldReturAnError()
public function testRenderObjectShouldReturAnError()
{
$response = $this->builder->renderObject(new \stdClass());

$this->assertEquals('Error: The API cannot handle this data structure.', $response);
}

public function test_renderResource_shouldReturAnError()
public function testRenderResourceShouldReturAnError()
{
$response = $this->builder->renderResource(new \stdClass());

$this->assertEquals('Error: The API cannot handle this data structure.', $response);
}

public function test_renderScalar_shouldFailForBooleanScalar()
public function testRenderScalarShouldFailForBooleanScalar()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$this->builder->renderScalar(true);
}

public function test_renderScalar_shouldFailForIntegerScalar()
public function testRenderScalarShouldFailForIntegerScalar()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$this->builder->renderScalar(5);
}

public function test_renderScalar_shouldFailForStringScalar()
public function testRenderScalarShouldFailForStringScalar()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
$this->builder->renderScalar('string');
}

public function test_renderDataTable_shouldFailForDataTable()
public function testRenderDataTableShouldFailForDataTable()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
Expand All @@ -96,7 +96,7 @@ public function test_renderDataTable_shouldFailForDataTable()
$this->builder->renderDataTable($dataTable);
}

public function test_renderDataTable_shouldFailForSubtables()
public function testRenderDataTableShouldFailForSubtables()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
Expand All @@ -111,7 +111,7 @@ public function test_renderDataTable_shouldFailForSubtables()
$this->builder->renderDataTable($dataTable);
}

public function test_renderDataTable_shouldFail_IfKeynameIsNotDate()
public function testRenderDataTableShouldFailIfKeynameIsNotDate()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
Expand All @@ -127,7 +127,7 @@ public function test_renderDataTable_shouldFail_IfKeynameIsNotDate()
$this->builder->renderDataTable($map);
}

public function test_renderDataTable_shouldRenderDataTableMaps_IfKeynameIsDate()
public function testRenderDataTableShouldRenderDataTableMapsIfKeynameIsDate()
{
$map = new DataTable\Map();
$map->setKeyName('date');
Expand All @@ -153,7 +153,7 @@ public function test_renderDataTable_shouldRenderDataTableMaps_IfKeynameIsDate()
</rss>', $response);
}

public function test_renderDataTable_shouldFailForSimpleDataTable()
public function testRenderDataTableShouldFailForSimpleDataTable()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
Expand All @@ -164,7 +164,7 @@ public function test_renderDataTable_shouldFailForSimpleDataTable()
$this->builder->renderDataTable($dataTable);
}

public function test_renderArray_ShouldFailForArrays()
public function testRenderArrayShouldFailForArrays()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('RSS feeds can be generated for one specific website');
Expand Down
4 changes: 2 additions & 2 deletions plugins/API/tests/System/GetSegmentsMetadataAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class GetSegmentsMetadataAPITest extends SystemTestCase
{
public function test_it_contains_visitid_by_default()
public function testItContainsVisitidByDefault()
{
$request = new Request(
'method=API.getSegmentsMetadata'
Expand All @@ -41,7 +41,7 @@ public function test_it_contains_visitid_by_default()
$this->assertTrue($contains);
}

public function test_it_does_not_contain_visitid_if_profile_disabled()
public function testItDoesNotContainVisitidIfProfileDisabled()
{
Cache::flushAll();

Expand Down
18 changes: 9 additions & 9 deletions plugins/API/tests/Unit/ConsoleRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ public function setUp(): void
DataTable\Manager::getInstance()->deleteAll();
}

public function test_renderSuccess_shouldAlwaysReturnTrueAndIgnoreMessage()
public function testRenderSuccessShouldAlwaysReturnTrueAndIgnoreMessage()
{
$response = $this->builder->renderSuccess('ok');

$this->assertEquals('Success:ok', $response);
}

public function test_renderException_shouldThrowTheException()
public function testRenderExceptionShouldThrowTheException()
{
$response = $this->builder->renderException('This message should be used', new \BadMethodCallException('The other message'));

$this->assertEquals('Error: This message should be used', $response);
}

public function test_renderScalar_shouldReturnTheSameValue()
public function testRenderScalarShouldReturnTheSameValue()
{
$response = $this->builder->renderScalar(true);
$this->assertSame("- 1 ['0' => 1] [] [idsubtable = ]<br />
Expand All @@ -60,21 +60,21 @@ public function test_renderScalar_shouldReturnTheSameValue()
", $response);
}

public function test_renderObject_shouldReturAnError()
public function testRenderObjectShouldReturAnError()
{
$response = $this->builder->renderObject(new \stdClass());

$this->assertEquals('Error: The API cannot handle this data structure.', $response);
}

public function test_renderResource_shouldReturAnError()
public function testRenderResourceShouldReturAnError()
{
$response = $this->builder->renderResource(new \stdClass());

$this->assertEquals('Error: The API cannot handle this data structure.', $response);
}

public function test_renderDataTable_shouldReturnResult()
public function testRenderDataTableShouldReturnResult()
{
$dataTable = new DataTable();
$dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
Expand All @@ -85,7 +85,7 @@ public function test_renderDataTable_shouldReturnResult()
", $response);
}

public function test_renderDataTableWithObjects_shouldReturnResult()
public function testRenderDataTableWithObjectsShouldReturnResult()
{
$dataTable = new DataTable();
$dataTable->addRowFromSimpleArray(array('nb_visits' => 5, 'nb_random' => 10));
Expand All @@ -101,7 +101,7 @@ public function test_renderDataTableWithObjects_shouldReturnResult()
<hr />Metadata<br /><br /> <b>processedRows</b><br />0 => Object [Piwik\Plugins\CoreHome\Columns\Metrics\AverageTimeOnSite]1 => Object [stdClass]2 => 2016-01-01", $response);
}

public function test_renderArray_ShouldReturnConsoleResult()
public function testRenderArrayShouldReturnConsoleResult()
{
$input = array(1, 2, 5, 'string', 10);

Expand All @@ -115,7 +115,7 @@ public function test_renderArray_ShouldReturnConsoleResult()
", $response);
}

public function test_renderArray_ShouldConvertMultiDimensionalAssociativeArrayToJson()
public function testRenderArrayShouldConvertMultiDimensionalAssociativeArrayToJson()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Data structure returned is not convertible in the requested format');
Expand Down
Loading

0 comments on commit d6d72d1

Please sign in to comment.