From 2f8e62d6b64324099b44cbac69395fef0e53b13e Mon Sep 17 00:00:00 2001
From: Maksim Spirkov <63721828+mspirkov@users.noreply.github.com>
Date: Mon, 27 Oct 2025 10:56:00 +0300
Subject: [PATCH] Fix codestyle in `tests` (#20638)
---
phpcs.xml.dist | 5 ----
tests/framework/base/ControllerTest.php | 7 +++++-
tests/framework/db/ActiveQueryTest.php | 24 +++++++++----------
tests/framework/db/ActiveRecordTest.php | 2 +-
.../framework/db/GetTablesAliasTestTrait.php | 20 ++++++++--------
tests/framework/di/InstanceTest.php | 8 +++----
tests/framework/grid/DataColumnTest.php | 10 ++++----
tests/framework/helpers/BaseConsoleTest.php | 8 +++----
tests/framework/helpers/HtmlTest.php | 16 ++++++-------
tests/framework/helpers/StringHelperTest.php | 12 +++++-----
.../validators/FileValidatorTest.php | 6 ++---
tests/framework/web/AssetBundleTest.php | 14 +++++------
12 files changed, 66 insertions(+), 66 deletions(-)
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 5ff7758c04..80d44a9e92 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -7,11 +7,6 @@
tests/*
-
-
- tests/*
-
-
tests/*
diff --git a/tests/framework/base/ControllerTest.php b/tests/framework/base/ControllerTest.php
index 0491239ec2..3c07a84763 100644
--- a/tests/framework/base/ControllerTest.php
+++ b/tests/framework/base/ControllerTest.php
@@ -110,7 +110,9 @@ class ControllerTest extends TestCase
}
}
-
+/**
+ * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
+ */
class TestController extends Controller
{
public function actionTest1()
@@ -138,6 +140,9 @@ class TestController extends Controller
}
}
+/**
+ * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
+ */
class Test1Controller extends Controller
{
public function actionTest_1()
diff --git a/tests/framework/db/ActiveQueryTest.php b/tests/framework/db/ActiveQueryTest.php
index e1d3814974..3baa552c7b 100644
--- a/tests/framework/db/ActiveQueryTest.php
+++ b/tests/framework/db/ActiveQueryTest.php
@@ -66,7 +66,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertInstanceOf('yii\db\Query', $result);
}
- public function testPopulate_EmptyRows(): void
+ public function testPopulateEmptyRows(): void
{
$query = new ActiveQuery(Customer::class);
$rows = [];
@@ -77,7 +77,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
/**
* @todo tests for internal logic of populate()
*/
- public function testPopulate_FilledRows(): void
+ public function testPopulateFilledRows(): void
{
$query = new ActiveQuery(Customer::class);
$rows = $query->all();
@@ -162,14 +162,14 @@ abstract class ActiveQueryTest extends DatabaseTestCase
/**
* @todo tests for the regex inside getQueryTableName
*/
- public function testGetQueryTableName_from_not_set(): void
+ public function testGetQueryTableNameFromNotSet(): void
{
$query = new ActiveQuery(Customer::class);
$result = $this->invokeMethod($query, 'getTableNameAndAlias');
$this->assertEquals(['customer', 'customer'], $result);
}
- public function testGetQueryTableName_from_set(): void
+ public function testGetQueryTableNameFromSet(): void
{
$options = ['from' => ['alias' => 'customer']];
$query = new ActiveQuery(Customer::class, $options);
@@ -187,7 +187,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertEquals($params, $result->params);
}
- public function testAndOnCondition_on_not_set(): void
+ public function testAndOnConditionOnNotSet(): void
{
$query = new ActiveQuery(Customer::class);
$on = ['active' => true];
@@ -197,7 +197,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertEquals($params, $result->params);
}
- public function testAndOnCondition_on_set(): void
+ public function testAndOnConditionOnSet(): void
{
$onOld = ['active' => true];
$query = new ActiveQuery(Customer::class);
@@ -210,7 +210,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertEquals($params, $result->params);
}
- public function testOrOnCondition_on_not_set(): void
+ public function testOrOnConditionOnNotSet(): void
{
$query = new ActiveQuery(Customer::class);
$on = ['active' => true];
@@ -220,7 +220,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertEquals($params, $result->params);
}
- public function testOrOnCondition_on_set(): void
+ public function testOrOnConditionOnSet(): void
{
$onOld = ['active' => true];
$query = new ActiveQuery(Customer::class);
@@ -244,7 +244,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertInstanceOf('yii\db\ActiveQuery', $result->via);
}
- public function testAlias_not_set(): void
+ public function testAliasNotSet(): void
{
$query = new ActiveQuery(Customer::class);
$result = $query->alias('alias');
@@ -252,7 +252,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
$this->assertEquals(['alias' => 'customer'], $result->from);
}
- public function testAlias_yet_set(): void
+ public function testAliasYetSet(): void
{
$aliasOld = ['old'];
$query = new ActiveQuery(Customer::class);
@@ -267,7 +267,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
return new ActiveQuery(null);
}
- public function testGetTableNames_notFilledFrom(): void
+ public function testGetTableNamesNotFilledFrom(): void
{
$query = new ActiveQuery(Profile::class);
@@ -278,7 +278,7 @@ abstract class ActiveQueryTest extends DatabaseTestCase
], $tables);
}
- public function testGetTableNames_wontFillFrom(): void
+ public function testGetTableNamesWontFillFrom(): void
{
$query = new ActiveQuery(Profile::class);
$this->assertEquals($query->from, null);
diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php
index 232b87a9fe..4427989a16 100644
--- a/tests/framework/db/ActiveRecordTest.php
+++ b/tests/framework/db/ActiveRecordTest.php
@@ -2064,7 +2064,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
$this->assertInstanceOf(Order::class, $orderItem->custom);
}
- public function testRefresh_querySetAlias_findRecord(): void
+ public function testRefreshQuerySetAliasFindRecord(): void
{
$customer = new CustomerWithAlias();
$customer->id = 1;
diff --git a/tests/framework/db/GetTablesAliasTestTrait.php b/tests/framework/db/GetTablesAliasTestTrait.php
index 831c97147e..33450c5337 100644
--- a/tests/framework/db/GetTablesAliasTestTrait.php
+++ b/tests/framework/db/GetTablesAliasTestTrait.php
@@ -20,7 +20,7 @@ trait GetTablesAliasTestTrait
*/
abstract protected function createQuery();
- public function testGetTableNames_isFromArrayWithAlias(): void
+ public function testGetTableNamesIsFromArrayWithAlias(): void
{
$query = $this->createQuery();
$query->from = [
@@ -40,7 +40,7 @@ trait GetTablesAliasTestTrait
], $tables);
}
- public function testGetTableNames_isFromArrayWithoutAlias(): void
+ public function testGetTableNamesIsFromArrayWithoutAlias(): void
{
$query = $this->createQuery();
$query->from = [
@@ -56,7 +56,7 @@ trait GetTablesAliasTestTrait
], $tables);
}
- public function testGetTableNames_isFromString(): void
+ public function testGetTableNamesIsFromString(): void
{
$query = $this->createQuery();
$query->from = 'profile AS \'prf\', user "usr", `order`, "customer", "a b" as "c d"';
@@ -72,7 +72,7 @@ trait GetTablesAliasTestTrait
], $tables);
}
- public function testGetTableNames_isFromObject_generateException(): void
+ public function testGetTableNamesIsFromObjectGenerateException(): void
{
$query = $this->createQuery();
$query->from = new stdClass();
@@ -82,7 +82,7 @@ trait GetTablesAliasTestTrait
$query->getTablesUsedInFrom();
}
- public function testGetTablesAlias_isFromString(): void
+ public function testGetTablesAliasIsFromString(): void
{
$query = $this->createQuery();
$query->from = 'profile AS \'prf\', user "usr", service srv, order, [a b] [c d], {{something}} AS myalias';
@@ -102,7 +102,7 @@ trait GetTablesAliasTestTrait
/**
* @see https://github.com/yiisoft/yii2/issues/14150
*/
- public function testGetTableNames_isFromPrefixedTableName(): void
+ public function testGetTableNamesIsFromPrefixedTableName(): void
{
$query = $this->createQuery();
$query->from = '{{%order_item}}';
@@ -117,7 +117,7 @@ trait GetTablesAliasTestTrait
/**
* @see https://github.com/yiisoft/yii2/issues/14211
*/
- public function testGetTableNames_isFromTableNameWithDatabase(): void
+ public function testGetTableNamesIsFromTableNameWithDatabase(): void
{
$query = $this->createQuery();
$query->from = 'tickets.workflows';
@@ -129,7 +129,7 @@ trait GetTablesAliasTestTrait
], $tables);
}
- public function testGetTableNames_isFromAliasedExpression(): void
+ public function testGetTableNamesIsFromAliasedExpression(): void
{
$query = $this->createQuery();
$expression = new Expression('(SELECT id FROM user)');
@@ -142,7 +142,7 @@ trait GetTablesAliasTestTrait
$this->assertEquals(['{{x}}' => $expression], $tables);
}
- public function testGetTableNames_isFromAliasedArrayWithExpression(): void
+ public function testGetTableNamesIsFromAliasedArrayWithExpression(): void
{
$query = $this->createQuery();
$query->from = ['x' => new Expression('(SELECT id FROM user)')];
@@ -154,7 +154,7 @@ trait GetTablesAliasTestTrait
], $tables);
}
- public function testGetTableNames_isFromAliasedSubquery(): void
+ public function testGetTableNamesIsFromAliasedSubquery(): void
{
$query = $this->createQuery();
$subQuery = $this->createQuery();
diff --git a/tests/framework/di/InstanceTest.php b/tests/framework/di/InstanceTest.php
index abc74fc298..1c311964d8 100644
--- a/tests/framework/di/InstanceTest.php
+++ b/tests/framework/di/InstanceTest.php
@@ -57,7 +57,7 @@ class InstanceTest extends TestCase
/**
* ensure an InvalidConfigException is thrown when a component does not exist.
*/
- public function testEnsure_NonExistingComponentException(): void
+ public function testEnsureNonExistingComponentException(): void
{
$container = new Container();
$this->expectException('yii\base\InvalidConfigException');
@@ -68,7 +68,7 @@ class InstanceTest extends TestCase
/**
* ensure an InvalidConfigException is thrown when a class does not exist.
*/
- public function testEnsure_NonExistingClassException(): void
+ public function testEnsureNonExistingClassException(): void
{
$container = new Container();
$this->expectException('yii\base\InvalidConfigException');
@@ -76,7 +76,7 @@ class InstanceTest extends TestCase
Instance::ensure('yii\cache\DoesNotExist', 'yii\cache\Cache', $container);
}
- public function testEnsure_WithoutType(): void
+ public function testEnsureWithoutType(): void
{
$container = new Container();
$container->set('db', [
@@ -89,7 +89,7 @@ class InstanceTest extends TestCase
$this->assertInstanceOf('\\yii\\db\\Connection', Instance::ensure(['class' => 'yii\db\Connection', 'dsn' => 'test'], null, $container));
}
- public function testEnsure_MinimalSettings(): void
+ public function testEnsureMinimalSettings(): void
{
Yii::$container->set('db', [
'class' => 'yii\db\Connection',
diff --git a/tests/framework/grid/DataColumnTest.php b/tests/framework/grid/DataColumnTest.php
index 1a0ee8c7b3..be25e574ab 100644
--- a/tests/framework/grid/DataColumnTest.php
+++ b/tests/framework/grid/DataColumnTest.php
@@ -29,7 +29,7 @@ class DataColumnTest extends TestCase
/**
* @see DataColumn::getHeaderCellLabel()
*/
- public function testColumnLabels_OnEmpty_ArrayProvider(): void
+ public function testColumnLabelsOnEmptyArrayProvider(): void
{
$this->mockApplication();
$grid = new GridView([
@@ -50,7 +50,7 @@ class DataColumnTest extends TestCase
/**
* @see DataColumn::getHeaderCellLabel()
*/
- public function testColumnLabels_OnEmpty_ArrayProvider_WithFilterModel(): void
+ public function testColumnLabelsOnEmptyArrayProviderWithFilterModel(): void
{
$this->mockApplication();
$grid = new GridView([
@@ -72,7 +72,7 @@ class DataColumnTest extends TestCase
* @see DataColumn::$filter
* @see DataColumn::renderFilterCellContent()
*/
- public function testFilterInput_String(): void
+ public function testFilterInputString(): void
{
$this->mockApplication();
$filterInput = '';
@@ -133,7 +133,7 @@ class DataColumnTest extends TestCase
* @see DataColumn::$filter
* @see DataColumn::renderFilterCellContent()
*/
- public function testFilterInput_Array(): void
+ public function testFilterInputArray(): void
{
$this->mockApplication([
'components' => [
@@ -184,7 +184,7 @@ HTML
* @see DataColumn::$filter
* @see DataColumn::renderFilterCellContent()
*/
- public function testFilterInput_FormatBoolean(): void
+ public function testFilterInputFormatBoolean(): void
{
$this->mockApplication([
'components' => [
diff --git a/tests/framework/helpers/BaseConsoleTest.php b/tests/framework/helpers/BaseConsoleTest.php
index 04d1a8ea15..6ad4fb720d 100644
--- a/tests/framework/helpers/BaseConsoleTest.php
+++ b/tests/framework/helpers/BaseConsoleTest.php
@@ -37,7 +37,7 @@ class BaseConsoleTest extends TestCase
/**
* @test
*/
- public function ansiColorizedSubstr_withoutColors(): void
+ public function ansiColorizedSubstrWithoutColors(): void
{
$str = 'FooBar';
@@ -56,13 +56,13 @@ class BaseConsoleTest extends TestCase
/**
* @test
- * @dataProvider ansiColorizedSubstr_withColors_data
+ * @dataProvider ansiColorizedSubstrWithColorsData
* @param $str
* @param $start
* @param $length
* @param $expected
*/
- public function ansiColorizedSubstr_withColors($str, $start, $length, $expected): void
+ public function ansiColorizedSubstrWithColors($str, $start, $length, $expected): void
{
$ansiStr = BaseConsole::renderColoredString($str);
@@ -71,7 +71,7 @@ class BaseConsoleTest extends TestCase
$this->assertEquals($ansiExpected, $ansiActual);
}
- public static function ansiColorizedSubstr_withColors_data(): array
+ public static function ansiColorizedSubstrWithColorsData(): array
{
return [
['%rFoo%gBar%n', 0, 3, '%rFoo%n'],
diff --git a/tests/framework/helpers/HtmlTest.php b/tests/framework/helpers/HtmlTest.php
index 3d7fe06bef..ba34ac7217 100644
--- a/tests/framework/helpers/HtmlTest.php
+++ b/tests/framework/helpers/HtmlTest.php
@@ -1612,10 +1612,10 @@ EOD;
}
/**
- * Data provider for [[testActiveInput_TypeText]].
+ * Data provider for [[testActiveInputTypeText]].
* @return array test data
*/
- public static function dataProviderActiveInput_TypeText(): array
+ public static function dataProviderActiveInputTypeText(): array
{
return [
[
@@ -1641,13 +1641,13 @@ EOD;
}
/**
- * @dataProvider dataProviderActiveInput_TypeText
+ * @dataProvider dataProviderActiveInputTypeText
*
* @param string $value
* @param array $options
* @param string $expectedHtml
*/
- public function testActiveInput_TypeText($value, array $options, $expectedHtml): void
+ public function testActiveInputTypeText($value, array $options, $expectedHtml): void
{
$model = new HtmlTestModel();
$model->name = $value;
@@ -2169,7 +2169,7 @@ HTML;
$this->assertEqualsWithoutLE($expected, $actual);
}
- public function testActiveCheckboxList_options(): void
+ public function testActiveCheckboxListOptions(): void
{
$model = new HtmlTestModel();
@@ -2180,7 +2180,7 @@ HTML;
$this->assertEqualsWithoutLE($expected, $actual);
}
- public function testActiveTextInput_placeholderFillFromModel(): void
+ public function testActiveTextInputPlaceholderFillFromModel(): void
{
$model = new HtmlTestModel();
@@ -2189,7 +2189,7 @@ HTML;
$this->assertStringContainsString('placeholder="Name"', $html);
}
- public function testActiveTextInput_customPlaceholder(): void
+ public function testActiveTextInputCustomPlaceholder(): void
{
$model = new HtmlTestModel();
@@ -2198,7 +2198,7 @@ HTML;
$this->assertStringContainsString('placeholder="Custom placeholder"', $html);
}
- public function testActiveTextInput_placeholderFillFromModelTabular(): void
+ public function testActiveTextInputPlaceholderFillFromModelTabular(): void
{
$model = new HtmlTestModel();
diff --git a/tests/framework/helpers/StringHelperTest.php b/tests/framework/helpers/StringHelperTest.php
index 2aad94a7b8..8ffdf43a07 100644
--- a/tests/framework/helpers/StringHelperTest.php
+++ b/tests/framework/helpers/StringHelperTest.php
@@ -404,7 +404,7 @@ class StringHelperTest extends TestCase
$this->assertSame($expectedResult, StringHelper::matchWildcard($pattern, $string, $options));
}
- public static function dataProviderMb_ucfirst(): array
+ public static function dataProviderMbUcfirst(): array
{
return [
['foo', 'Foo'],
@@ -419,14 +419,14 @@ class StringHelperTest extends TestCase
/**
* @param string $string
* @param string $expectedResult
- * @dataProvider dataProviderMb_ucfirst
+ * @dataProvider dataProviderMbUcfirst
*/
- public function testMb_ucfirst($string, $expectedResult): void
+ public function testMbUcfirst($string, $expectedResult): void
{
$this->assertSame($expectedResult, StringHelper::mb_ucfirst($string));
}
- public static function dataProviderMb_ucwords(): array
+ public static function dataProviderMbUcwords(): array
{
return [
['foo', 'Foo'],
@@ -448,9 +448,9 @@ class StringHelperTest extends TestCase
/**
* @param string $string
* @param string $expectedResult
- * @dataProvider dataProviderMb_ucwords
+ * @dataProvider dataProviderMbUcwords
*/
- public function testMb_ucwords($string, $expectedResult): void
+ public function testMbUcwords($string, $expectedResult): void
{
$this->assertSame($expectedResult, StringHelper::mb_ucwords($string));
}
diff --git a/tests/framework/validators/FileValidatorTest.php b/tests/framework/validators/FileValidatorTest.php
index c9753b0701..d5c647d749 100644
--- a/tests/framework/validators/FileValidatorTest.php
+++ b/tests/framework/validators/FileValidatorTest.php
@@ -228,7 +228,7 @@ class FileValidatorTest extends TestCase
$this->assertFalse($m->validate());
}
- public function testValidateAttribute_minFilesGreaterThanOneMaxFilesUnlimited_notError(): void
+ public function testValidateAttributeMinFilesGreaterThanOneMaxFilesUnlimitedNotError(): void
{
$validator = new FileValidator(['minFiles' => 2, 'maxFiles' => 0]);
$model = FakedValidationModel::createWithAttributes(
@@ -255,7 +255,7 @@ class FileValidatorTest extends TestCase
$this->assertFalse($model->hasErrors('attr_images'));
}
- public function testValidateAttribute_minFilesTwoMaxFilesFour_notError(): void
+ public function testValidateAttributeMinFilesTwoMaxFilesFourNotError(): void
{
$validator = new FileValidator(['minFiles' => 2, 'maxFiles' => 4]);
$model = FakedValidationModel::createWithAttributes(
@@ -282,7 +282,7 @@ class FileValidatorTest extends TestCase
$this->assertFalse($model->hasErrors('attr_images'));
}
- public function testValidateAttribute_minFilesTwoMaxFilesUnlimited_hasError(): void
+ public function testValidateAttributeMinFilesTwoMaxFilesUnlimitedHasError(): void
{
$validator = new FileValidator(['minFiles' => 2, 'maxFiles' => 0]);
$model = FakedValidationModel::createWithAttributes(
diff --git a/tests/framework/web/AssetBundleTest.php b/tests/framework/web/AssetBundleTest.php
index f1e4bad481..3f9753e4fd 100644
--- a/tests/framework/web/AssetBundleTest.php
+++ b/tests/framework/web/AssetBundleTest.php
@@ -80,11 +80,11 @@ class AssetBundleTest extends TestCase
$bundle->publish($am);
$this->assertTrue(is_dir($bundle->basePath));
- $this->sourcesPublish_VerifyFiles('css', $bundle);
- $this->sourcesPublish_VerifyFiles('js', $bundle);
+ $this->sourcesPublishVerifyFiles('css', $bundle);
+ $this->sourcesPublishVerifyFiles('js', $bundle);
}
- private function sourcesPublish_VerifyFiles($type, $bundle): void
+ private function sourcesPublishVerifyFiles($type, $bundle): void
{
foreach ($bundle->$type as $filename) {
$publishedFile = $bundle->basePath . DIRECTORY_SEPARATOR . $filename;
@@ -101,7 +101,7 @@ class AssetBundleTest extends TestCase
$this->verifySourcesPublishedBySymlink($view);
}
- public function testSourcesPublishedBySymlink_Issue9333(): void
+ public function testSourcesPublishedBySymlinkIssue9333(): void
{
$view = $this->getView([
'linkAssets' => true,
@@ -113,7 +113,7 @@ class AssetBundleTest extends TestCase
$this->assertTrue(is_dir(dirname($bundle->basePath)));
}
- public function testSourcesPublish_AssetManagerBeforeCopy(): void
+ public function testSourcesPublishAssetManagerBeforeCopy(): void
{
$view = $this->getView([
'beforeCopy' => function ($from, $to) {
@@ -132,7 +132,7 @@ class AssetBundleTest extends TestCase
}
}
- public function testSourcesPublish_AssetBeforeCopy(): void
+ public function testSourcesPublishAssetBeforeCopy(): void
{
$view = $this->getView();
$am = $view->assetManager;
@@ -152,7 +152,7 @@ class AssetBundleTest extends TestCase
}
}
- public function testSourcesPublish_publishOptions_Only(): void
+ public function testSourcesPublishPublishOptionsOnly(): void
{
$view = $this->getView();
$am = $view->assetManager;