Fix codestyle in tests (#20638)

This commit is contained in:
Maksim Spirkov
2025-10-27 10:56:00 +03:00
committed by GitHub
parent fa9a2b6e6d
commit 2f8e62d6b6
12 changed files with 66 additions and 66 deletions

View File

@@ -7,11 +7,6 @@
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!-- TODO: fix errors -->
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<!-- TODO: fix errors -->
<rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
<exclude-pattern>tests/*</exclude-pattern>

View File

@@ -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()

View File

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

View File

@@ -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;

View File

@@ -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();

View File

@@ -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',

View File

@@ -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 = '<input type="text"/>';
@@ -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' => [

View File

@@ -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'],

View File

@@ -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();

View File

@@ -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));
}

View File

@@ -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(

View File

@@ -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;