mirror of
https://github.com/yiisoft/yii2.git
synced 2025-12-18 05:32:29 +08:00
Make test data providers static and declare array return types. (#20621)
This commit is contained in:
@@ -18,7 +18,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ChangeLogTest extends TestCase
|
||||
{
|
||||
public function changeProvider()
|
||||
public static function changeProvider(): array
|
||||
{
|
||||
$lines = preg_split('~\R~', file_get_contents(__DIR__ . '/../../framework/CHANGELOG.md'), -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class ActionFilterTest extends TestCase
|
||||
$this->assertEquals([1, 3, 2], $controller->result);
|
||||
}
|
||||
|
||||
public function actionFilterProvider()
|
||||
public static function actionFilterProvider(): array
|
||||
{
|
||||
return [
|
||||
[['class' => 'yii\filters\AccessControl', 'user' => 'yiiunit\framework\base\MockUser']],
|
||||
|
||||
@@ -68,7 +68,7 @@ class ControllerTest extends TestCase
|
||||
$this->assertEquals($expectedActionMethod, $actionMethod);
|
||||
}
|
||||
|
||||
public function createInlineActionProvider()
|
||||
public static function createInlineActionProvider(): array
|
||||
{
|
||||
return [
|
||||
['\yiiunit\framework\base\TestController', 'non-existent-id', null],
|
||||
@@ -91,7 +91,7 @@ class ControllerTest extends TestCase
|
||||
$this->assertSame($expected, preg_match('/^(?:[a-z0-9_]+-)*[a-z0-9_]+$/', $input));
|
||||
}
|
||||
|
||||
public function actionIdMethodProvider()
|
||||
public static function actionIdMethodProvider(): array
|
||||
{
|
||||
return [
|
||||
['apple-id', 1],
|
||||
|
||||
@@ -182,7 +182,7 @@ TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderEncryptByKeyCompat()
|
||||
public static function dataProviderEncryptByKeyCompat(): array
|
||||
{
|
||||
// these ciphertexts generated using Yii 2.0.2 which is based on mcrypt.
|
||||
$mcrypt = [
|
||||
@@ -493,7 +493,7 @@ TEXT;
|
||||
$this->assertEquals($data, $this->security->decryptByKey($encrypted, $key));
|
||||
}
|
||||
|
||||
public function dataProviderEncryptByPasswordCompat()
|
||||
public static function dataProviderEncryptByPasswordCompat(): array
|
||||
{
|
||||
// these ciphertexts generated using Yii 2.0.2 which is based on mcrypt.
|
||||
$mcrypt = [
|
||||
@@ -803,7 +803,7 @@ TEXT;
|
||||
$this->assertEquals($data, $this->security->decryptByPassword($encrypted, $password));
|
||||
}
|
||||
|
||||
public function randomKeyInvalidInputs()
|
||||
public static function randomKeyInvalidInputs(): array
|
||||
{
|
||||
return [
|
||||
[0],
|
||||
@@ -873,7 +873,7 @@ TEXT;
|
||||
$this->assertEquals(1, preg_match('/[A-Za-z0-9_-]+/', $key));
|
||||
}
|
||||
|
||||
public function dataProviderPbkdf2()
|
||||
public static function dataProviderPbkdf2(): array
|
||||
{
|
||||
return array_filter([
|
||||
[
|
||||
@@ -968,7 +968,7 @@ TEXT;
|
||||
$this->assertEquals($okm, bin2hex($DK));
|
||||
}
|
||||
|
||||
public function dataProviderDeriveKey()
|
||||
public static function dataProviderDeriveKey(): array
|
||||
{
|
||||
// See Appendix A in https://tools.ietf.org/html/rfc5869
|
||||
return [
|
||||
@@ -1061,7 +1061,7 @@ TEXT;
|
||||
$this->assertEquals($okm, bin2hex($dk));
|
||||
}
|
||||
|
||||
public function dataProviderCompareStrings()
|
||||
public static function dataProviderCompareStrings(): array
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
@@ -1120,7 +1120,7 @@ TEXT;
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function maskProvider()
|
||||
public static function maskProvider(): array
|
||||
{
|
||||
return [
|
||||
['1'],
|
||||
|
||||
@@ -66,7 +66,7 @@ class AttributeBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function preserveNonEmptyValuesDataProvider()
|
||||
public static function preserveNonEmptyValuesDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -66,7 +66,7 @@ class AttributesBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function preserveNonEmptyValuesDataProvider()
|
||||
public static function preserveNonEmptyValuesDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -121,7 +121,7 @@ class AttributesBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function orderProvider()
|
||||
public static function orderProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -130,7 +130,7 @@ class TimestampBehaviorTest extends TestCase
|
||||
$model->save(false);
|
||||
}
|
||||
|
||||
public function expressionProvider()
|
||||
public static function expressionProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -142,7 +142,7 @@ class TimestampBehaviorTest extends TestCase
|
||||
[new Expression("strftime('%Y')"), date('Y')],
|
||||
['2015-10-20', '2015-10-20'],
|
||||
[time(), time()],
|
||||
[[$this, 'arrayCallable'], '2015-10-20'],
|
||||
[[null, 'arrayCallable'], '2015-10-20'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -153,6 +153,10 @@ class TimestampBehaviorTest extends TestCase
|
||||
*/
|
||||
public function testNewRecordExpression($expression, $expected): void
|
||||
{
|
||||
if (is_array($expression)) {
|
||||
$expression[0] ??= $this;
|
||||
}
|
||||
|
||||
ActiveRecordTimestamp::$tableName = 'test_auto_timestamp_string';
|
||||
ActiveRecordTimestamp::$behaviors = [
|
||||
'timestamp' => [
|
||||
|
||||
@@ -107,7 +107,7 @@ abstract class CacheTestCase extends TestCase
|
||||
/**
|
||||
* @return array testing multiSet with and without expiry
|
||||
*/
|
||||
public function multiSetExpiry()
|
||||
public static function multiSetExpiry(): array
|
||||
{
|
||||
return [[0], [2]];
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class RequestTest extends TestCase
|
||||
{
|
||||
public function provider()
|
||||
public static function provider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -32,7 +32,7 @@ class UnknownCommandExceptionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function suggestedCommandsProvider()
|
||||
public static function suggestedCommandsProvider(): array
|
||||
{
|
||||
return [
|
||||
['migate', ['migrate']],
|
||||
|
||||
@@ -466,7 +466,7 @@ EOL;
|
||||
* Data provider for [[testAdjustCssUrl()]].
|
||||
* @return array test data.
|
||||
*/
|
||||
public function adjustCssUrlDataProvider()
|
||||
public static function adjustCssUrlDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -585,7 +585,7 @@ EOL;
|
||||
* Data provider for [[testFindRealPath()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function findRealPathDataProvider()
|
||||
public static function findRealPathDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -159,7 +159,7 @@ class MigrateControllerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function generateMigrationDataProvider()
|
||||
public static function generateMigrationDataProvider(): array
|
||||
{
|
||||
$params = [
|
||||
'create_fields' => [
|
||||
@@ -359,7 +359,7 @@ class MigrateControllerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function generateJunctionMigrationDataProvider()
|
||||
public static function generateJunctionMigrationDataProvider(): array
|
||||
{
|
||||
return [
|
||||
['create_junction_post_and_tag_tables', 'post_tag', 'post', 'tag'],
|
||||
@@ -487,7 +487,7 @@ class MigrateControllerTest extends TestCase
|
||||
$this->assertStringContainsString('No new migrations found. Your system is up-to-date.', $result);
|
||||
}
|
||||
|
||||
public function refreshMigrationDataProvider()
|
||||
public static function refreshMigrationDataProvider(): array
|
||||
{
|
||||
return [
|
||||
['default'],
|
||||
|
||||
@@ -124,7 +124,7 @@ class PHPMessageControllerTest extends BaseMessageControllerTest
|
||||
$this->assertEqualsWithoutLE($expected, $head);
|
||||
}
|
||||
|
||||
public function messageFileCategoriesDataProvider()
|
||||
public static function messageFileCategoriesDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'removeUnused:false - unused category should not be removed - normal category' => ['test_delete_category', true, false, true],
|
||||
|
||||
@@ -23,7 +23,7 @@ class TableTest extends TestCase
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
public function getTableData()
|
||||
public static function getTableData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -69,7 +69,7 @@ EXPECTED;
|
||||
$this->assertEqualsWithoutLE($expected, $tableContent);
|
||||
}
|
||||
|
||||
public function getMultiLineTableData()
|
||||
public static function getMultiLineTableData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -138,7 +138,7 @@ EXPECTED;
|
||||
$this->assertEqualsWithoutLE($expected, $tableContent);
|
||||
}
|
||||
|
||||
public function getNumericTableData()
|
||||
public static function getNumericTableData(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -658,7 +658,7 @@ EXPECTED;
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function dataMinimumWidth()
|
||||
public static function dataMinimumWidth(): array
|
||||
{
|
||||
return [
|
||||
['X'],
|
||||
|
||||
@@ -23,7 +23,7 @@ class ActiveDataFilterTest extends TestCase
|
||||
|
||||
// Tests :
|
||||
|
||||
public function dataProviderBuild()
|
||||
public static function dataProviderBuild(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -87,7 +87,7 @@ class DataFilterTest extends TestCase
|
||||
* Data provider for [[testValidate()]].
|
||||
* @return array test data.
|
||||
*/
|
||||
public function dataProviderValidate()
|
||||
public static function dataProviderValidate(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -295,7 +295,7 @@ class DataFilterTest extends TestCase
|
||||
* Data provider for [[testNormalize()]].
|
||||
* @return array test data.
|
||||
*/
|
||||
public function dataProviderNormalize()
|
||||
public static function dataProviderNormalize(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -33,7 +33,7 @@ class PaginationTest extends TestCase
|
||||
* Data provider for [[testCreateUrl()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderCreateUrl()
|
||||
public static function dataProviderCreateUrl(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -116,7 +116,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals(999, $pagination->getPage());
|
||||
}
|
||||
|
||||
public function dataProviderPageCount()
|
||||
public static function dataProviderPageCount(): array
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
@@ -153,7 +153,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals(0, (new Pagination())->getPage());
|
||||
}
|
||||
|
||||
public function dataProviderSetPage()
|
||||
public static function dataProviderSetPage(): array
|
||||
{
|
||||
return [
|
||||
[null, false, 0, null],
|
||||
@@ -188,7 +188,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($page, $pagination->getPage());
|
||||
}
|
||||
|
||||
public function dataProviderGetPageSize()
|
||||
public static function dataProviderGetPageSize(): array
|
||||
{
|
||||
return [
|
||||
[[1, 50], 20],
|
||||
@@ -215,7 +215,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($pageSize, $pagination->getPageSize());
|
||||
}
|
||||
|
||||
public function dataProviderSetPageSize()
|
||||
public static function dataProviderSetPageSize(): array
|
||||
{
|
||||
return [
|
||||
[null, false, false, 20],
|
||||
@@ -250,7 +250,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($pageSize, $pagination->getPageSize());
|
||||
}
|
||||
|
||||
public function dataProviderGetOffset()
|
||||
public static function dataProviderGetOffset(): array
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
@@ -277,7 +277,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($offset, $pagination->getOffset());
|
||||
}
|
||||
|
||||
public function dataProviderGetLimit()
|
||||
public static function dataProviderGetLimit(): array
|
||||
{
|
||||
return [
|
||||
[0, -1],
|
||||
@@ -300,7 +300,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($limit, $pagination->getLimit());
|
||||
}
|
||||
|
||||
public function dataProviderGetLinks()
|
||||
public static function dataProviderGetLinks(): array
|
||||
{
|
||||
return [
|
||||
[0, 0, 0, '/index.php?r=list&page=1&per-page=0', null, null, null, null],
|
||||
|
||||
@@ -209,7 +209,7 @@ class SortTest extends TestCase
|
||||
$this->assertEquals('/index.php?r=site%2Findex&sort=age', $sort->createUrl('name'));
|
||||
}
|
||||
|
||||
public function providerForLinkWithParams()
|
||||
public static function providerForLinkWithParams(): array
|
||||
{
|
||||
return [
|
||||
[true, null, '<a class="asc" href="/index.php?r=site%2Findex&sort=-age%2C-name" data-sort="-age,-name">Age</a>'],
|
||||
@@ -251,7 +251,7 @@ class SortTest extends TestCase
|
||||
$this->assertEquals($link, $sort->link('age'));
|
||||
}
|
||||
|
||||
public function providerForLinkWithParamsAndPassedButEmptySort()
|
||||
public static function providerForLinkWithParamsAndPassedButEmptySort(): array
|
||||
{
|
||||
return [
|
||||
[null],
|
||||
@@ -295,7 +295,7 @@ class SortTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForLinkWithoutParams()
|
||||
public static function providerForLinkWithoutParams(): array
|
||||
{
|
||||
return [
|
||||
[false, null, '<a href="/index.php?r=site%2Findex&sort=age" data-sort="age">Age</a>'],
|
||||
|
||||
@@ -48,7 +48,7 @@ class SqlDataProviderTest extends DatabaseTestCase
|
||||
$this->assertEquals(3, $dataProvider->getTotalCount());
|
||||
}
|
||||
|
||||
public function providerForOrderByColumn()
|
||||
public static function providerForOrderByColumn(): array
|
||||
{
|
||||
return [
|
||||
'no marks' => ['name'],
|
||||
|
||||
@@ -592,7 +592,7 @@ class ContainerTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function dataNotInstantiableException()
|
||||
public static function dataNotInstantiableException(): array
|
||||
{
|
||||
return [
|
||||
[Bar::class],
|
||||
|
||||
@@ -218,7 +218,7 @@ class AccessRuleTest extends TestCase
|
||||
* test user id
|
||||
* expected match result (true, false, null)
|
||||
*/
|
||||
public function matchRoleProvider()
|
||||
public static function matchRoleProvider(): array
|
||||
{
|
||||
return [
|
||||
['create', true, 'user1', [], true],
|
||||
|
||||
@@ -33,7 +33,7 @@ class HostControlTest extends TestCase
|
||||
/**
|
||||
* @return array test data.
|
||||
*/
|
||||
public function hostInfoValidationDataProvider()
|
||||
public static function hostInfoValidationDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -39,7 +39,7 @@ class PageCacheTest extends TestCase
|
||||
CacheTestCase::$microtime = null;
|
||||
}
|
||||
|
||||
public function cacheTestCaseProvider()
|
||||
public static function cacheTestCaseProvider(): array
|
||||
{
|
||||
return [
|
||||
// Basic
|
||||
|
||||
@@ -49,7 +49,7 @@ class AuthTest extends TestCase
|
||||
$this->mockWebApplication($appConfig);
|
||||
}
|
||||
|
||||
public function tokenProvider()
|
||||
public static function tokenProvider(): array
|
||||
{
|
||||
return [
|
||||
['token1', 'user1'],
|
||||
@@ -136,7 +136,7 @@ class AuthTest extends TestCase
|
||||
$this->ensureFilterApplies($token, $login, $filter);
|
||||
}
|
||||
|
||||
public function authMethodProvider()
|
||||
public static function authMethodProvider(): array
|
||||
{
|
||||
return [
|
||||
['yii\filters\auth\CompositeAuth'],
|
||||
|
||||
@@ -122,7 +122,7 @@ class BasicAuthTest extends AuthTest
|
||||
$session->destroy();
|
||||
}
|
||||
|
||||
public function authMethodProvider()
|
||||
public static function authMethodProvider(): array
|
||||
{
|
||||
return [
|
||||
['yii\filters\auth\HttpBasicAuth'],
|
||||
|
||||
@@ -178,7 +178,7 @@ class CompositeAuthTest extends TestCase
|
||||
$this->assertEquals('success', $controller->run('a'));
|
||||
}
|
||||
|
||||
public function compositeAuthDataProvider()
|
||||
public static function compositeAuthDataProvider(): array
|
||||
{
|
||||
return [
|
||||
//base usage
|
||||
|
||||
@@ -44,7 +44,7 @@ class GridViewTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function emptyDataProvider()
|
||||
public static function emptyDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[null, 'No results found.'],
|
||||
|
||||
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace yiiunit\framework\grid;
|
||||
|
||||
use yiiunit\TestCase;
|
||||
use Yii;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\data\Pagination;
|
||||
@@ -19,7 +20,7 @@ use yii\grid\SerialColumn;
|
||||
/**
|
||||
* @group grid
|
||||
*/
|
||||
class SerialColumnTest extends \yiiunit\TestCase
|
||||
class SerialColumnTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideRenderDataCellData
|
||||
|
||||
@@ -862,7 +862,7 @@ class ArrayHelperTest extends TestCase
|
||||
ArrayHelper::keyExists('a', $array, false);
|
||||
}
|
||||
|
||||
public function valueProvider()
|
||||
public static function valueProvider(): array
|
||||
{
|
||||
return [
|
||||
['name', 'test'],
|
||||
@@ -995,7 +995,7 @@ class ArrayHelperTest extends TestCase
|
||||
* Data provider for [[testSetValue()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderSetValue()
|
||||
public static function dataProviderSetValue(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1571,7 +1571,7 @@ class ArrayHelperTest extends TestCase
|
||||
* Data provider for [[testRecursiveSort()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderRecursiveSort()
|
||||
public static function dataProviderRecursiveSort(): array
|
||||
{
|
||||
return [
|
||||
//Normal index array
|
||||
|
||||
@@ -71,7 +71,7 @@ class BaseConsoleTest extends TestCase
|
||||
$this->assertEquals($ansiExpected, $ansiActual);
|
||||
}
|
||||
|
||||
public function ansiColorizedSubstr_withColors_data()
|
||||
public static function ansiColorizedSubstr_withColors_data(): array
|
||||
{
|
||||
return [
|
||||
['%rFoo%gBar%n', 0, 3, '%rFoo%n'],
|
||||
|
||||
@@ -28,7 +28,7 @@ class BaseUrlTest extends TestCase
|
||||
$this->assertEquals($expected, BaseUrl::ensureScheme($url, $scheme));
|
||||
}
|
||||
|
||||
public function ensureSchemeUrlProvider()
|
||||
public static function ensureSchemeUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'relative url and https scheme will return input url' => [
|
||||
@@ -69,7 +69,7 @@ class BaseUrlTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function relativeTrueUrlProvider()
|
||||
public static function relativeTrueUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'url url without protocol' => [
|
||||
@@ -87,7 +87,7 @@ class BaseUrlTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function relativeFalseUrlProvider()
|
||||
public static function relativeFalseUrlProvider(): array
|
||||
{
|
||||
return [
|
||||
'url with https protocol' => [
|
||||
|
||||
@@ -154,7 +154,7 @@ class ConsoleTest extends TestCase
|
||||
}
|
||||
}*/
|
||||
|
||||
public function ansiFormats()
|
||||
public static function ansiFormats(): array
|
||||
{
|
||||
return [
|
||||
['test', 'test'],
|
||||
|
||||
@@ -1266,7 +1266,7 @@ class FileHelperTest extends TestCase
|
||||
FileHelper::changeOwnership($useFile ? $file : null, $ownership, $mode);
|
||||
}
|
||||
|
||||
public function changeOwnershipInvalidArgumentsProvider()
|
||||
public static function changeOwnershipInvalidArgumentsProvider(): array
|
||||
{
|
||||
return [
|
||||
[false, '123:123', null],
|
||||
@@ -1288,7 +1288,7 @@ class FileHelperTest extends TestCase
|
||||
$this->assertEquals($extensions, FileHelper::getExtensionsByMimeType($mimeType));
|
||||
}
|
||||
|
||||
public function getExtensionsByMimeTypeProvider()
|
||||
public static function getExtensionsByMimeTypeProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1323,7 +1323,7 @@ class FileHelperTest extends TestCase
|
||||
$this->assertEquals($extension, FileHelper::getExtensionByMimeType($mimeType, $preferShort));
|
||||
}
|
||||
|
||||
public function getExtensionByMimeTypeProvider()
|
||||
public static function getExtensionByMimeTypeProvider(): array
|
||||
{
|
||||
return [
|
||||
['application/json', true, 'json'],
|
||||
|
||||
@@ -73,7 +73,7 @@ class FormatConverterTest extends TestCase
|
||||
$this->assertEquals('\\o\\\'\\c\\l\\o\\c\\k', FormatConverter::convertDateIcuToPhp('\'o\'\'clock\''));
|
||||
}
|
||||
|
||||
public function providerForICU2PHPPatterns()
|
||||
public static function providerForICU2PHPPatterns(): array
|
||||
{
|
||||
return [
|
||||
'two single quotes produce one' => ["''", "\\'"],
|
||||
@@ -222,7 +222,7 @@ class FormatConverterTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForICU2JUIPatterns()
|
||||
public static function providerForICU2JUIPatterns(): array
|
||||
{
|
||||
return [
|
||||
'era designator like (Anno Domini)' => ['G', ''],
|
||||
@@ -389,7 +389,7 @@ class FormatConverterTest extends TestCase
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
public function providerForPHP2ICUPatterns()
|
||||
public static function providerForPHP2ICUPatterns(): array
|
||||
{
|
||||
return [
|
||||
'single \' should be encoded as \'\', which internally should be encoded as \'\'\'\'' => ["'", "''"],
|
||||
@@ -497,7 +497,7 @@ class FormatConverterTest extends TestCase
|
||||
$this->assertEquals('dd-mm-yy', FormatConverter::convertDatePhpToJui('d-m-Y'));
|
||||
}
|
||||
|
||||
public function providerForPHP2JUIPatterns()
|
||||
public static function providerForPHP2JUIPatterns(): array
|
||||
{
|
||||
return [
|
||||
'Day of the month, 2 digits with leading zeros 01 to 31' => ['d', 'dd'],
|
||||
|
||||
@@ -205,7 +205,7 @@ class HtmlTest extends TestCase
|
||||
* Data provider for [[testBeginFormSimulateViaPost()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderBeginFormSimulateViaPost()
|
||||
public static function dataProviderBeginFormSimulateViaPost(): array
|
||||
{
|
||||
return [
|
||||
['<form action="/foo" method="GET">', 'GET'],
|
||||
@@ -255,7 +255,7 @@ class HtmlTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function imgDataProvider()
|
||||
public static function imgDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -426,7 +426,7 @@ class HtmlTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function textareaDataProvider()
|
||||
public static function textareaDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -618,7 +618,7 @@ EOD;
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForNonStrictBooleanDropDownList()
|
||||
public static function providerForNonStrictBooleanDropDownList(): array
|
||||
{
|
||||
return [
|
||||
[null, false, false, false],
|
||||
@@ -653,7 +653,7 @@ HTML;
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForStrictBooleanDropDownList()
|
||||
public static function providerForStrictBooleanDropDownList(): array
|
||||
{
|
||||
return [
|
||||
[null, false, false, false],
|
||||
@@ -1480,7 +1480,7 @@ EOD;
|
||||
* Data provider for [[testActiveTextInput()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActiveTextInput()
|
||||
public static function dataProviderActiveTextInput(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1523,7 +1523,7 @@ EOD;
|
||||
* Data provider for [[testActiveTextInputMaxLength]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActiveTextInputMaxLength()
|
||||
public static function dataProviderActiveTextInputMaxLength(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1572,7 +1572,7 @@ EOD;
|
||||
* Data provider for [[testActivePasswordInput()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActivePasswordInput()
|
||||
public static function dataProviderActivePasswordInput(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1615,7 +1615,7 @@ EOD;
|
||||
* Data provider for [[testActiveInput_TypeText]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActiveInput_TypeText()
|
||||
public static function dataProviderActiveInput_TypeText(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1654,7 +1654,7 @@ EOD;
|
||||
$this->assertEquals($expectedHtml, Html::activeInput('text', $model, 'name', $options));
|
||||
}
|
||||
|
||||
public function errorSummaryDataProvider()
|
||||
public static function errorSummaryDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1781,7 +1781,7 @@ EOD;
|
||||
* Data provider for [[testActiveTextArea()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActiveTextArea()
|
||||
public static function dataProviderActiveTextArea(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1850,7 +1850,7 @@ EOD;
|
||||
* Data provider for [[testActiveRadio()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActiveRadio()
|
||||
public static function dataProviderActiveRadio(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1894,7 +1894,7 @@ EOD;
|
||||
* Data provider for [[testActiveCheckbox()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderActiveCheckbox()
|
||||
public static function dataProviderActiveCheckbox(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1938,7 +1938,7 @@ EOD;
|
||||
* Data provider for [[testAttributeNameValidation()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function validAttributeNamesProvider()
|
||||
public static function validAttributeNamesProvider(): array
|
||||
{
|
||||
$data = [
|
||||
['asd]asdf.asdfa[asdfa', 'asdf.asdfa'],
|
||||
@@ -1964,7 +1964,7 @@ EOD;
|
||||
* Data provider for [[testAttributeNameValidation()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function invalidAttributeNamesProvider()
|
||||
public static function invalidAttributeNamesProvider(): array
|
||||
{
|
||||
return [
|
||||
['. ..'],
|
||||
@@ -2216,7 +2216,7 @@ HTML;
|
||||
$this->assertStringContainsString('placeholder="My placeholder: Name"', $html);
|
||||
}
|
||||
|
||||
public static function getInputIdDataProvider()
|
||||
public static function getInputIdDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -2255,7 +2255,7 @@ HTML;
|
||||
];
|
||||
}
|
||||
|
||||
public static function getInputIdByNameDataProvider()
|
||||
public static function getInputIdByNameDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -24,7 +24,7 @@ class IpHelperTest extends TestCase
|
||||
$this->assertSame($expected, $version, $message);
|
||||
}
|
||||
|
||||
public function getIpVersionProvider()
|
||||
public static function getIpVersionProvider(): array
|
||||
{
|
||||
return [
|
||||
['192.168.0.1', IpHelper::IPV4],
|
||||
@@ -44,7 +44,7 @@ class IpHelperTest extends TestCase
|
||||
$this->assertSame($expected, $expanded, $message);
|
||||
}
|
||||
|
||||
public function expandIpv6Provider()
|
||||
public static function expandIpv6Provider(): array
|
||||
{
|
||||
return [
|
||||
['fa01::1', 'fa01:0000:0000:0000:0000:0000:0000:0001'],
|
||||
@@ -75,7 +75,7 @@ class IpHelperTest extends TestCase
|
||||
$this->assertSame($expected, $result, $message);
|
||||
}
|
||||
|
||||
public function ip2binProvider()
|
||||
public static function ip2binProvider(): array
|
||||
{
|
||||
return [
|
||||
['192.168.1.1', '11000000101010000000000100000001'],
|
||||
@@ -99,7 +99,7 @@ class IpHelperTest extends TestCase
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
|
||||
public function inRangeProvider()
|
||||
public static function inRangeProvider(): array
|
||||
{
|
||||
return [
|
||||
['192.168.1.1/24', '192.168.0.0/23', true],
|
||||
|
||||
@@ -167,7 +167,7 @@ class StringHelperTest extends TestCase
|
||||
/**
|
||||
* Rules that should work the same for case-sensitive and case-insensitive `startsWith()`.
|
||||
*/
|
||||
public function providerStartsWith()
|
||||
public static function providerStartsWith(): array
|
||||
{
|
||||
return [
|
||||
// positive check
|
||||
@@ -223,7 +223,7 @@ class StringHelperTest extends TestCase
|
||||
/**
|
||||
* Rules that should work the same for case-sensitive and case-insensitive `endsWith()`.
|
||||
*/
|
||||
public function providerEndsWith()
|
||||
public static function providerEndsWith(): array
|
||||
{
|
||||
return [
|
||||
// positive check
|
||||
@@ -307,7 +307,7 @@ class StringHelperTest extends TestCase
|
||||
$this->assertEquals($output, $decoded);
|
||||
}
|
||||
|
||||
public function base64UrlEncodedStringsProvider()
|
||||
public static function base64UrlEncodedStringsProvider(): array
|
||||
{
|
||||
return [
|
||||
['This is an encoded string', 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='],
|
||||
@@ -321,7 +321,7 @@ class StringHelperTest extends TestCase
|
||||
* Data provider for [[testMatchWildcard()]]
|
||||
* @return array test data.
|
||||
*/
|
||||
public function dataProviderMatchWildcard()
|
||||
public static function dataProviderMatchWildcard(): array
|
||||
{
|
||||
return [
|
||||
// *
|
||||
@@ -404,7 +404,7 @@ class StringHelperTest extends TestCase
|
||||
$this->assertSame($expectedResult, StringHelper::matchWildcard($pattern, $string, $options));
|
||||
}
|
||||
|
||||
public function dataProviderMb_ucfirst()
|
||||
public static function dataProviderMb_ucfirst(): array
|
||||
{
|
||||
return [
|
||||
['foo', 'Foo'],
|
||||
@@ -426,7 +426,7 @@ class StringHelperTest extends TestCase
|
||||
$this->assertSame($expectedResult, StringHelper::mb_ucfirst($string));
|
||||
}
|
||||
|
||||
public function dataProviderMb_ucwords()
|
||||
public static function dataProviderMb_ucwords(): array
|
||||
{
|
||||
return [
|
||||
['foo', 'Foo'],
|
||||
@@ -465,7 +465,7 @@ class StringHelperTest extends TestCase
|
||||
$this->assertSame($expectedResult, StringHelper::dirname($string));
|
||||
}
|
||||
|
||||
public function dataProviderDirname()
|
||||
public static function dataProviderDirname(): array
|
||||
{
|
||||
return [
|
||||
['\\foo\\bar\\test', '\foo\bar'],
|
||||
@@ -521,7 +521,7 @@ class StringHelperTest extends TestCase
|
||||
$this->assertSame($expectedResult, StringHelper::findBetween($string, $start, $end));
|
||||
}
|
||||
|
||||
public function dataProviderFindBetween()
|
||||
public static function dataProviderFindBetween(): array
|
||||
{
|
||||
return [
|
||||
['hello world hello', ' hello', ' world', null], // end before start
|
||||
|
||||
@@ -61,7 +61,7 @@ class VarDumperTest extends TestCase
|
||||
* Data provider for [[testExport()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderExport()
|
||||
public static function dataProviderExport(): array
|
||||
{
|
||||
// Regular :
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class FallbackMessageFormatterTest extends TestCase
|
||||
public const SUBJECT = 'сабж';
|
||||
public const SUBJECT_VALUE = 'Answer to the Ultimate Question of Life, the Universe, and Everything';
|
||||
|
||||
public function patterns()
|
||||
public static function patterns(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -548,7 +548,7 @@ class FormatterDateTest extends TestCase
|
||||
$this->assertSame($this->formatter->nullDisplay, $this->formatter->asDuration(null));
|
||||
}
|
||||
|
||||
public function dateInputs()
|
||||
public static function dateInputs(): array
|
||||
{
|
||||
return [
|
||||
['2015-01-01 00:00:00', '2014-13-01 00:00:00'],
|
||||
@@ -584,7 +584,7 @@ class FormatterDateTest extends TestCase
|
||||
$this->assertSame($expected, $this->formatter->asDatetime($value, 'yyyy-MM-dd HH:mm:ss'));
|
||||
}
|
||||
|
||||
public function provideTimezones()
|
||||
public static function provideTimezones(): array
|
||||
{
|
||||
return [
|
||||
['UTC'],
|
||||
|
||||
@@ -46,7 +46,7 @@ class FormatterNumberTest extends TestCase
|
||||
/**
|
||||
* Provides some configuration that should not affect Integer formatter.
|
||||
*/
|
||||
public function differentConfigProvider()
|
||||
public static function differentConfigProvider(): array
|
||||
{
|
||||
// make this test not break when intl is not installed
|
||||
if (!extension_loaded('intl')) {
|
||||
@@ -824,7 +824,7 @@ class FormatterNumberTest extends TestCase
|
||||
$this->assertSame('1023 B', $this->formatter->asShortSize(1023));
|
||||
}
|
||||
|
||||
public function providerForDirectWrongTypeAttributes()
|
||||
public static function providerForDirectWrongTypeAttributes(): array
|
||||
{
|
||||
return [
|
||||
'not-int key for int options' => [
|
||||
@@ -870,7 +870,7 @@ class FormatterNumberTest extends TestCase
|
||||
$this->formatter->asInteger(1, $intOptions, $textOptions);
|
||||
}
|
||||
|
||||
public function providerForConfiguredWrongTypeAttributes()
|
||||
public static function providerForConfiguredWrongTypeAttributes(): array
|
||||
{
|
||||
return [
|
||||
'not-int key for int options' => [
|
||||
|
||||
@@ -357,7 +357,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertSame('1451602800', $this->formatter->asTimestamp($dateTime));
|
||||
}
|
||||
|
||||
public function lengthDataProvider()
|
||||
public static function lengthDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -456,7 +456,7 @@ class FormatterTest extends TestCase
|
||||
$this->assertSame($expected, call_user_func_array([$this->formatter, 'asShortLength'], $arguments), 'Failed asserting that ' . $message);
|
||||
}
|
||||
|
||||
public function weightDataProvider()
|
||||
public static function weightDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -230,7 +230,7 @@ class I18NTest extends TestCase
|
||||
Event::off(PhpMessageSource::class, PhpMessageSource::EVENT_MISSING_TRANSLATION);
|
||||
}
|
||||
|
||||
public function sourceLanguageDataProvider()
|
||||
public static function sourceLanguageDataProvider(): array
|
||||
{
|
||||
return [
|
||||
['en-GB'],
|
||||
|
||||
@@ -30,7 +30,7 @@ class MessageFormatterTest extends TestCase
|
||||
public const SUBJECT = 'сабж';
|
||||
public const SUBJECT_VALUE = 'Answer to the Ultimate Question of Life, the Universe, and Everything';
|
||||
|
||||
public function patterns()
|
||||
public static function patterns(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -276,7 +276,7 @@ _MSG_
|
||||
];
|
||||
}
|
||||
|
||||
public function parsePatterns()
|
||||
public static function parsePatterns(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -493,7 +493,7 @@ class LoggerTest extends TestCase
|
||||
$this->assertEquals([$fistCategory], $logger->getProfiling(['cat*'], ['category*']));
|
||||
}
|
||||
|
||||
public function providerForNonProfilingMessages()
|
||||
public static function providerForNonProfilingMessages(): array
|
||||
{
|
||||
return [
|
||||
[Logger::LEVEL_ERROR],
|
||||
|
||||
@@ -20,7 +20,7 @@ class TargetTest extends TestCase
|
||||
{
|
||||
public static $messages;
|
||||
|
||||
public function filters()
|
||||
public static function filters(): array
|
||||
{
|
||||
return [
|
||||
[[], ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']],
|
||||
|
||||
@@ -216,7 +216,7 @@ class BaseMailerTest extends TestCase
|
||||
$this->assertEquals(strip_tags($htmlViewFileContent), $message->_textBody, 'Unable to render text by direct view!');
|
||||
}
|
||||
|
||||
public function htmlAndPlainProvider()
|
||||
public static function htmlAndPlainProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -107,7 +107,7 @@ trait MutexTestTrait
|
||||
$this->assertFalse($mutexOne->isAcquired('non existing'));
|
||||
}
|
||||
|
||||
public static function mutexDataProvider()
|
||||
public static function mutexDataProvider(): array
|
||||
{
|
||||
$utf = <<<'UTF'
|
||||
𝐘˛𝜄 ӏ𝕤 𝗮 𝔣𝖺𐑈𝝉, 𐑈ℯ𝔠u𝒓𝗲, 𝝰𝞹𝒹 𝖊𝘧𝒇𝗶𝕔𝖎ⅇπτ P𝘏𝙿 𝖿г𝖺m𝖾wσr𝐤.
|
||||
|
||||
@@ -183,7 +183,7 @@ abstract class DbManagerTestCase extends ManagerTestCase
|
||||
$this->auth->assign($updatePost, $userId);
|
||||
}
|
||||
|
||||
public function emptyValuesProvider()
|
||||
public static function emptyValuesProvider(): array
|
||||
{
|
||||
return [
|
||||
[0, 0, true],
|
||||
|
||||
@@ -466,7 +466,7 @@ abstract class ManagerTestCase extends TestCase
|
||||
$this->assertNotEmpty($this->auth->getRoles());
|
||||
}
|
||||
|
||||
public function RBACItemsProvider()
|
||||
public static function RBACItemsProvider(): array
|
||||
{
|
||||
return [
|
||||
[Item::TYPE_ROLE],
|
||||
|
||||
@@ -149,7 +149,7 @@ class YiiRequirementCheckerTest extends TestCase
|
||||
* Data provider for [[testGetByteSize()]].
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderGetByteSize()
|
||||
public static function dataProviderGetByteSize(): array
|
||||
{
|
||||
return [
|
||||
['456', 456],
|
||||
@@ -179,7 +179,7 @@ class YiiRequirementCheckerTest extends TestCase
|
||||
* Data provider for [[testCompareByteSize()]]
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderCompareByteSize()
|
||||
public static function dataProviderCompareByteSize(): array
|
||||
{
|
||||
return [
|
||||
['2M', '2K', '>', true],
|
||||
|
||||
@@ -129,7 +129,7 @@ class IndexActionTest extends TestCase
|
||||
* Data provider for [[testPrepareDataProviderWithPaginationAndSorting()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderTestPrepareDataProviderWithPaginationAndSorting()
|
||||
public static function dataProviderTestPrepareDataProviderWithPaginationAndSorting(): array
|
||||
{
|
||||
return [
|
||||
[ // Default config
|
||||
|
||||
@@ -285,7 +285,7 @@ class SerializerTest extends TestCase
|
||||
], $serializer->serialize($model));
|
||||
}
|
||||
|
||||
public function dataProviderSerializeDataProvider()
|
||||
public static function dataProviderSerializeDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -224,7 +224,7 @@ class UrlRuleTest extends TestCase
|
||||
* - first element is the route to create
|
||||
* - second element is the expected URL
|
||||
*/
|
||||
public function createUrlDataProvider()
|
||||
public static function createUrlDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// with pluralize
|
||||
@@ -415,7 +415,7 @@ class UrlRuleTest extends TestCase
|
||||
* - second element is the expected URL
|
||||
* - third element is the expected result of getCreateUrlStatus() method
|
||||
*/
|
||||
public static function getCreateUrlStatusProvider()
|
||||
public static function getCreateUrlStatusProvider(): array
|
||||
{
|
||||
return [
|
||||
'single controller' => [
|
||||
|
||||
@@ -236,7 +236,7 @@ class DateValidatorTest extends TestCase
|
||||
$this->assertFalse($model->hasErrors('attr_date'));
|
||||
}
|
||||
|
||||
public function provideTimezones()
|
||||
public static function provideTimezones(): array
|
||||
{
|
||||
return [
|
||||
['UTC'],
|
||||
@@ -1074,7 +1074,7 @@ class DateValidatorTest extends TestCase
|
||||
$this->assertTrue($model->hasErrors('attr_date'));
|
||||
}
|
||||
|
||||
public function provideTestStrictDateFormatIntlFail()
|
||||
public static function provideTestStrictDateFormatIntlFail(): array
|
||||
{
|
||||
return [
|
||||
['yyyy-MM-dd', '13-Mar-19', true],
|
||||
@@ -1111,7 +1111,7 @@ class DateValidatorTest extends TestCase
|
||||
$this->assertFalse($model->hasErrors('attr_date'));
|
||||
}
|
||||
|
||||
public function provideTestStrictDateFormatIntlPass()
|
||||
public static function provideTestStrictDateFormatIntlPass(): array
|
||||
{
|
||||
return [
|
||||
['yyyy-MM-dd', '0013-03-19', true],
|
||||
@@ -1143,7 +1143,7 @@ class DateValidatorTest extends TestCase
|
||||
$this->assertTrue($model->hasErrors('attr_date'));
|
||||
}
|
||||
|
||||
public function provideTestStrictDateFormatPhpFail()
|
||||
public static function provideTestStrictDateFormatPhpFail(): array
|
||||
{
|
||||
return [
|
||||
['php:Y-m-d', '13-Mar-19', true],
|
||||
@@ -1179,7 +1179,7 @@ class DateValidatorTest extends TestCase
|
||||
$this->assertFalse($model->hasErrors('attr_date'));
|
||||
}
|
||||
|
||||
public function provideTestStrictDateFormatPhpPass()
|
||||
public static function provideTestStrictDateFormatPhpPass(): array
|
||||
{
|
||||
return [
|
||||
['php:Y-m-d', '0013-03-19', true],
|
||||
|
||||
@@ -144,7 +144,7 @@ class EmailValidatorTest extends TestCase
|
||||
$this->assertFalse($model->hasErrors('attr_email'));
|
||||
}
|
||||
|
||||
public function malformedAddressesProvider()
|
||||
public static function malformedAddressesProvider(): array
|
||||
{
|
||||
return [
|
||||
// this is the demo email used in the proof of concept of the exploit
|
||||
|
||||
@@ -552,7 +552,7 @@ class FileValidatorTest extends TestCase
|
||||
$this->assertFalse($validator->validate($file));
|
||||
}
|
||||
|
||||
public function validMimeTypes()
|
||||
public static function validMimeTypes(): array
|
||||
{
|
||||
$validMimeTypes = array_filter([
|
||||
['test.svg', 'image/*', 'svg'],
|
||||
@@ -575,7 +575,7 @@ class FileValidatorTest extends TestCase
|
||||
return $validMimeTypes;
|
||||
}
|
||||
|
||||
public function invalidMimeTypes()
|
||||
public static function invalidMimeTypes(): array
|
||||
{
|
||||
return [
|
||||
['test.txt', 'image/*', 'png, jpg'],
|
||||
@@ -684,7 +684,7 @@ class FileValidatorTest extends TestCase
|
||||
$this->assertEquals($expected, $validator->validate($file), sprintf('Mime type validate fail: "%s" / "%s"', $mask, $fileMimeType));
|
||||
}
|
||||
|
||||
public function mimeTypeCaseInsensitive()
|
||||
public static function mimeTypeCaseInsensitive(): array
|
||||
{
|
||||
return [
|
||||
['Image/*', 'image/jp2', true],
|
||||
|
||||
@@ -31,7 +31,7 @@ class IpValidatorTest extends TestCase
|
||||
new IpValidator(['ipv4' => false, 'ipv6' => false]);
|
||||
}
|
||||
|
||||
public function provideRangesForSubstitution()
|
||||
public static function provideRangesForSubstitution(): array
|
||||
{
|
||||
return [
|
||||
['10.0.0.1', ['10.0.0.1']],
|
||||
@@ -65,7 +65,7 @@ class IpValidatorTest extends TestCase
|
||||
$this->assertFalse($validator->validate('babe::cafe'));
|
||||
}
|
||||
|
||||
public function provideBadIps()
|
||||
public static function provideBadIps(): array
|
||||
{
|
||||
return [['not.an.ip'], [['what an array', '??']], [123456], [true], [false], ['bad:forSure']];
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ EOF;
|
||||
$this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
|
||||
}
|
||||
|
||||
public function positionProvider()
|
||||
public static function positionProvider(): array
|
||||
{
|
||||
return [
|
||||
[View::POS_HEAD, true],
|
||||
@@ -414,7 +414,7 @@ EOF;
|
||||
$this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php'));
|
||||
}
|
||||
|
||||
public function registerFileDataProvider()
|
||||
public static function registerFileDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// JS files registration
|
||||
|
||||
@@ -129,7 +129,7 @@ Exception: yii\web\NotFoundHttpException', $out);
|
||||
$this->assertStringContainsString('<a href="netbeans://open?file=' . $file . '&line=63">', $out);
|
||||
}
|
||||
|
||||
public function dataHtmlEncode()
|
||||
public static function dataHtmlEncode(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -29,7 +29,7 @@ class JsonResponseFormatterTest extends FormatterTest
|
||||
return new JsonResponseFormatter($configuration);
|
||||
}
|
||||
|
||||
public function formatScalarDataProvider()
|
||||
public static function formatScalarDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[1, 1],
|
||||
@@ -39,7 +39,7 @@ class JsonResponseFormatterTest extends FormatterTest
|
||||
];
|
||||
}
|
||||
|
||||
public function formatArrayDataProvider()
|
||||
public static function formatArrayDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// input, json, pretty json
|
||||
@@ -76,7 +76,7 @@ class JsonResponseFormatterTest extends FormatterTest
|
||||
];
|
||||
}
|
||||
|
||||
public function formatObjectDataProvider()
|
||||
public static function formatObjectDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[new Post(123, 'abc'), '{"id":123,"title":"abc"}'],
|
||||
@@ -91,7 +91,7 @@ class JsonResponseFormatterTest extends FormatterTest
|
||||
];
|
||||
}
|
||||
|
||||
public function formatTraversableObjectDataProvider()
|
||||
public static function formatTraversableObjectDataProvider(): array
|
||||
{
|
||||
$postsStack = new SplStack();
|
||||
$postsStack->push(new Post(915, 'record1'));
|
||||
@@ -102,14 +102,14 @@ class JsonResponseFormatterTest extends FormatterTest
|
||||
];
|
||||
}
|
||||
|
||||
public function formatModelDataProvider()
|
||||
public static function formatModelDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[new ModelStub(['id' => 123, 'title' => 'abc', 'hidden' => 'hidden']), '{"id":123,"title":"abc"}'],
|
||||
];
|
||||
}
|
||||
|
||||
public function contentTypeGenerationDataProvider()
|
||||
public static function contentTypeGenerationDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -389,7 +389,7 @@ class RequestTest extends TestCase
|
||||
$this->assertEquals($_GET, ['id' => 63]);
|
||||
}
|
||||
|
||||
public function getHostInfoDataProvider()
|
||||
public static function getHostInfoDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// empty
|
||||
@@ -593,7 +593,7 @@ class RequestTest extends TestCase
|
||||
$this->assertNull($request->getServerPort());
|
||||
}
|
||||
|
||||
public function isSecureServerDataProvider()
|
||||
public static function isSecureServerDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[['HTTPS' => 1], true],
|
||||
@@ -721,7 +721,7 @@ class RequestTest extends TestCase
|
||||
$_SERVER = $original;
|
||||
}
|
||||
|
||||
public function isSecureServerWithoutTrustedHostDataProvider()
|
||||
public static function isSecureServerWithoutTrustedHostDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// RFC 7239 forwarded header is not enabled
|
||||
@@ -760,7 +760,7 @@ class RequestTest extends TestCase
|
||||
$_SERVER = $original;
|
||||
}
|
||||
|
||||
public function getUserIPDataProvider()
|
||||
public static function getUserIPDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -938,7 +938,7 @@ class RequestTest extends TestCase
|
||||
$_SERVER = $original;
|
||||
}
|
||||
|
||||
public function getUserIPWithoutTruestHostDataProvider()
|
||||
public static function getUserIPWithoutTruestHostDataProvider(): array
|
||||
{
|
||||
return [
|
||||
// RFC 7239 forwarded is not enabled
|
||||
@@ -980,7 +980,7 @@ class RequestTest extends TestCase
|
||||
$_SERVER = $original;
|
||||
}
|
||||
|
||||
public function getMethodDataProvider()
|
||||
public static function getMethodDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1014,7 +1014,7 @@ class RequestTest extends TestCase
|
||||
$_SERVER = $original;
|
||||
}
|
||||
|
||||
public function getIsAjaxDataProvider()
|
||||
public static function getIsAjaxDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1046,7 +1046,7 @@ class RequestTest extends TestCase
|
||||
$_SERVER = $original;
|
||||
}
|
||||
|
||||
public function getIsPjaxDataProvider()
|
||||
public static function getIsPjaxDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1090,7 +1090,7 @@ class RequestTest extends TestCase
|
||||
$this->assertNull($request->getOrigin());
|
||||
}
|
||||
|
||||
public function httpAuthorizationHeadersProvider()
|
||||
public static function httpAuthorizationHeadersProvider(): array
|
||||
{
|
||||
return [
|
||||
['not a base64 at all', [base64_decode('not a base64 at all'), null]],
|
||||
@@ -1169,7 +1169,7 @@ class RequestTest extends TestCase
|
||||
$this->assertSame('default', $request->getBodyParam('unexisting', 'default'));
|
||||
}
|
||||
|
||||
public function getBodyParamsDataProvider()
|
||||
public static function getBodyParamsDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'json' => ['application/json', '{"foo":"bar","baz":1}', ['foo' => 'bar', 'baz' => 1]],
|
||||
@@ -1193,7 +1193,7 @@ class RequestTest extends TestCase
|
||||
$this->assertSame($expected, $request->getBodyParams());
|
||||
}
|
||||
|
||||
public function trustedHostAndInjectedXForwardedForDataProvider()
|
||||
public static function trustedHostAndInjectedXForwardedForDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'emptyIPs' => ['1.1.1.1', '', null, ['10.10.10.10'], '1.1.1.1'],
|
||||
@@ -1230,7 +1230,7 @@ class RequestTest extends TestCase
|
||||
$this->assertSame($expectedUserIp, $request->getUserIP());
|
||||
}
|
||||
|
||||
public function trustedHostAndXForwardedPortDataProvider()
|
||||
public static function trustedHostAndXForwardedPortDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'defaultPlain' => ['1.1.1.1', 80, null, null, 80],
|
||||
@@ -1274,7 +1274,7 @@ class RequestTest extends TestCase
|
||||
$this->assertSame($expectedMethod, $request->getMethod());
|
||||
}
|
||||
|
||||
public function alreadyResolvedIpDataProvider()
|
||||
public static function alreadyResolvedIpDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'resolvedXForwardedFor' => [
|
||||
@@ -1317,7 +1317,7 @@ class RequestTest extends TestCase
|
||||
$this->assertSame($expectedIsSecureConnection, $request->isSecureConnection, 'Secure connection fail!');
|
||||
}
|
||||
|
||||
public function parseForwardedHeaderDataProvider()
|
||||
public static function parseForwardedHeaderDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -44,7 +44,7 @@ class ResponseTest extends TestCase
|
||||
$this->response = new Response();
|
||||
}
|
||||
|
||||
public function rightRanges()
|
||||
public static function rightRanges(): array
|
||||
{
|
||||
// TODO test more cases for range requests and check for rfc compatibility
|
||||
// https://tools.ietf.org/html/rfc2616
|
||||
@@ -83,7 +83,7 @@ class ResponseTest extends TestCase
|
||||
$this->assertEquals((string)$length, $headers->get('Content-Length'));
|
||||
}
|
||||
|
||||
public function wrongRanges()
|
||||
public static function wrongRanges(): array
|
||||
{
|
||||
// TODO test more cases for range requests and check for rfc compatibility
|
||||
// https://tools.ietf.org/html/rfc2616
|
||||
@@ -213,7 +213,7 @@ class ResponseTest extends TestCase
|
||||
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
|
||||
* @return array
|
||||
*/
|
||||
public function dataProviderAjaxRedirectInternetExplorer11()
|
||||
public static function dataProviderAjaxRedirectInternetExplorer11(): array
|
||||
{
|
||||
return [
|
||||
['Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0', [301 => 301, 302 => 302]], // Firefox
|
||||
@@ -260,7 +260,7 @@ class ResponseTest extends TestCase
|
||||
static::assertEquals(200, $this->response->statusCode);
|
||||
}
|
||||
|
||||
public function dataProviderSetStatusCodeByException()
|
||||
public static function dataProviderSetStatusCodeByException(): array
|
||||
{
|
||||
$data = [
|
||||
[
|
||||
@@ -303,7 +303,7 @@ class ResponseTest extends TestCase
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function formatDataProvider()
|
||||
public static function formatDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[Response::FORMAT_JSON, '{"value":1}'],
|
||||
@@ -415,7 +415,7 @@ class ResponseTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function cookiesTestProvider()
|
||||
public static function cookiesTestProvider(): array
|
||||
{
|
||||
$expireInt = time() + 3600;
|
||||
$expireString = date('D, d-M-Y H:i:s', $expireInt) . ' GMT';
|
||||
|
||||
@@ -69,7 +69,7 @@ class UrlManagerCreateUrlTest extends TestCase
|
||||
return new UrlManager($config);
|
||||
}
|
||||
|
||||
public function variationsProvider()
|
||||
public static function variationsProvider(): array
|
||||
{
|
||||
$baseUrlConfig = [
|
||||
'baseUrl' => '/test',
|
||||
@@ -521,7 +521,7 @@ class UrlManagerCreateUrlTest extends TestCase
|
||||
$assertations($manager);
|
||||
}
|
||||
|
||||
public function absolutePatternsVariations()
|
||||
public static function absolutePatternsVariations(): array
|
||||
{
|
||||
$baseUrlConfig = [
|
||||
'baseUrl' => '/test',
|
||||
@@ -682,7 +682,7 @@ class UrlManagerCreateUrlTest extends TestCase
|
||||
$this->assertEquals($expected, $manager->createAbsoluteUrl($urlParams));
|
||||
}
|
||||
|
||||
public function multipleHostsRulesDataProvider()
|
||||
public static function multipleHostsRulesDataProvider(): array
|
||||
{
|
||||
return [
|
||||
['http://example.com'],
|
||||
|
||||
@@ -106,7 +106,7 @@ class UrlManagerParseUrlTest extends TestCase
|
||||
$this->assertFalse($manager->parseRequest($this->getRequest('module/site/index/')));
|
||||
}
|
||||
|
||||
public function suffixProvider()
|
||||
public static function suffixProvider(): array
|
||||
{
|
||||
return [
|
||||
['.html'],
|
||||
|
||||
@@ -62,7 +62,7 @@ class UrlManagerTest extends TestCase
|
||||
* $showScriptName and $enableStrictParsing should have no effect in default format.
|
||||
* Passing these options ensures that.
|
||||
*/
|
||||
public function ignoredOptionsProvider()
|
||||
public static function ignoredOptionsProvider(): array
|
||||
{
|
||||
return [
|
||||
[false, false],
|
||||
@@ -215,7 +215,7 @@ class UrlManagerTest extends TestCase
|
||||
/**
|
||||
* @return array provides different names for UrlManager::$routeParam
|
||||
*/
|
||||
public function routeParamProvider()
|
||||
public static function routeParamProvider(): array
|
||||
{
|
||||
return [
|
||||
['r'], // default value
|
||||
|
||||
@@ -1355,7 +1355,7 @@ class UrlRuleTest extends TestCase
|
||||
* - third element is the expected URL
|
||||
* - fourth element is the expected result of getCreateUrlStatus() method
|
||||
*/
|
||||
public static function getCreateUrlStatusProvider()
|
||||
public static function getCreateUrlStatusProvider(): array
|
||||
{
|
||||
return [
|
||||
'route' => [
|
||||
|
||||
@@ -266,7 +266,7 @@ EOT;
|
||||
$this->assertEquals($expectedValue, $actualValue);
|
||||
}
|
||||
|
||||
public function hintDataProvider()
|
||||
public static function hintDataProvider(): array
|
||||
{
|
||||
return [
|
||||
['Hint Content', '<div class="hint-block">Hint Content</div>'],
|
||||
|
||||
@@ -129,7 +129,7 @@ HTML,
|
||||
);
|
||||
}
|
||||
|
||||
public function itemViewOptions()
|
||||
public static function itemViewOptions(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -175,7 +175,7 @@ HTML,
|
||||
$this->assertEqualsWithoutLE($expected, $out);
|
||||
}
|
||||
|
||||
public function itemOptions()
|
||||
public static function itemOptions(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -348,7 +348,7 @@ HTML,
|
||||
</div>', $out);
|
||||
}
|
||||
|
||||
public function providerForSummary()
|
||||
public static function providerForSummary(): array
|
||||
{
|
||||
return [
|
||||
'empty' => ['', '<div id="w0" class="list-view">
|
||||
|
||||
Reference in New Issue
Block a user