From 909396074eef92d62dd34b4709bb7351e722bec3 Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+mspirkov@users.noreply.github.com> Date: Fri, 10 Oct 2025 23:04:09 +0300 Subject: [PATCH] Fix codestyle in `build` and `tests` (#20586) --- .github/workflows/lint.yaml | 2 +- build/controllers/MimeTypeController.php | 11 +- build/controllers/PhpDocController.php | 29 ++- build/controllers/ReleaseController.php | 35 ++-- build/controllers/Utf8Controller.php | 30 +-- phpcs.xml.dist | 26 +++ tests/TestCase.php | 2 +- tests/data/ar/Cat.php | 2 +- tests/data/ar/Order.php | 1 - tests/data/base/Singer.php | 4 +- tests/framework/ChangeLogTest.php | 5 +- tests/framework/ar/ActiveRecordTestTrait.php | 1 + tests/framework/base/ActionFilterTest.php | 1 - tests/framework/base/ComponentTest.php | 1 - tests/framework/base/ControllerTest.php | 6 - tests/framework/base/ErrorExceptionTest.php | 2 +- tests/framework/base/ExposedSecurity.php | 1 + tests/framework/base/ModuleTest.php | 2 +- tests/framework/base/SecurityTest.php | 4 +- tests/framework/base/ViewTest.php | 16 +- tests/framework/base/WidgetTest.php | 2 +- .../themes/basic/views/site/index.php | 1 + .../themes/christmas/views/site/index.php | 1 + .../themes/christmas/views/site/main.php | 1 + .../base/stub/AnonymousComponentClass.php | 6 +- .../base/stub/AnonymousModelClass.php | 4 +- .../behaviors/OptimisticLockBehaviorTest.php | 4 +- .../behaviors/SluggableBehaviorTest.php | 5 +- .../behaviors/TimestampBehaviorTest.php | 8 +- tests/framework/caching/ApcCacheTest.php | 1 + tests/framework/caching/ArrayCacheTest.php | 5 +- tests/framework/caching/CacheTestCase.php | 10 +- tests/framework/caching/DbCacheTest.php | 1 + tests/framework/caching/DbDependencyTest.php | 1 + .../caching/DbQueryDependencyTest.php | 2 +- tests/framework/caching/DependencyTest.php | 1 + tests/framework/caching/FileCacheTest.php | 1 + tests/framework/caching/MemCacheTest.php | 1 + tests/framework/caching/MemCachedTest.php | 1 + tests/framework/caching/MssqlCacheTest.php | 2 +- tests/framework/caching/PgSQLCacheTest.php | 1 + tests/framework/caching/TagDependencyTest.php | 1 + tests/framework/caching/WinCacheTest.php | 1 + tests/framework/console/ControllerTest.php | 6 +- tests/framework/console/FakeController.php | 1 + .../framework/console/FakeHelpController.php | 1 + .../FakeHelpControllerWithoutOutput.php | 1 + .../framework/console/FakePhp71Controller.php | 1 + tests/framework/console/RequestTest.php | 3 + .../console/UnknownCommandExceptionTest.php | 1 + .../controllers/AssetControllerTest.php | 1 + .../controllers/BaseMessageControllerTest.php | 32 ++- .../controllers/CacheControllerTest.php | 3 +- .../controllers/DbMessageControllerTest.php | 3 +- .../controllers/EchoMigrateController.php | 1 + .../controllers/FixtureControllerTest.php | 1 + .../controllers/HelpControllerTest.php | 13 +- .../controllers/MigrateControllerTest.php | 1 + .../MigrateControllerTestTrait.php | 2 +- .../controllers/PHPMessageControllerTest.php | 4 +- .../controllers/POMessageControllerTest.php | 1 + .../controllers/ServeControllerTest.php | 1 + .../controllers/SilencedCacheController.php | 1 + .../StdOutBufferControllerTrait.php | 1 + .../console/controllers/stub/index.php | 2 +- .../framework/console/stubs/DummyService.php | 3 +- tests/framework/console/widgets/TableTest.php | 167 +++++++++------ tests/framework/data/ActiveDataFilterTest.php | 1 + .../data/ActiveDataProviderCloningTest.php | 1 + .../framework/data/ActiveDataProviderTest.php | 1 + .../framework/data/ArrayDataProviderTest.php | 1 + tests/framework/data/BaseDataProviderTest.php | 1 + tests/framework/data/DataFilterTest.php | 1 + tests/framework/data/PaginationTest.php | 1 + tests/framework/data/SortTest.php | 1 + tests/framework/data/SqlDataProviderTest.php | 1 + .../db/ActiveQueryModelConnectionTest.php | 1 + tests/framework/db/ActiveQueryTest.php | 4 +- tests/framework/db/ActiveRecordTest.php | 17 +- tests/framework/db/AnyCaseValue.php | 1 + tests/framework/db/AnyValue.php | 1 + tests/framework/db/BatchQueryResultTest.php | 1 + .../framework/db/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/CommandTest.php | 40 ++-- tests/framework/db/CompareValue.php | 1 + tests/framework/db/ConnectionTest.php | 5 +- tests/framework/db/DatabaseTestCase.php | 2 +- .../framework/db/GetTablesAliasTestTrait.php | 1 + tests/framework/db/QueryBuilderTest.php | 31 +-- tests/framework/db/QueryTest.php | 7 +- tests/framework/db/SchemaTest.php | 1 + tests/framework/db/UnqueryableQueryMock.php | 1 + .../db/cubrid/ActiveDataProviderTest.php | 1 + .../framework/db/cubrid/ActiveFixtureTest.php | 1 + tests/framework/db/cubrid/ActiveQueryTest.php | 1 + .../framework/db/cubrid/ActiveRecordTest.php | 1 + .../db/cubrid/BatchQueryResultTest.php | 1 + .../db/cubrid/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/cubrid/CommandTest.php | 1 + tests/framework/db/cubrid/ConnectionTest.php | 1 + .../db/cubrid/ExistValidatorTest.php | 1 + .../framework/db/cubrid/QueryBuilderTest.php | 1 + tests/framework/db/cubrid/QueryTest.php | 1 + tests/framework/db/cubrid/SchemaTest.php | 2 +- .../db/cubrid/UniqueValidatorTest.php | 1 + .../db/mssql/ActiveDataProviderTest.php | 1 + .../framework/db/mssql/ActiveFixtureTest.php | 1 + tests/framework/db/mssql/ActiveQueryTest.php | 1 + tests/framework/db/mssql/ActiveRecordTest.php | 1 + .../db/mssql/BatchQueryResultTest.php | 1 + .../db/mssql/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/mssql/CommandTest.php | 1 + tests/framework/db/mssql/ConnectionTest.php | 1 + .../db/mssql/DbMessageSourceTest.php | 1 + .../framework/db/mssql/ExistValidatorTest.php | 1 + tests/framework/db/mssql/QueryBuilderTest.php | 25 +-- tests/framework/db/mssql/QueryCacheTest.php | 3 +- tests/framework/db/mssql/QueryTest.php | 1 + tests/framework/db/mssql/SchemaTest.php | 3 +- .../db/mssql/UniqueValidatorTest.php | 1 + tests/framework/db/mssql/type/BooleanTest.php | 1 + .../framework/db/mssql/type/VarbinaryTest.php | 1 + .../db/mysql/ActiveDataProviderTest.php | 1 + .../framework/db/mysql/ActiveFixtureTest.php | 1 + tests/framework/db/mysql/ActiveQueryTest.php | 1 + tests/framework/db/mysql/ActiveRecordTest.php | 1 + .../db/mysql/BatchQueryResultTest.php | 1 + .../db/mysql/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/mysql/CommandTest.php | 1 + tests/framework/db/mysql/ConnectionTest.php | 1 + .../framework/db/mysql/ExistValidatorTest.php | 1 + tests/framework/db/mysql/QueryBuilderTest.php | 15 +- tests/framework/db/mysql/QueryTest.php | 1 + tests/framework/db/mysql/SchemaTest.php | 11 +- .../db/mysql/UniqueValidatorTest.php | 1 + .../db/mysql/connection/DeadLockTest.php | 6 +- tests/framework/db/mysql/type/JsonTest.php | 1 + .../db/oci/ActiveDataProviderTest.php | 1 + tests/framework/db/oci/ActiveFixtureTest.php | 1 + tests/framework/db/oci/ActiveQueryTest.php | 1 + tests/framework/db/oci/ActiveRecordTest.php | 1 + .../framework/db/oci/BatchQueryResultTest.php | 1 + .../db/oci/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/oci/CommandTest.php | 14 +- tests/framework/db/oci/ConnectionTest.php | 1 + tests/framework/db/oci/ExistValidatorTest.php | 1 + tests/framework/db/oci/QueryBuilderTest.php | 6 +- tests/framework/db/oci/QueryTest.php | 1 + tests/framework/db/oci/SchemaTest.php | 1 + .../framework/db/oci/UniqueValidatorTest.php | 1 + .../db/pgsql/ActiveDataProviderTest.php | 1 + tests/framework/db/pgsql/ActiveQueryTest.php | 1 + tests/framework/db/pgsql/ActiveRecordTest.php | 7 +- tests/framework/db/pgsql/ArrayParserTest.php | 2 +- .../db/pgsql/BatchQueryResultTest.php | 1 + .../db/pgsql/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/pgsql/CommandTest.php | 13 +- tests/framework/db/pgsql/ConnectionTest.php | 1 + .../framework/db/pgsql/ExistValidatorTest.php | 1 + tests/framework/db/pgsql/QueryBuilderTest.php | 5 +- tests/framework/db/pgsql/QueryTest.php | 7 +- tests/framework/db/pgsql/SchemaTest.php | 9 +- .../db/pgsql/UniqueValidatorTest.php | 3 +- tests/framework/db/pgsql/type/BooleanTest.php | 1 + .../db/sqlite/ActiveDataProviderTest.php | 1 + .../framework/db/sqlite/ActiveFixtureTest.php | 1 + tests/framework/db/sqlite/ActiveQueryTest.php | 1 + .../framework/db/sqlite/ActiveRecordTest.php | 1 + .../db/sqlite/BatchQueryResultTest.php | 1 + .../db/sqlite/ColumnSchemaBuilderTest.php | 1 + tests/framework/db/sqlite/CommandTest.php | 1 + tests/framework/db/sqlite/ConnectionTest.php | 1 + .../db/sqlite/ExistValidatorTest.php | 1 + .../framework/db/sqlite/QueryBuilderTest.php | 1 + tests/framework/db/sqlite/QueryTest.php | 1 + tests/framework/db/sqlite/SchemaTest.php | 1 + .../framework/db/sqlite/SqlTokenizerTest.php | 1 + .../db/sqlite/UniqueValidatorTest.php | 1 + .../framework/db/sqlite/type/BooleanTest.php | 1 + .../framework/db/testBatchInsertWithYield.php | 1 + tests/framework/di/ContainerTest.php | 1 + tests/framework/di/InstanceTest.php | 1 + tests/framework/di/ServiceLocatorTest.php | 2 +- tests/framework/di/stubs/Bar.php | 1 + tests/framework/di/stubs/BarSetter.php | 1 + tests/framework/di/stubs/Corge.php | 1 + tests/framework/di/stubs/Foo.php | 1 + tests/framework/di/stubs/FooBaz.php | 1 + tests/framework/di/stubs/FooProperty.php | 1 + tests/framework/di/stubs/Qux.php | 1 + tests/framework/di/stubs/QuxAnother.php | 1 + tests/framework/di/stubs/QuxFactory.php | 1 + tests/framework/di/stubs/QuxInterface.php | 1 + tests/framework/di/stubs/Variadic.php | 1 + .../di/testContainerWithVariadicCallable.php | 1 + tests/framework/filters/AccessRuleTest.php | 61 +++++- tests/framework/filters/AjaxFilterTest.php | 1 + .../filters/ContentNegotiatorTest.php | 1 + tests/framework/filters/CorsTest.php | 7 +- tests/framework/filters/HostControlTest.php | 4 +- tests/framework/filters/HttpCacheTest.php | 1 + tests/framework/filters/PageCacheTest.php | 5 +- tests/framework/filters/RateLimiterTest.php | 4 +- .../framework/filters/auth/AuthMethodTest.php | 13 +- tests/framework/filters/auth/AuthTest.php | 3 +- .../framework/filters/auth/BasicAuthTest.php | 1 + .../filters/auth/CompositeAuthTest.php | 1 + .../framework/filters/stubs/ExposedLogger.php | 2 +- .../filters/stubs/MockAuthManager.php | 1 + tests/framework/filters/stubs/RateLimit.php | 2 +- .../framework/filters/stubs/UserIdentity.php | 1 + tests/framework/grid/ActionColumnTest.php | 9 +- tests/framework/grid/CheckboxColumnTest.php | 3 +- tests/framework/grid/DataColumnTest.php | 14 +- tests/framework/grid/GridViewTest.php | 50 ++--- .../framework/grid/RadiobuttonColumnTest.php | 1 + tests/framework/helpers/ArrayHelperTest.php | 8 +- tests/framework/helpers/BaseConsoleTest.php | 3 +- tests/framework/helpers/ConsoleStub.php | 2 +- tests/framework/helpers/ConsoleTest.php | 43 ++-- tests/framework/helpers/FallbackInflector.php | 1 + tests/framework/helpers/FileHelperTest.php | 60 +++--- .../framework/helpers/FormatConverterTest.php | 1 + tests/framework/helpers/HtmlTest.php | 22 +- tests/framework/helpers/InflectorTest.php | 1 + tests/framework/helpers/JsonTest.php | 3 +- tests/framework/helpers/MarkdownTest.php | 3 +- .../helpers/ReplaceArrayValueTest.php | 1 + tests/framework/helpers/StringHelperTest.php | 6 +- .../framework/helpers/UnsetArrayValueTest.php | 1 + tests/framework/helpers/UrlTest.php | 1 + tests/framework/helpers/VarDumperTest.php | 19 +- tests/framework/i18n/DbMessageSourceTest.php | 5 +- .../i18n/FallbackMessageFormatterTest.php | 1 + tests/framework/i18n/FormatterDateTest.php | 4 +- tests/framework/i18n/FormatterNumberTest.php | 2 +- tests/framework/i18n/FormatterTest.php | 15 +- .../i18n/GettextMessageSourceTest.php | 1 + tests/framework/i18n/GettextMoFileTest.php | 1 + tests/framework/i18n/GettextPoFileTest.php | 1 + tests/framework/i18n/I18NTest.php | 7 +- tests/framework/i18n/IntlTestHelper.php | 1 + tests/framework/i18n/LocaleTest.php | 1 + tests/framework/i18n/MessageFormatterTest.php | 1 + tests/framework/log/ArrayTarget.php | 1 + tests/framework/log/DbTargetTest.php | 1 + tests/framework/log/DispatcherTest.php | 4 +- tests/framework/log/EmailTargetTest.php | 3 +- tests/framework/log/FileTargetTest.php | 1 + tests/framework/log/LoggerTest.php | 127 ++++++------ tests/framework/log/MySQLTargetTest.php | 1 + tests/framework/log/PgSQLTargetTest.php | 1 + tests/framework/log/SqliteTargetTest.php | 1 + tests/framework/log/SyslogTargetTest.php | 3 +- tests/framework/log/TargetTest.php | 1 + tests/framework/log/mocks/TargetMock.php | 4 +- tests/framework/log/mocks/typed_error.php | 3 +- tests/framework/mail/BaseMailerTest.php | 1 + tests/framework/mail/BaseMessageTest.php | 1 + tests/framework/models/JsonModel.php | 3 +- tests/framework/mutex/FileMutexTest.php | 1 + tests/framework/mutex/MutexTestTrait.php | 1 + tests/framework/mutex/MysqlMutexTest.php | 3 +- tests/framework/mutex/PgsqlMutexTest.php | 1 + .../framework/mutex/RetryAcquireTraitTest.php | 1 + tests/framework/mutex/mocks/DumbMutex.php | 1 + tests/framework/rbac/ActionRule.php | 1 + tests/framework/rbac/AuthorRule.php | 1 + tests/framework/rbac/DbManagerTestCase.php | 6 +- tests/framework/rbac/ExposedPhpManager.php | 1 + tests/framework/rbac/ManagerTestCase.php | 2 +- .../framework/rbac/MySQLManagerCacheTest.php | 1 + tests/framework/rbac/MySQLManagerTest.php | 1 + .../framework/rbac/PgSQLManagerCacheTest.php | 1 + tests/framework/rbac/PgSQLManagerTest.php | 1 + tests/framework/rbac/PhpManagerTest.php | 1 + tests/framework/rbac/SqliteManagerTest.php | 1 + .../YiiRequirementCheckerTest.php | 1 + tests/framework/rest/IndexActionTest.php | 51 ++--- tests/framework/rest/SerializerTest.php | 13 +- tests/framework/rest/UrlRuleTest.php | 1 + tests/framework/test/ActiveFixtureTest.php | 2 +- tests/framework/test/ArrayFixtureTest.php | 3 +- tests/framework/test/FixtureTest.php | 94 +++++---- tests/framework/test/custom/customer.php | 1 + tests/framework/test/data/array_fixture.php | 1 + tests/framework/test/data/customer.php | 1 + tests/framework/test/data/profile.php | 1 + .../validators/BooleanValidatorTest.php | 1 + .../validators/CompareValidatorTest.php | 3 +- .../validators/DateValidatorTest.php | 1 + .../validators/DefaultValueValidatorTest.php | 1 + .../validators/EachValidatorTest.php | 1 + .../validators/EmailValidatorTest.php | 2 +- .../validators/ExistValidatorTest.php | 9 +- .../validators/FileValidatorTest.php | 10 +- .../validators/FilterValidatorTest.php | 1 + .../framework/validators/IpValidatorTest.php | 4 +- .../validators/NumberValidatorTest.php | 1 + .../validators/RangeValidatorTest.php | 1 + .../RegularExpressionValidatorTest.php | 1 + .../validators/RequiredValidatorTest.php | 1 + .../validators/StringValidatorTest.php | 1 + .../validators/UniqueValidatorTest.php | 15 +- .../framework/validators/UrlValidatorTest.php | 1 + tests/framework/validators/ValidatorTest.php | 1 + tests/framework/web/AssetBundleTest.php | 7 +- tests/framework/web/AssetConverterTest.php | 9 +- tests/framework/web/ControllerTest.php | 37 ++-- tests/framework/web/CookieCollectionTest.php | 1 + tests/framework/web/ErrorActionTest.php | 1 + tests/framework/web/ErrorHandlerTest.php | 6 +- tests/framework/web/FakeController.php | 1 + tests/framework/web/FakePhp71Controller.php | 2 +- tests/framework/web/FakePhp7Controller.php | 1 + tests/framework/web/FakePhp80Controller.php | 2 - tests/framework/web/FormatterTest.php | 1 + tests/framework/web/GroupUrlRuleTest.php | 1 + tests/framework/web/HeaderCollectionTest.php | 1 + .../web/JsonResponseFormatterTest.php | 1 + tests/framework/web/LinkTest.php | 1 + .../web/MultipartFormDataParserTest.php | 5 +- tests/framework/web/Post.php | 1 + tests/framework/web/RequestTest.php | 54 ++--- tests/framework/web/ResponseTest.php | 23 ++- tests/framework/web/UploadedFileTest.php | 3 +- .../framework/web/UrlManagerCreateUrlTest.php | 4 +- .../framework/web/UrlManagerParseUrlTest.php | 12 +- tests/framework/web/UrlManagerTest.php | 2 +- tests/framework/web/UrlNormalizerTest.php | 1 + tests/framework/web/UrlRuleTest.php | 1 + tests/framework/web/UserIdentity.php | 1 + tests/framework/web/UserTest.php | 7 +- tests/framework/web/ViewTest.php | 194 ++++++++++++------ .../web/XmlResponseFormatterTest.php | 1 + .../web/mocks/TestRequestComponent.php | 5 +- .../web/session/AbstractDbSessionTest.php | 3 +- .../web/session/CacheSessionTest.php | 1 + tests/framework/web/session/SessionTest.php | 1 + .../web/session/SessionTestTrait.php | 1 - .../web/session/mssql/DbSessionTest.php | 1 + .../web/session/mysql/DbSessionTest.php | 1 + .../web/session/pgsql/DbSessionTest.php | 1 + .../web/session/sqlite/DbSessionTest.php | 1 + tests/framework/web/stubs/CachedUrlRule.php | 1 + .../framework/web/stubs/ModelBindingStub.php | 11 +- tests/framework/web/stubs/ModelStub.php | 1 + tests/framework/web/stubs/VendorImage.php | 1 + tests/framework/widgets/ActiveFieldTest.php | 11 +- tests/framework/widgets/ActiveFormTest.php | 65 +++--- tests/framework/widgets/BlockTest.php | 1 + tests/framework/widgets/BreadcrumbsTest.php | 2 +- .../widgets/ContentDecoratorTest.php | 1 + tests/framework/widgets/DetailViewTest.php | 1 + tests/framework/widgets/FragmentCacheTest.php | 3 +- tests/framework/widgets/LinkPagerTest.php | 1 + tests/framework/widgets/LinkSorterTest.php | 25 ++- tests/framework/widgets/ListViewTest.php | 34 +-- tests/framework/widgets/MenuTest.php | 15 +- tests/framework/widgets/PjaxTest.php | 1 + tests/framework/widgets/SpacelessTest.php | 1 + 361 files changed, 1422 insertions(+), 790 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 225649bc34..ee78b6c60c 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -67,4 +67,4 @@ jobs: tools: cs2pr - name: Run PHP_CodeSniffer. - run: vendor/bin/phpcs -q --report=checkstyle framework/ | cs2pr + run: vendor/bin/phpcs -q --report=checkstyle framework/ tests/ build/ | cs2pr diff --git a/build/controllers/MimeTypeController.php b/build/controllers/MimeTypeController.php index 82a8164c0d..a16f160819 100644 --- a/build/controllers/MimeTypeController.php +++ b/build/controllers/MimeTypeController.php @@ -1,4 +1,5 @@ 'application/rtf', 'text/xml' => 'application/xml', 'image/svg' => 'image/svg+xml', @@ -48,7 +49,7 @@ class MimeTypeController extends Controller /** * @var array MIME types to add to the ones parsed from Apache files */ - private $additionalMimeTypes = [ + private $_additionalMimeTypes = [ 'apng' => 'image/apng', 'avif' => 'image/avif', 'jfif' => 'image/jpeg', @@ -107,7 +108,7 @@ class MimeTypeController extends Controller } } } - $mimeMap = array_replace($mimeMap, $this->additionalMimeTypes); + $mimeMap = array_replace($mimeMap, $this->_additionalMimeTypes); ksort($mimeMap, SORT_STRING); $array = VarDumper::export($mimeMap); @@ -145,7 +146,7 @@ EOD; private function generateMimeAliasesFile($outFile) { $this->stdout("generating file $outFile..."); - $array = VarDumper::export($this->aliases); + $array = VarDumper::export($this->_aliases); $content = <<additionalMimeTypes as $ext => $mime) { + foreach ($this->_additionalMimeTypes as $ext => $mime) { if (!array_key_exists($mime, $extensionMap)) { $extensionMap[$mime] = []; } diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index 47f71892f7..aa8cdfee98 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -1,4 +1,5 @@ setUpExtensionAliases($extensionPath); @@ -418,8 +419,12 @@ class PhpDocController extends ConsoleController $types = explode('|', $matches[2]); foreach ($types as $i => $type) { switch ($type) { - case 'integer': $types[$i] = 'int'; break; - case 'boolean': $types[$i] = 'bool'; break; + case 'integer': + $types[$i] = 'int'; + break; + case 'boolean': + $types[$i] = 'bool'; + break; } } @@ -525,13 +530,15 @@ class PhpDocController extends ConsoleController } } -// $this->checkPropertyOrder($lineInfo); + // $this->checkPropertyOrder($lineInfo); $result = []; foreach ($lines as $i => $line) { $result[] = $line; if (!($propertiesOnly && $i === $endofAll)) { - if ($i === $endofUse || $i === $endofConst || $i === $endofPublic || - $i === $endofProtected || $i === $endofPrivate) { + if ( + $i === $endofUse || $i === $endofConst || $i === $endofPublic || + $i === $endofProtected || $i === $endofPrivate + ) { $result[] = ''; } if ($i === $endofAll) { @@ -820,8 +827,8 @@ class PhpDocController extends ConsoleController if (isset($prop['get'], $prop['set'])) { if ($prop['get']['type'] !== $prop['set']['type']) { $note = ' Note that the type of this property differs in getter and setter.' - . ' See [[get' . ucfirst($propName) . '()]]' - . ' and [[set' . ucfirst($propName) . '()]] for details.'; + . ' See [[get' . ucfirst($propName) . '()]]' + . ' and [[set' . ucfirst($propName) . '()]] for details.'; } } elseif (isset($prop['get'])) { if (!$this->hasSetterInParents($className, $propName)) { diff --git a/build/controllers/ReleaseController.php b/build/controllers/ReleaseController.php index e15aa14d18..6479b7df82 100644 --- a/build/controllers/ReleaseController.php +++ b/build/controllers/ReleaseController.php @@ -1,4 +1,5 @@ composerSetStability($what, $version); -// $this->resortChangelogs($what, $version); - // $this->closeChangelogs($what, $version); - // $this->composerSetStability($what, $version); - // if (in_array('framework', $what)) { - // $this->updateYiiVersion($version); - // } + // $this->resortChangelogs($what, $version); + // $this->closeChangelogs($what, $version); + // $this->composerSetStability($what, $version); + // if (in_array('framework', $what)) { + // $this->updateYiiVersion($version); + // } // if done: // * ./build/build release/done framework 2.0.0-dev 2.0.0-rc // * ./build/build release/done redis 2.0.0-dev 2.0.0-rc -// $this->openChangelogs($what, $nextVersion); -// $this->composerSetStability($what, 'dev'); -// if (in_array('framework', $what)) { -// $this->updateYiiVersion($devVersion); -// } + // $this->openChangelogs($what, $nextVersion); + // $this->composerSetStability($what, 'dev'); + // if (in_array('framework', $what)) { + // $this->updateYiiVersion($devVersion); + // } @@ -875,8 +876,10 @@ class ReleaseController extends Controller $state = 'start'; foreach ($lines as $l => $line) { // starting from the changelogs headline - if (isset($lines[$l - 2]) && strpos($lines[$l - 2], $version) !== false && - isset($lines[$l - 1]) && strncmp($lines[$l - 1], '---', 3) === 0) { + if ( + isset($lines[$l - 2]) && strpos($lines[$l - 2], $version) !== false && + isset($lines[$l - 1]) && strncmp($lines[$l - 1], '---', 3) === 0 + ) { $state = 'changelog'; } if ($state === 'changelog' && isset($lines[$l + 1]) && strncmp($lines[$l + 1], '---', 3) === 0) { @@ -992,7 +995,8 @@ class ReleaseController extends Controller $this->sed( '/function getVersion\(\)\R {4}\{\R {8}return \'(.+?)\';/', "function getVersion()\n {\n return '$version';", - $frameworkPath . '/BaseYii.php'); + $frameworkPath . '/BaseYii.php' + ); } protected function sed($pattern, $replace, $files) @@ -1021,8 +1025,7 @@ class ReleaseController extends Controller rsort($tags, SORT_NATURAL); // TODO this can not deal with alpha/beta/rc... // exclude 3.0.0-alpha1 tag - if (($key = array_search('3.0.0-alpha1', $tags, true)) !== false) - { + if (($key = array_search('3.0.0-alpha1', $tags, true)) !== false) { unset($tags[$key]); } diff --git a/build/controllers/Utf8Controller.php b/build/controllers/Utf8Controller.php index e332461b12..7d159634a6 100644 --- a/build/controllers/Utf8Controller.php +++ b/build/controllers/Utf8Controller.php @@ -1,4 +1,5 @@ found('UNSUPPORTED SPACE CHARACTER', $c, $line, $pos, $file); continue; } - if ($ord < 0x0020 && $ord != 0x000A && $ord != 0x0009 || - 0x0080 <= $ord && $ord < 0x009F) { + if ( + $ord < 0x0020 && $ord != 0x000A && $ord != 0x0009 || + 0x0080 <= $ord && $ord < 0x009F + ) { $this->found('CONTROL CHARACTER', $c, $line, $pos, $file); continue; } -// if ($ord > 0x009F) { -// $this->found("NON ASCII CHARACTER", $c, $line, $pos, $file); -// continue; -// } + // if ($ord > 0x009F) { + // $this->found("NON ASCII CHARACTER", $c, $line, $pos, $file); + // continue; + // } } } } @@ -114,11 +118,11 @@ class Utf8Controller extends Controller return ($h & 0x1F) << 6 | (\ord($c[1]) & 0x3F); } elseif ($h <= 0xEF) { return ($h & 0x0F) << 12 | (\ord($c[1]) & 0x3F) << 6 - | (\ord($c[2]) & 0x3F); + | (\ord($c[2]) & 0x3F); } elseif ($h <= 0xF4) { return ($h & 0x0F) << 18 | (\ord($c[1]) & 0x3F) << 12 - | (\ord($c[2]) & 0x3F) << 6 - | (\ord($c[3]) & 0x3F); + | (\ord($c[2]) & 0x3F) << 6 + | (\ord($c[3]) & 0x3F); } return false; diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a11d2a0d33..5ff7758c04 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -2,6 +2,30 @@ + + + tests/* + + + + + tests/* + + + + + tests/* + + + + tests/bootstrap.php + tests/framework/web/UserTest.php + + + + tests/data/views/simple.php + + @@ -12,4 +36,6 @@ framework/views/* + tests/data/views/* + tests/js/* diff --git a/tests/TestCase.php b/tests/TestCase.php index 2036681ea5..c468454ba9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -187,7 +187,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase */ protected function sanitizeWhitespaces($string) { - return preg_replace("/[\pZ\pC]/u", " ", $string); + return preg_replace('/[\pZ\pC]/u', ' ', $string); } /** diff --git a/tests/data/ar/Cat.php b/tests/data/ar/Cat.php index 28002381c7..494294edea 100644 --- a/tests/data/ar/Cat.php +++ b/tests/data/ar/Cat.php @@ -48,6 +48,6 @@ class Cat extends Animal */ public function getThrowable() { - return 5/0; + return 5 / 0; } } diff --git a/tests/data/ar/Order.php b/tests/data/ar/Order.php index c2781d2c10..048f7ced6e 100644 --- a/tests/data/ar/Order.php +++ b/tests/data/ar/Order.php @@ -245,5 +245,4 @@ class Order extends ActiveRecord { return $this->hasOne(Customer::className(), ['id' => 'virtualCustomerId']); } - } diff --git a/tests/data/base/Singer.php b/tests/data/base/Singer.php index 649214cdcb..7f6d840000 100644 --- a/tests/data/base/Singer.php +++ b/tests/data/base/Singer.php @@ -32,7 +32,9 @@ class Singer extends Model [['lastName'], 'required'], [['lastName'], 'string', 'max' => 25], [['underscore_style'], 'yii\captcha\CaptchaValidator'], - [['test'], 'required', 'when' => function ($model) { return $model->firstName === 'cebe'; }], + [['test'], 'required', 'when' => function ($model) { + return $model->firstName === 'cebe'; + }], ]; } } diff --git a/tests/framework/ChangeLogTest.php b/tests/framework/ChangeLogTest.php index 3308b4049d..52bccb4c1b 100644 --- a/tests/framework/ChangeLogTest.php +++ b/tests/framework/ChangeLogTest.php @@ -20,13 +20,12 @@ class ChangeLogTest extends TestCase { public function changeProvider() { - - $lines = preg_split("~\R~", file_get_contents(__DIR__ . '/../../framework/CHANGELOG.md'), -1, PREG_SPLIT_NO_EMPTY); + $lines = preg_split('~\R~', file_get_contents(__DIR__ . '/../../framework/CHANGELOG.md'), -1, PREG_SPLIT_NO_EMPTY); // Don't check last 1500 lines, they are old and often don't obey the standard. $lastIndex = count($lines) - 1500; $result = []; - foreach($lines as $i => $line) { + foreach ($lines as $i => $line) { if (strncmp('- ', $line, 2) === 0) { $result[] = [$line]; } diff --git a/tests/framework/ar/ActiveRecordTestTrait.php b/tests/framework/ar/ActiveRecordTestTrait.php index 07f270afc7..f82db23a2e 100644 --- a/tests/framework/ar/ActiveRecordTestTrait.php +++ b/tests/framework/ar/ActiveRecordTestTrait.php @@ -1,4 +1,5 @@ assertEquals([1, 3, 2], $controller->result); } - public function actionFilterProvider() { return [ diff --git a/tests/framework/base/ComponentTest.php b/tests/framework/base/ComponentTest.php index eb7f05f66d..941619c7ca 100644 --- a/tests/framework/base/ComponentTest.php +++ b/tests/framework/base/ComponentTest.php @@ -492,7 +492,6 @@ class ComponentTest extends TestCase $obj->trigger('barEventOnce'); $this->assertEquals(1, $obj->foo); } - } class NewComponent extends Component diff --git a/tests/framework/base/ControllerTest.php b/tests/framework/base/ControllerTest.php index 686eef3b5f..ce97daf76b 100644 --- a/tests/framework/base/ControllerTest.php +++ b/tests/framework/base/ControllerTest.php @@ -127,17 +127,14 @@ class TestController extends Controller public function actionTest3() { - } public function actionTestTest() { - } public function actionTest_test() { - } } @@ -145,16 +142,13 @@ class Test1Controller extends Controller { public function actionTest_1() { - } public function actionTest_test() { - } public function actionTestTest_test_2() { - } } diff --git a/tests/framework/base/ErrorExceptionTest.php b/tests/framework/base/ErrorExceptionTest.php index 08de051034..b34bbe6314 100644 --- a/tests/framework/base/ErrorExceptionTest.php +++ b/tests/framework/base/ErrorExceptionTest.php @@ -40,7 +40,7 @@ class ErrorExceptionTest extends TestCase } try { throw new ErrorException(); - } catch (ErrorException $e){ + } catch (ErrorException $e) { $this->assertEquals(__FUNCTION__, $e->getTrace()[0]['function']); } } diff --git a/tests/framework/base/ExposedSecurity.php b/tests/framework/base/ExposedSecurity.php index 45d310445c..e384df5ac4 100644 --- a/tests/framework/base/ExposedSecurity.php +++ b/tests/framework/base/ExposedSecurity.php @@ -1,4 +1,5 @@ assertEquals('test/test-controller1/test1', Yii::$app->controller->action->uniqueId); } - public function testServiceLocatorTraversal(): void { $parent = new Module('parent'); @@ -232,6 +231,7 @@ class ModuleTestController extends Controller { ModuleTest::$actionRuns[] = $this->action->uniqueId; } + public function actionTest2(): void { ModuleTest::$actionRuns[] = $this->action->uniqueId; diff --git a/tests/framework/base/SecurityTest.php b/tests/framework/base/SecurityTest.php index c8b50b48a8..365ba6bae5 100644 --- a/tests/framework/base/SecurityTest.php +++ b/tests/framework/base/SecurityTest.php @@ -803,7 +803,6 @@ TEXT; $this->assertEquals($data, $this->security->decryptByPassword($encrypted, $password)); } - public function randomKeyInvalidInputs() { return [ @@ -1057,7 +1056,8 @@ TEXT; hex2bin((string)$ikm), hex2bin((string)$salt), hex2bin((string)$info), - $l); + $l + ); $this->assertEquals($okm, bin2hex($dk)); } diff --git a/tests/framework/base/ViewTest.php b/tests/framework/base/ViewTest.php index 7249a9b127..eed0b8abae 100644 --- a/tests/framework/base/ViewTest.php +++ b/tests/framework/base/ViewTest.php @@ -51,13 +51,17 @@ class ViewTest extends TestCase $view = new View(); $exceptionViewFile = $this->testViewPath . DIRECTORY_SEPARATOR . 'exception.php'; - file_put_contents($exceptionViewFile, <<<'PHP' + file_put_contents( + $exceptionViewFile, + <<<'PHP'

Exception

PHP -); + ); $normalViewFile = $this->testViewPath . DIRECTORY_SEPARATOR . 'no-exception.php'; - file_put_contents($normalViewFile, <<<'PHP' + file_put_contents( + $normalViewFile, + <<<'PHP'

No Exception

PHP ); @@ -82,7 +86,9 @@ PHP Yii::setAlias('@theme', $this->testViewPath . '/theme1'); $baseView = "{$this->testViewPath}/theme1/base.php"; - file_put_contents($baseView, <<<'PHP' + file_put_contents( + $baseView, + <<<'PHP' render("sub"); ?> @@ -90,7 +96,7 @@ PHP ); $subView = "{$this->testViewPath}/sub.php"; - $subViewContent = "subviewcontent"; + $subViewContent = 'subviewcontent'; file_put_contents($subView, $subViewContent); $view->theme = new Theme([ diff --git a/tests/framework/base/WidgetTest.php b/tests/framework/base/WidgetTest.php index fa236ca83f..70b1870eab 100644 --- a/tests/framework/base/WidgetTest.php +++ b/tests/framework/base/WidgetTest.php @@ -1,4 +1,5 @@ attachBehavior('bar', (new class () extends Behavior -{ +$obj->attachBehavior('bar', (new class () extends Behavior { public function events() { return [ diff --git a/tests/framework/base/stub/AnonymousModelClass.php b/tests/framework/base/stub/AnonymousModelClass.php index ec4aace8a9..b196289cfd 100644 --- a/tests/framework/base/stub/AnonymousModelClass.php +++ b/tests/framework/base/stub/AnonymousModelClass.php @@ -4,7 +4,5 @@ declare(strict_types=1); use yii\base\Model; -return new class() extends Model -{ - +return new class () extends Model { }; diff --git a/tests/framework/behaviors/OptimisticLockBehaviorTest.php b/tests/framework/behaviors/OptimisticLockBehaviorTest.php index 85b6e30a99..25ec3162a8 100644 --- a/tests/framework/behaviors/OptimisticLockBehaviorTest.php +++ b/tests/framework/behaviors/OptimisticLockBehaviorTest.php @@ -95,7 +95,6 @@ class OptimisticLockBehaviorTest extends TestCase $this->assertEquals(2, $model->version, 'updated version should equal 2'); } - public function testNewRecord(): void { // create a record without any version @@ -129,7 +128,6 @@ class OptimisticLockBehaviorTest extends TestCase $this->assertEquals(8, $model->version, 'init version should equal 8'); } - public function testUpdateRecord(): void { $request = new Request(); @@ -213,7 +211,7 @@ class OptimisticLockBehaviorTest extends TestCase $this->assertEquals(3, $model->version, 'updated version should equal 3'); } - public function testDeleteRecord(): void + public function testDeleteRecord(): void { $request = new Request(); Yii::$app->set('request', $request); diff --git a/tests/framework/behaviors/SluggableBehaviorTest.php b/tests/framework/behaviors/SluggableBehaviorTest.php index ad1444c447..2882cae734 100644 --- a/tests/framework/behaviors/SluggableBehaviorTest.php +++ b/tests/framework/behaviors/SluggableBehaviorTest.php @@ -1,4 +1,5 @@ save(); $model = new ActiveRecordSluggableUnique(); - $model->sluggable->uniqueSlugGenerator = function ($baseSlug, $iteration) {return $baseSlug . '-callback';}; + $model->sluggable->uniqueSlugGenerator = function ($baseSlug, $iteration) { + return $baseSlug . '-callback'; + }; $model->name = $name; $model->save(); diff --git a/tests/framework/behaviors/TimestampBehaviorTest.php b/tests/framework/behaviors/TimestampBehaviorTest.php index 8a64fcb90f..cf97023ded 100644 --- a/tests/framework/behaviors/TimestampBehaviorTest.php +++ b/tests/framework/behaviors/TimestampBehaviorTest.php @@ -1,4 +1,5 @@ buildKey([ "First example of invalid UTF-8 sequence: \xF5", - "Valid UTF-8 string", + 'Valid UTF-8 string', ]); $secondCacheKey = $cache->buildKey([ "Second example of invalid UTF-8 sequence: \xF6", - "Valid UTF-8 string", + 'Valid UTF-8 string', ]); $this->assertNotEquals($firstCacheKey, $secondCacheKey); diff --git a/tests/framework/caching/CacheTestCase.php b/tests/framework/caching/CacheTestCase.php index fc98fb57e0..1fce0a44fa 100644 --- a/tests/framework/caching/CacheTestCase.php +++ b/tests/framework/caching/CacheTestCase.php @@ -1,4 +1,5 @@ 'test']); $expected = 'SilverFire'; - $loginClosure = function ($cache) use (&$login) { return 'SilverFire'; }; + $loginClosure = function ($cache) use (&$login) { + return 'SilverFire'; + }; $this->assertEquals($expected, $cache->getOrSet('some-login', $loginClosure, null, $dependency)); // Call again with another login to make sure that value is cached - $loginClosure = function ($cache) use (&$login) { return 'SamDark'; }; + $loginClosure = function ($cache) use (&$login) { + return 'SamDark'; + }; $this->assertEquals($expected, $cache->getOrSet('some-login', $loginClosure, null, $dependency)); $dependency->invalidate($cache, 'test'); diff --git a/tests/framework/caching/DbCacheTest.php b/tests/framework/caching/DbCacheTest.php index 21d2723cb6..e05aa446aa 100644 --- a/tests/framework/caching/DbCacheTest.php +++ b/tests/framework/caching/DbCacheTest.php @@ -1,4 +1,5 @@ 'INT', 'data' => 'VARBINARY(MAX)', ])->execute(); - } /** diff --git a/tests/framework/caching/PgSQLCacheTest.php b/tests/framework/caching/PgSQLCacheTest.php index 45478537c4..d7bafa62cc 100644 --- a/tests/framework/caching/PgSQLCacheTest.php +++ b/tests/framework/caching/PgSQLCacheTest.php @@ -1,4 +1,5 @@ expectException('yii\console\Exception'); $this->expectExceptionMessage($message); $result = $controller->runAction('aksi3', $params); - } public function testNullableInjectedActionParams() @@ -132,7 +132,9 @@ class ControllerTest extends TestCase $injectionAction = new InlineAction('injection', $this->controller, 'actionInjection'); $params = ['between' => 'test', 'after' => 'another', 'before' => 'test']; - \Yii::$container->set(DummyService::className(), function() { throw new \RuntimeException('uh oh'); }); + \Yii::$container->set(DummyService::className(), function () { + throw new \RuntimeException('uh oh'); + }); $this->expectException(get_class(new RuntimeException())); $this->expectExceptionMessage('uh oh'); diff --git a/tests/framework/console/FakeController.php b/tests/framework/console/FakeController.php index cc268c4b18..670ab68076 100644 --- a/tests/framework/console/FakeController.php +++ b/tests/framework/console/FakeController.php @@ -1,4 +1,5 @@ configFileName; $out = $this->runMessageControllerAction('config', [$configFileName]); - $this->assertFileExists($configFileName, - "Unable to create config file from template. Command output:\n\n" . $out); + $this->assertFileExists( + $configFileName, + "Unable to create config file from template. Command output:\n\n" . $out + ); } public function testActionConfigSubDir() @@ -196,8 +199,10 @@ abstract class BaseMessageControllerTest extends TestCase $out = $this->runMessageControllerAction('extract', [$this->configFileName]); $out .= $this->runMessageControllerAction('extract', [$this->configFileName]); - $this->assertNotFalse(strpos($out, 'Nothing to save'), - "Controller should respond with \"Nothing to save\" if there's nothing to update. Command output:\n\n" . $out); + $this->assertNotFalse( + strpos($out, 'Nothing to save'), + "Controller should respond with \"Nothing to save\" if there's nothing to update. Command output:\n\n" . $out + ); } /** @@ -300,12 +305,16 @@ abstract class BaseMessageControllerTest extends TestCase $out = $this->runMessageControllerAction('extract', [$this->configFileName]); $messages = $this->loadMessages($category); - $this->assertSame($zeroMessageContent, + $this->assertSame( + $zeroMessageContent, $messages[$zeroMessage], - "Message content \"0\" is lost. Command output:\n\n" . $out); - $this->assertSame($falseMessageContent, + "Message content \"0\" is lost. Command output:\n\n" . $out + ); + $this->assertSame( + $falseMessageContent, $messages[$falseMessage], - "Message content \"false\" is lost. Command output:\n\n" . $out); + "Message content \"false\" is lost. Command output:\n\n" . $out + ); } /** @@ -484,8 +493,11 @@ abstract class BaseMessageControllerTest extends TestCase $out = $this->runMessageControllerAction('extract', [$this->configFileName]); $messages = $this->loadMessages($category); - $this->assertArrayHasKey($mainMessage, $messages, - "\"$mainMessage\" is missing in translation file. Command output:\n\n" . $out); + $this->assertArrayHasKey( + $mainMessage, + $messages, + "\"$mainMessage\" is missing in translation file. Command output:\n\n" . $out + ); } /** diff --git a/tests/framework/console/controllers/CacheControllerTest.php b/tests/framework/console/controllers/CacheControllerTest.php index 183d173d8e..a77d9d8334 100644 --- a/tests/framework/console/controllers/CacheControllerTest.php +++ b/tests/framework/console/controllers/CacheControllerTest.php @@ -1,4 +1,5 @@ expectException('yii\console\Exception'); $this->expectExceptionMessage('You should specify cache components names'); - + $this->_cacheController->actionFlush(); } diff --git a/tests/framework/console/controllers/DbMessageControllerTest.php b/tests/framework/console/controllers/DbMessageControllerTest.php index 4ecdbd1124..d685f3bad9 100644 --- a/tests/framework/console/controllers/DbMessageControllerTest.php +++ b/tests/framework/console/controllers/DbMessageControllerTest.php @@ -1,4 +1,5 @@ markTestSkipped('There\'s no need to order messages for database'); } - - } diff --git a/tests/framework/console/controllers/EchoMigrateController.php b/tests/framework/console/controllers/EchoMigrateController.php index 44faf4a5d4..2eefd60267 100644 --- a/tests/framework/console/controllers/EchoMigrateController.php +++ b/tests/framework/console/controllers/EchoMigrateController.php @@ -1,4 +1,5 @@ 'yiiunit\data\console\controllers', ]); $result = Console::stripAnsiFormat($this->runControllerAction('index')); - $this->assertStringNotContainsString("- fake-empty", $result); - $this->assertStringContainsString("- fake-no-default", $result); - $this->assertStringContainsString(" fake-no-default/index", $result); - $this->assertStringNotContainsString(" fake-no-default/index (default)", $result); + $this->assertStringNotContainsString('- fake-empty', $result); + $this->assertStringContainsString('- fake-no-default', $result); + $this->assertStringContainsString(' fake-no-default/index', $result); + $this->assertStringNotContainsString(' fake-no-default/index (default)', $result); } } diff --git a/tests/framework/console/controllers/MigrateControllerTest.php b/tests/framework/console/controllers/MigrateControllerTest.php index 8fdbce6e02..20f41abfe6 100644 --- a/tests/framework/console/controllers/MigrateControllerTest.php +++ b/tests/framework/console/controllers/MigrateControllerTest.php @@ -1,4 +1,5 @@ migrationExitCode; diff --git a/tests/framework/console/controllers/PHPMessageControllerTest.php b/tests/framework/console/controllers/PHPMessageControllerTest.php index f2d9c06fdb..f67d464296 100644 --- a/tests/framework/console/controllers/PHPMessageControllerTest.php +++ b/tests/framework/console/controllers/PHPMessageControllerTest.php @@ -1,4 +1,5 @@ assertEqualsWithoutLE($expected, $head); } - public function messageFileCategoriesDataProvider(){ + public function messageFileCategoriesDataProvider() + { return [ 'removeUnused:false - unused category should not be removed - normal category' => ['test_delete_category', true, false, true], 'removeUnused:false - unused category should not be removed - nested category' => ['nested/category', true, false, true], diff --git a/tests/framework/console/controllers/POMessageControllerTest.php b/tests/framework/console/controllers/POMessageControllerTest.php index 25d165406b..693f5340e7 100644 --- a/tests/framework/console/controllers/POMessageControllerTest.php +++ b/tests/framework/console/controllers/POMessageControllerTest.php @@ -1,4 +1,5 @@ assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - ['testcontent1', 'testcontent2', 'testcontent3'], - ['testcontent21', 'testcontent22', 'testcontent23'], - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + ['testcontent1', 'testcontent2', 'testcontent3'], + ['testcontent21', 'testcontent22', 'testcontent23'], + ])->setScreenWidth(200)->run() ); } @@ -225,11 +228,13 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - [['key1' => 'col1', 'key2' => 'col2'], 'testcontent2', 'testcontent3'], - ['testcontent21', 'testcontent22', ['col1', 'col2']], - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + [['key1' => 'col1', 'key2' => 'col2'], 'testcontent2', 'testcontent3'], + ['testcontent21', 'testcontent22', ['col1', 'col2']], + ])->setScreenWidth(200)->run() ); } @@ -249,11 +254,13 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - ['testcontent1', 'testcontent2', 'testcontent3'], - ['testcontent21', 'testcontent22', ['col1', 'col2']], - ])->setScreenWidth(200)->setListPrefix('* ')->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + ['testcontent1', 'testcontent2', 'testcontent3'], + ['testcontent21', 'testcontent22', ['col1', 'col2']], + ])->setScreenWidth(200)->setListPrefix('* ')->run() ); } @@ -274,15 +281,17 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - ['testcontent1', 'testcontent2', 'testcontent3'], - [ - 'testcontent21 with loooooooooooooooooooooooong content', - 'testcontent22 with loooooooooooooooooooooooong content', - ['col1 with loooooooooooooooooooooooong content', 'col2 with long content'] - ], - ])->setScreenWidth(100)->setListPrefix('-- ')->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + ['testcontent1', 'testcontent2', 'testcontent3'], + [ + 'testcontent21 with loooooooooooooooooooooooong content', + 'testcontent22 with loooooooooooooooooooooooong content', + ['col1 with loooooooooooooooooooooooong content', 'col2 with long content'] + ], + ])->setScreenWidth(100)->setListPrefix('-- ')->run() ); } @@ -301,17 +310,29 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - ['testcontent1', 'testcontent2', 'testcontent3'], - ['testcontent_21', 'testcontent__22', 'testcontent___23'], - ])->setChars([ - Table::CHAR_TOP => '+', Table::CHAR_TOP_MID => '*', Table::CHAR_TOP_LEFT => '*', - Table::CHAR_TOP_RIGHT => '*', Table::CHAR_BOTTOM => '+', Table::CHAR_BOTTOM_MID => '*', - Table::CHAR_BOTTOM_LEFT => '*', Table::CHAR_BOTTOM_RIGHT => '*', Table::CHAR_LEFT => '/', - Table::CHAR_LEFT_MID => '*', Table::CHAR_MID => '+', Table::CHAR_MID_MID => '*', - Table::CHAR_RIGHT => '/', Table::CHAR_RIGHT_MID => '*', Table::CHAR_MIDDLE => '/', - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + ['testcontent1', 'testcontent2', 'testcontent3'], + ['testcontent_21', 'testcontent__22', 'testcontent___23'], + ])->setChars([ + Table::CHAR_TOP => '+', + Table::CHAR_TOP_MID => '*', + Table::CHAR_TOP_LEFT => '*', + Table::CHAR_TOP_RIGHT => '*', + Table::CHAR_BOTTOM => '+', + Table::CHAR_BOTTOM_MID => '*', + Table::CHAR_BOTTOM_LEFT => '*', + Table::CHAR_BOTTOM_RIGHT => '*', + Table::CHAR_LEFT => '/', + Table::CHAR_LEFT_MID => '*', + Table::CHAR_MID => '+', + Table::CHAR_MID_MID => '*', + Table::CHAR_RIGHT => '/', + Table::CHAR_RIGHT_MID => '*', + Table::CHAR_MIDDLE => '/', + ])->setScreenWidth(200)->run() ); } @@ -362,14 +383,16 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - ['testcontent1', 'testcontent2'], - ['testcontent21', 'testcontent22', null], - ['testcontent31'], - ['testcontent41', null, 'testcontent43'], - [null, null, 'testcontent53'], - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + ['testcontent1', 'testcontent2'], + ['testcontent21', 'testcontent22', null], + ['testcontent31'], + ['testcontent41', null, 'testcontent43'], + [null, null, 'testcontent53'], + ])->setScreenWidth(200)->run() ); } @@ -388,11 +411,13 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([ - [null, null, null], - [], - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([ + [null, null, null], + [], + ])->setScreenWidth(200)->run() ); } @@ -409,10 +434,12 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setRows([ - ['testcontent1', 'testcontent2'], - ['testcontent21', 'testcontent22'] - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setRows([ + ['testcontent1', 'testcontent2'], + ['testcontent21', 'testcontent22'] + ])->setScreenWidth(200)->run() ); } @@ -427,8 +454,10 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', 'test3']) - ->setRows([])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', 'test3']) + ->setRows([])->setScreenWidth(200)->run() ); } @@ -505,9 +534,9 @@ EXPECTED; $columnWidths = $this->getInaccessibleProperty($table, 'columnWidths'); $this->assertArrayHasKey(1, $columnWidths); - $this->assertEquals(4+2, $columnWidths[1]); + $this->assertEquals(4 + 2, $columnWidths[1]); $this->assertArrayHasKey(2, $columnWidths); - $this->assertEquals(8+2, $columnWidths[2]); + $this->assertEquals(8 + 2, $columnWidths[2]); } public function testCalculateRowHeightShouldNotThrowDivisionByZeroException() @@ -659,15 +688,17 @@ EXPECTED; EXPECTED; - $this->assertEqualsWithoutLE($expected, $table->setHeaders(['test1', 'test2', Console::ansiFormat('test3', [Console::FG_RED])]) - ->setRows([ - [Console::ansiFormat('testcontent11', [Console::FG_BLUE]), Console::ansiFormat('testcontent12', [Console::FG_YELLOW]), 'testcontent13'], - ['testcontent21', 'testcontent22', [ - 'a', - Console::ansiFormat('b', [Console::FG_PURPLE]), - Console::ansiFormat('c', [Console::FG_GREEN]), - ]], - ])->setScreenWidth(200)->run() + $this->assertEqualsWithoutLE( + $expected, + $table->setHeaders(['test1', 'test2', Console::ansiFormat('test3', [Console::FG_RED])]) + ->setRows([ + [Console::ansiFormat('testcontent11', [Console::FG_BLUE]), Console::ansiFormat('testcontent12', [Console::FG_YELLOW]), 'testcontent13'], + ['testcontent21', 'testcontent22', [ + 'a', + Console::ansiFormat('b', [Console::FG_PURPLE]), + Console::ansiFormat('c', [Console::FG_GREEN]), + ]], + ])->setScreenWidth(200)->run() ); } } diff --git a/tests/framework/data/ActiveDataFilterTest.php b/tests/framework/data/ActiveDataFilterTest.php index a4763fd81a..f710d5b080 100644 --- a/tests/framework/data/ActiveDataFilterTest.php +++ b/tests/framework/data/ActiveDataFilterTest.php @@ -1,4 +1,5 @@ assertEquals(['alias' => 'old'], $result->from); } - use GetTablesAliasTestTrait; protected function createQuery() { return new ActiveQuery(null); diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index 5b2a15c461..e8107d9ad2 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -1,4 +1,5 @@ getOrderClass(); - $orderClass::find()->with('customer')->indexBy(function(Order $order) { + $orderClass::find()->with('customer')->indexBy(function (Order $order) { $this->assertTrue($order->isRelationPopulated('customer')); $this->assertNotEmpty($order->customer->id); @@ -2060,7 +2061,6 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertInstanceOf(Order::className(), $orderItem->custom); } - public function testRefresh_querySetAlias_findRecord() { $customer = new \yiiunit\data\ar\CustomerWithAlias(); @@ -2089,7 +2089,6 @@ abstract class ActiveRecordTest extends DatabaseTestCase { $cat = new Cat(); $this->assertFalse(isset($cat->throwable)); - } /** @@ -2228,7 +2227,9 @@ abstract class ActiveRecordTest extends DatabaseTestCase // Test eager loading relations as arrays. /** @var array $customers */ $customers = Customer::find()->asArray(true)->all(); - Customer::loadRelationsFor($customers, ['orders.items' => function ($query) { $query->asArray(false); }], true); + Customer::loadRelationsFor($customers, ['orders.items' => function ($query) { + $query->asArray(false); + }], true); foreach ($customers as $customer) { $this->assertTrue(isset($customer['orders'])); $this->assertTrue(is_array($customer['orders'])); @@ -2253,9 +2254,13 @@ abstract class ActiveRecordTest extends DatabaseTestCase // Test eager loading previously loaded relation (relation value should be replaced with a new value loaded from database). /** @var Customer $customer */ - $customer = Customer::find()->where(['id' => 2])->with(['orders' => function ($query) { $query->orderBy(['id' => SORT_ASC]); }])->one(); + $customer = Customer::find()->where(['id' => 2])->with(['orders' => function ($query) { + $query->orderBy(['id' => SORT_ASC]); + }])->one(); $this->assertTrue($customer->orders[0]->id < $customer->orders[1]->id, 'Related models should be sorted by ID in ascending order.'); - $customer->loadRelations(['orders' => function ($query) { $query->orderBy(['id' => SORT_DESC]); }]); + $customer->loadRelations(['orders' => function ($query) { + $query->orderBy(['id' => SORT_DESC]); + }]); $this->assertTrue($customer->orders[0]->id > $customer->orders[1]->id, 'Related models should be sorted by ID in descending order.'); } } diff --git a/tests/framework/db/AnyCaseValue.php b/tests/framework/db/AnyCaseValue.php index e347fc6b2a..394110706b 100644 --- a/tests/framework/db/AnyCaseValue.php +++ b/tests/framework/db/AnyCaseValue.php @@ -1,4 +1,5 @@ assertEquals(1, $command->execute()); $command = $db->createCommand('SELECT [[int_col]], [[char_col]], [[float_col]], [[blob_col]], [[numeric_col]], [[bool_col]] FROM {{type}}'); -// $command->prepare(); -// $command->pdoStatement->bindColumn('blob_col', $bc, \PDO::PARAM_LOB); + // $command->prepare(); + // $command->pdoStatement->bindColumn('blob_col', $bc, \PDO::PARAM_LOB); $row = $command->queryOne(); $this->assertEquals($intCol, $row['int_col']); $this->assertEquals($charCol, $row['char_col']); @@ -401,7 +402,7 @@ SQL; '{{%type}}', ['int_col'], [[new Expression(':qp1', [':qp1' => 42])]], // This example is completely useless. This feature of batchInsert is intended to be used with complex expression objects, such as JsonExpression. - 'expected' => "INSERT INTO `type` (`int_col`) VALUES (:qp1)", + 'expected' => 'INSERT INTO `type` (`int_col`) VALUES (:qp1)', 'expectedParams' => [':qp1' => 42] ], 'batchIsert empty rows represented by ArrayObject' => [ @@ -513,7 +514,8 @@ SQL; )->execute(); $query = new \yii\db\Query(); - $query->select([ + $query->select( + [ '{{customer}}.[[email]] as name', '[[name]] as email', '[[address]]', @@ -567,7 +569,8 @@ SQL; )->execute(); $query = new \yii\db\Query(); - $query->select([ + $query->select( + [ 'email' => '{{customer}}.[[email]]', 'address' => 'name', 'name' => 'address', @@ -1404,7 +1407,6 @@ SQL; public function testAutoRefreshTableSchema() { if ($this->driverName === 'sqlsrv') { - // related to https://github.com/yiisoft/yii2/pull/17364 $this->markTestSkipped('Should be fixed'); } @@ -1528,26 +1530,26 @@ SQL; public function testBindValuesSupportsDeprecatedPDOCastingFormat() { $db = $this->getConnection(); - $db->createCommand()->setSql("SELECT :p1")->bindValues([':p1' => [2, \PDO::PARAM_STR]]); + $db->createCommand()->setSql('SELECT :p1')->bindValues([':p1' => [2, \PDO::PARAM_STR]]); $this->assertTrue(true); } public function testBindValuesSupportsEnums() - { - if (version_compare(PHP_VERSION, '8.1.0') >= 0) { - $db = $this->getConnection(); - $command = $db->createCommand(); + { + if (version_compare(PHP_VERSION, '8.1.0') >= 0) { + $db = $this->getConnection(); + $command = $db->createCommand(); - $command->setSql('SELECT :p1')->bindValues([':p1' => enums\Status::Active]); - $this->assertSame('Active', $command->params[':p1']); + $command->setSql('SELECT :p1')->bindValues([':p1' => enums\Status::Active]); + $this->assertSame('Active', $command->params[':p1']); - $command->setSql('SELECT :p1')->bindValues([':p1' => enums\StatusTypeString::Active]); - $this->assertSame('active', $command->params[':p1']); + $command->setSql('SELECT :p1')->bindValues([':p1' => enums\StatusTypeString::Active]); + $this->assertSame('active', $command->params[':p1']); - $command->setSql('SELECT :p1')->bindValues([':p1' => enums\StatusTypeInt::Active]); - $this->assertSame(1, $command->params[':p1']); - } else { + $command->setSql('SELECT :p1')->bindValues([':p1' => enums\StatusTypeInt::Active]); + $this->assertSame(1, $command->params[':p1']); + } else { $this->markTestSkipped('Enums are not supported in PHP < 8.1'); } - } + } } diff --git a/tests/framework/db/CompareValue.php b/tests/framework/db/CompareValue.php index 41a690b34a..8d8f9c87eb 100644 --- a/tests/framework/db/CompareValue.php +++ b/tests/framework/db/CompareValue.php @@ -1,4 +1,5 @@ assertStringContainsString( 'SELECT * FROM qlog1 WHERE id=1 ORDER BY nonexistingcolumn;', - $e->getMessage(), 'Exception message should contain raw SQL query: ' . (string) $e, + $e->getMessage(), + 'Exception message should contain raw SQL query: ' . (string) $e, ); $thrown = true; } @@ -475,7 +477,6 @@ abstract class ConnectionTest extends DatabaseTestCase } } - /** * Test whether slave connection is recovered when call getSlavePdo(true) after close(). * diff --git a/tests/framework/db/DatabaseTestCase.php b/tests/framework/db/DatabaseTestCase.php index 66c143eb18..1d0d7d9347 100644 --- a/tests/framework/db/DatabaseTestCase.php +++ b/tests/framework/db/DatabaseTestCase.php @@ -1,4 +1,5 @@ driverName === null) { diff --git a/tests/framework/db/GetTablesAliasTestTrait.php b/tests/framework/db/GetTablesAliasTestTrait.php index a3a00a10ea..5b8f04fdad 100644 --- a/tests/framework/db/GetTablesAliasTestTrait.php +++ b/tests/framework/db/GetTablesAliasTestTrait.php @@ -1,4 +1,5 @@ columnTypes() as $item) { list($column, $builder, $expected) = $item; - if (!(strncmp($column, Schema::TYPE_PK, 2) === 0 || - strncmp($column, Schema::TYPE_UPK, 3) === 0 || - strncmp($column, Schema::TYPE_BIGPK, 5) === 0 || - strncmp($column, Schema::TYPE_UBIGPK, 6) === 0 || - strncmp(substr($column, -5), 'FIRST', 5) === 0 - )) { + if ( + !( + strncmp($column, Schema::TYPE_PK, 2) === 0 || + strncmp($column, Schema::TYPE_UPK, 3) === 0 || + strncmp($column, Schema::TYPE_BIGPK, 5) === 0 || + strncmp($column, Schema::TYPE_UBIGPK, 6) === 0 || + strncmp(substr($column, -5), 'FIRST', 5) === 0 + ) + ) { $columns['col' . ++$i] = str_replace('CHECK (value', 'CHECK ([[col' . $i . ']]', $column); } } @@ -1114,13 +1118,13 @@ abstract class QueryBuilderTest extends DatabaseTestCase // not [['not', 'name'], 'NOT (name)', []], - [['not', (new Query)->select('exists')->from('some_table')], 'NOT ((SELECT [[exists]] FROM [[some_table]]))', []], + [['not', (new Query())->select('exists')->from('some_table')], 'NOT ((SELECT [[exists]] FROM [[some_table]]))', []], // and [['and', 'id=1', 'id=2'], '(id=1) AND (id=2)', []], [['and', 'type=1', ['or', 'id=1', 'id=2']], '(type=1) AND ((id=1) OR (id=2))', []], [['and', 'id=1', new Expression('id=:qp0', [':qp0' => 2])], '(id=1) AND (id=:qp0)', [':qp0' => 2]], - [['and', ['expired' => false], (new Query)->select('count(*) > 1')->from('queue')], '([[expired]]=:qp0) AND ((SELECT count(*) > 1 FROM [[queue]]))', [':qp0' => false]], + [['and', ['expired' => false], (new Query())->select('count(*) > 1')->from('queue')], '([[expired]]=:qp0) AND ((SELECT count(*) > 1 FROM [[queue]]))', [':qp0' => false]], // or [['or', 'id=1', 'id=2'], '(id=1) OR (id=2)', []], @@ -1138,7 +1142,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase [new BetweenColumnsCondition('2018-02-11', 'NOT BETWEEN', 'NOW()', 'update_time'), ':qp0 NOT BETWEEN NOW() AND [[update_time]]', [':qp0' => '2018-02-11']], [new BetweenColumnsCondition(new Expression('NOW()'), 'BETWEEN', 'create_time', 'update_time'), 'NOW() BETWEEN [[create_time]] AND [[update_time]]', []], [new BetweenColumnsCondition(new Expression('NOW()'), 'NOT BETWEEN', 'create_time', 'update_time'), 'NOW() NOT BETWEEN [[create_time]] AND [[update_time]]', []], - [new BetweenColumnsCondition(new Expression('NOW()'), 'NOT BETWEEN', (new Query)->select('min_date')->from('some_table'), 'max_date'), 'NOW() NOT BETWEEN (SELECT [[min_date]] FROM [[some_table]]) AND [[max_date]]', []], + [new BetweenColumnsCondition(new Expression('NOW()'), 'NOT BETWEEN', (new Query())->select('min_date')->from('some_table'), 'max_date'), 'NOW() NOT BETWEEN (SELECT [[min_date]] FROM [[some_table]]) AND [[max_date]]', []], // in [['in', 'id', [1, 2, (new Query())->select('three')->from('digits')]], '[[id]] IN (:qp0, :qp1, (SELECT [[three]] FROM [[digits]]))', [':qp0' => 1, ':qp1' => 2]], @@ -1610,7 +1614,6 @@ abstract class QueryBuilderTest extends DatabaseTestCase $this->assertEquals($expectedQueryParams, $actualQueryParams); } - public function testBuildWhereExistsWithParameters() { $expectedQuerySql = $this->replaceQuotes( @@ -1768,7 +1771,8 @@ abstract class QueryBuilderTest extends DatabaseTestCase list($sql, $params) = $this->getQueryBuilder()->build($query); $expected = $this->replaceQuotes( 'SELECT [[t]].[[id]] AS [[ID]], [[gsm]].[[username]] AS [[GSM]], [[part]].[[Part]], [[t]].[[Part_Cost]] AS [[Part Cost]], st_x(location::geometry) AS [[lon]],' - . ' case t.Status_Id when 1 then \'Acknowledge\' when 2 then \'No Action\' else \'Unknown Action\' END as [[Next Action]] FROM [[tablename]]'); + . ' case t.Status_Id when 1 then \'Acknowledge\' when 2 then \'No Action\' else \'Unknown Action\' END as [[Next Action]] FROM [[tablename]]' + ); $this->assertEquals($expected, $sql); $this->assertEmpty($params); } @@ -2416,7 +2420,6 @@ abstract class QueryBuilderTest extends DatabaseTestCase $this->assertSame($expectedParams, $actualParams); } - public function testCommentColumn() { $qb = $this->getQueryBuilder(); @@ -2489,7 +2492,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase [new LikeCondition('name', 'or not like', [new Expression('CONCAT("test", name, "%")'), '\ab_c']), '[[name]] NOT LIKE CONCAT("test", name, "%") OR [[name]] NOT LIKE :qp0', [':qp0' => '%\\\ab\_c%']], // like with expression as columnName - [['like', new Expression('name'), 'teststring'], 'name LIKE :qp0', [':qp0' => "%teststring%"]], + [['like', new Expression('name'), 'teststring'], 'name LIKE :qp0', [':qp0' => '%teststring%']], ]; // adjust dbms specific escaping @@ -2537,7 +2540,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase ->andWhere(['in', 'id', ['1', '0']]); list($sql, $params) = $this->getQueryBuilder()->build($query); - $this->assertSame($this->replaceQuotes("SELECT * FROM [[admin_user]] WHERE [[id]] IN (:qp0, :qp1)"), $sql); + $this->assertSame($this->replaceQuotes('SELECT * FROM [[admin_user]] WHERE [[id]] IN (:qp0, :qp1)'), $sql); $this->assertSame([':qp0' => '1', ':qp1' => '0'], $params); } } diff --git a/tests/framework/db/QueryTest.php b/tests/framework/db/QueryTest.php index 515f70a485..fb4a08645f 100644 --- a/tests/framework/db/QueryTest.php +++ b/tests/framework/db/QueryTest.php @@ -1,4 +1,5 @@ assertInstanceOf('\yii\db\Expression', $query->from[0]); } - use GetTablesAliasTestTrait; - protected function createQuery() { return new Query(); @@ -416,7 +417,6 @@ abstract class QueryTest extends DatabaseTestCase $this->assertEquals(['user3' => 'user3', 'user2' => 'user2', 'user1' => 'user1'], $result); } - /** * Ensure no ambiguous column error occurs on indexBy with JOIN. * @@ -733,7 +733,6 @@ abstract class QueryTest extends DatabaseTestCase $this->assertEquals(null, $query->cache()->where(['id' => 3])->scalar($db), 'Null value should be cached.'); } - /** * checks that all needed properties copied from source to new query */ diff --git a/tests/framework/db/SchemaTest.php b/tests/framework/db/SchemaTest.php index d487b6421a..366f5c4170 100644 --- a/tests/framework/db/SchemaTest.php +++ b/tests/framework/db/SchemaTest.php @@ -1,4 +1,5 @@ quoteValue($table) . ", + 'TABLE', N" . $db->quoteValue($table) . ', DEFAULT, DEFAULT - )"; + )'; return $db->createCommand($sql)->queryAll(); } @@ -90,8 +91,8 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest N'MS_description', 'SCHEMA', N'dbo', 'TABLE', N" . $db->quoteValue($table) . ", - 'COLUMN', N" . $db->quoteValue($column) . " - )"; + 'COLUMN', N" . $db->quoteValue($column) . ' + )'; return $db->createCommand($sql)->queryAll(); } @@ -235,12 +236,12 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest public function testCommentColumn() { - $this->markTestSkipped("Testing the behavior, not sql generation anymore."); + $this->markTestSkipped('Testing the behavior, not sql generation anymore.'); } public function testCommentTable() { - $this->markTestSkipped("Testing the behavior, not sql generation anymore."); + $this->markTestSkipped('Testing the behavior, not sql generation anymore.'); } /** @@ -646,13 +647,13 @@ ALTER TABLE [foo1] ADD CONSTRAINT [UQ_foo1_bar] UNIQUE ([bar])"; $connection->createCommand($sql)->execute(); $schema = $connection->getTableSchema('[foo1]', true); - $this->assertEquals("varchar(255)", $schema->getColumn('bar')->dbType); + $this->assertEquals('varchar(255)', $schema->getColumn('bar')->dbType); $this->assertEquals(true, $schema->getColumn('bar')->allowNull); $sql = $connection->getQueryBuilder()->alterColumn('foo1', 'bar', $this->string(128)->notNull()); $connection->createCommand($sql)->execute(); $schema = $connection->getTableSchema('[foo1]', true); - $this->assertEquals("nvarchar(128)", $schema->getColumn('bar')->dbType); + $this->assertEquals('nvarchar(128)', $schema->getColumn('bar')->dbType); $this->assertEquals(false, $schema->getColumn('bar')->allowNull); } @@ -684,7 +685,7 @@ WHILE 1=1 BEGIN EXEC (N'ALTER TABLE ' + @tableName + ' DROP CONSTRAINT [' + @constraintName + ']') END ALTER TABLE [foo1] ADD CONSTRAINT [DF_foo1_bar] DEFAULT NULL FOR [bar]"; - $sql = $qb->alterColumn('foo1', 'bar', $this->integer()->null()->defaultValue(NULL)); + $sql = $qb->alterColumn('foo1', 'bar', $this->integer()->null()->defaultValue(null)); $this->assertEquals($expected, $sql); } @@ -727,7 +728,7 @@ ALTER TABLE [foo1] ADD CONSTRAINT [DF_foo1_bar] DEFAULT CAST(GETDATE() AS INT) F $sql = $connection->getQueryBuilder()->alterColumn('foo1', 'bar', $this->string(128)->null()->check('LEN(bar) > 5')); $connection->createCommand($sql)->execute(); $schema = $connection->getTableSchema('[foo1]', true); - $this->assertEquals("nvarchar(128)", $schema->getColumn('bar')->dbType); + $this->assertEquals('nvarchar(128)', $schema->getColumn('bar')->dbType); $this->assertEquals(true, $schema->getColumn('bar')->allowNull); $sql = "INSERT INTO [foo1]([bar]) values('abcdef')"; @@ -795,14 +796,14 @@ ALTER TABLE [foo1] DROP COLUMN [bar]"; { $connection = $this->getConnection(); - $sql = $connection->getQueryBuilder()->alterColumn('foo1', 'bar', $this->string(64)->defaultValue("")->check('LEN(bar) < 5')->unique()); + $sql = $connection->getQueryBuilder()->alterColumn('foo1', 'bar', $this->string(64)->defaultValue('')->check('LEN(bar) < 5')->unique()); $connection->createCommand($sql)->execute(); $sql = $connection->getQueryBuilder()->dropColumn('foo1', 'bar'); $this->assertEquals(0, $connection->createCommand($sql)->execute()); $schema = $connection->getTableSchema('[foo1]', true); - $this->assertEquals(NULL, $schema->getColumn('bar')); + $this->assertEquals(null, $schema->getColumn('bar')); } public function buildFromDataProvider() diff --git a/tests/framework/db/mssql/QueryCacheTest.php b/tests/framework/db/mssql/QueryCacheTest.php index b35c11fde1..78fcbb012e 100644 --- a/tests/framework/db/mssql/QueryCacheTest.php +++ b/tests/framework/db/mssql/QueryCacheTest.php @@ -1,4 +1,5 @@ true, ])->execute(); - $function = function($db) use ($key){ + $function = function ($db) use ($key) { return (new Query()) ->select(['blob_col']) ->from('type') diff --git a/tests/framework/db/mssql/QueryTest.php b/tests/framework/db/mssql/QueryTest.php index c4df28000d..3f4de9b733 100644 --- a/tests/framework/db/mssql/QueryTest.php +++ b/tests/framework/db/mssql/QueryTest.php @@ -1,4 +1,5 @@ json(), - "json", + 'json', ]; } @@ -126,7 +127,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest * @link https://github.com/yiisoft/yii2/issues/14367 */ $mysqlVersion = $this->getDb()->getSlavePdo(true)->getAttribute(\PDO::ATTR_SERVER_VERSION); - $supportsFractionalSeconds = version_compare($mysqlVersion,'5.6.4', '>='); + $supportsFractionalSeconds = version_compare($mysqlVersion, '5.6.4', '>='); if ($supportsFractionalSeconds) { $expectedValues = [ 'datetime(0) NOT NULL', @@ -150,7 +151,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest if (in_array('NO_ZERO_DATE', $sqlModes, true)) { $this->markTestIncomplete( "MySQL doesn't allow the 'TIMESTAMP' column definition when the NO_ZERO_DATE mode enabled. " . - "This definition test was skipped." + 'This definition test was skipped.' ); } else { $columns[] = [ @@ -307,7 +308,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest ], 'nested and combined json expression' => [ ['=', 'jsoncol', new JsonExpression(new JsonExpression(['a' => 1, 'b' => 2, 'd' => new JsonExpression(['e' => 3])]))], - "[[jsoncol]] = :qp0", [':qp0' => '{"a":1,"b":2,"d":{"e":3}}'] + '[[jsoncol]] = :qp0', [':qp0' => '{"a":1,"b":2,"d":{"e":3}}'] ], 'search by property in JSON column (issue #15838)' => [ ['=', new Expression("(jsoncol->>'$.someKey')"), '42'], @@ -380,7 +381,7 @@ MySqlStatement; // int value should not be converted to string, when column is `bigint unsigned` $sql = $command->insert('{{type}}', ['bigint_col' => 22])->getRawSql(); - $this->assertEquals("INSERT INTO `type` (`bigint_col`) VALUES (22)", $sql); + $this->assertEquals('INSERT INTO `type` (`bigint_col`) VALUES (22)', $sql); // string value should not be converted $sql = $command->insert('{{type}}', ['bigint_col' => '1000000000000'])->getRawSql(); @@ -397,10 +398,10 @@ MySqlStatement; // primary key columns should have NULL as value $sql = $command->insert('null_values', [])->getRawSql(); - $this->assertEquals("INSERT INTO `null_values` (`id`) VALUES (NULL)", $sql); + $this->assertEquals('INSERT INTO `null_values` (`id`) VALUES (NULL)', $sql); // non-primary key columns should have DEFAULT as value $sql = $command->insert('negative_default_values', [])->getRawSql(); - $this->assertEquals("INSERT INTO `negative_default_values` (`tinyint_col`) VALUES (DEFAULT)", $sql); + $this->assertEquals('INSERT INTO `negative_default_values` (`tinyint_col`) VALUES (DEFAULT)', $sql); } } diff --git a/tests/framework/db/mysql/QueryTest.php b/tests/framework/db/mysql/QueryTest.php index 8d4847d667..30d2adc1a8 100644 --- a/tests/framework/db/mysql/QueryTest.php +++ b/tests/framework/db/mysql/QueryTest.php @@ -1,4 +1,5 @@ invokeMethod($schema, 'loadColumnSchema', [[ 'field' => 'emulated_MariaDB_field', 'type' => 'timestamp', - 'collation' => NULL, + 'collation' => null, 'null' => 'NO', 'key' => '', 'default' => 'current_timestamp()', @@ -240,17 +241,17 @@ SQL; $column = $this->invokeMethod($schema, 'loadColumnSchema', [[ 'field' => 'emulated_MariaDB_field', 'type' => 'timestamp', - 'collation' => NULL, + 'collation' => null, 'null' => 'NO', 'key' => '', - 'default' => NULL, + 'default' => null, 'extra' => '', 'privileges' => 'select,insert,update,references', 'comment' => '', ]]); $this->assertInstanceOf(ColumnSchema::className(), $column); - $this->assertEquals(NULL, $column->defaultValue); + $this->assertEquals(null, $column->defaultValue); } public function getExpectedColumns() diff --git a/tests/framework/db/mysql/UniqueValidatorTest.php b/tests/framework/db/mysql/UniqueValidatorTest.php index c6a3146bb2..dc8572220f 100644 --- a/tests/framework/db/mysql/UniqueValidatorTest.php +++ b/tests/framework/db/mysql/UniqueValidatorTest.php @@ -1,4 +1,5 @@ log('child 2: cannot install signal handler'); return 1; } diff --git a/tests/framework/db/mysql/type/JsonTest.php b/tests/framework/db/mysql/type/JsonTest.php index b955c7221c..4709132f2d 100644 --- a/tests/framework/db/mysql/type/JsonTest.php +++ b/tests/framework/db/mysql/type/JsonTest.php @@ -1,4 +1,5 @@ assertEquals('user2', $command->bindValue(':id', 2)->queryScalar()); }, 10); - $db->enableQueryCache =false; + $db->enableQueryCache = false; $db->cache(function (Connection $db) use ($update) { $command = $db->createCommand('SELECT [[name]] FROM {{customer}} WHERE [[id]] = :id'); @@ -289,7 +290,6 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertEquals('1', $data[0]['bool_col']); $this->assertIsOneOf($data[1]['bool_col'], ['0', false]); $this->assertIsOneOf($data[2]['bool_col'], ['0', false]); - } catch (\Exception $e) { setlocale(LC_NUMERIC, $locale); throw $e; @@ -339,9 +339,9 @@ class CommandTest extends \yiiunit\framework\db\CommandTest { $db = $this->getConnection(); - if ($db->getSchema()->getTableSchema("testCreateTable") !== null) { - $db->createCommand("DROP SEQUENCE testCreateTable_SEQ")->execute(); - $db->createCommand()->dropTable("testCreateTable")->execute(); + if ($db->getSchema()->getTableSchema('testCreateTable') !== null) { + $db->createCommand('DROP SEQUENCE testCreateTable_SEQ')->execute(); + $db->createCommand()->dropTable('testCreateTable')->execute(); } $db->createCommand()->createTable( @@ -404,7 +404,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $db = $this->getConnection(); if ($db->getSchema()->getTableSchema('testAlterTable') !== null) { - $db->createCommand("DROP SEQUENCE testAlterTable_SEQ")->execute(); + $db->createCommand('DROP SEQUENCE testAlterTable_SEQ')->execute(); $db->createCommand()->dropTable('testAlterTable')->execute(); } @@ -453,7 +453,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest } if ($db->getSchema()->getTableSchema('testCreateViewTable')) { - $db->createCommand("DROP SEQUENCE testCreateViewTable_SEQ")->execute(); + $db->createCommand('DROP SEQUENCE testCreateViewTable_SEQ')->execute(); $db->createCommand()->dropTable('testCreateViewTable')->execute(); } diff --git a/tests/framework/db/oci/ConnectionTest.php b/tests/framework/db/oci/ConnectionTest.php index 76992cce91..2edf3b0432 100644 --- a/tests/framework/db/oci/ConnectionTest.php +++ b/tests/framework/db/oci/ConnectionTest.php @@ -1,4 +1,5 @@ assertIsOneOf($actualParams, $expectedParams); } } - } diff --git a/tests/framework/db/oci/QueryTest.php b/tests/framework/db/oci/QueryTest.php index fa583ae42e..292a7a1921 100644 --- a/tests/framework/db/oci/QueryTest.php +++ b/tests/framework/db/oci/QueryTest.php @@ -1,4 +1,5 @@ getConnection(); $command = $db->createCommand(); - $command->batchInsert('bool_values', - ['bool_col'], [ + $command->batchInsert( + 'bool_values', + ['bool_col'], + [ [true], [false], ] diff --git a/tests/framework/db/pgsql/ArrayParserTest.php b/tests/framework/db/pgsql/ArrayParserTest.php index fdea8c9b20..a58237ab4b 100644 --- a/tests/framework/db/pgsql/ArrayParserTest.php +++ b/tests/framework/db/pgsql/ArrayParserTest.php @@ -27,7 +27,7 @@ class ArrayParserTest extends TestCase ['{,,}', [null, null, null]], ['{1,2,}', ['1','2',null]], ['{{},,1}', [[], null, '1']], - ['{"{\"key\":\"value\"}",NULL,"NULL","{}"}', ['{"key":"value"}', null, "NULL", '{}']], + ['{"{\"key\":\"value\"}",NULL,"NULL","{}"}', ['{"key":"value"}', null, 'NULL', '{}']], ['{boo,",",,test}', ['boo', ',', null, 'test']], ['{"string1","str\\\\in\\"g2","str,ing3"}', ['string1','str\\in"g2','str,ing3']], ['{{1,2,3},{4,5,6},{7,8,9}}', [['1','2','3'], ['4','5','6'], ['7','8','9']]], diff --git a/tests/framework/db/pgsql/BatchQueryResultTest.php b/tests/framework/db/pgsql/BatchQueryResultTest.php index f479637139..690b84aa5c 100644 --- a/tests/framework/db/pgsql/BatchQueryResultTest.php +++ b/tests/framework/db/pgsql/BatchQueryResultTest.php @@ -1,4 +1,5 @@ getConnection(); $command = $db->createCommand(); - $command->batchInsert('bool_values', - ['bool_col'], [ + $command->batchInsert( + 'bool_values', + ['bool_col'], + [ [true], [false], ] @@ -164,7 +167,8 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertSame(1, $inserted); - $found = $db->createCommand(<<createCommand( + << '{"Some not existing key": "random value"}' @@ -172,7 +176,8 @@ PGSQL )->execute(); $this->assertSame(0, $found); - $found = $db->createCommand(<<createCommand( + << '{"Solution date": "13.01.2011"}' diff --git a/tests/framework/db/pgsql/ConnectionTest.php b/tests/framework/db/pgsql/ConnectionTest.php index c3a6d0c68e..a7fb939a36 100644 --- a/tests/framework/db/pgsql/ConnectionTest.php +++ b/tests/framework/db/pgsql/ConnectionTest.php @@ -1,4 +1,5 @@ json(), - "jsonb", + 'jsonb', ], ]; @@ -273,7 +274,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest $config = $this->database; unset($config['fixture']); - $this->prepareDatabase($config, realpath(__DIR__.'/../../../data') . '/postgres12.sql'); + $this->prepareDatabase($config, realpath(__DIR__ . '/../../../data') . '/postgres12.sql'); $qb = $this->getQueryBuilder(false); diff --git a/tests/framework/db/pgsql/QueryTest.php b/tests/framework/db/pgsql/QueryTest.php index 2fe80782d4..df8d370840 100644 --- a/tests/framework/db/pgsql/QueryTest.php +++ b/tests/framework/db/pgsql/QueryTest.php @@ -1,4 +1,5 @@ getConnection(); $command = $db->createCommand(); - $command->batchInsert('bool_values', - ['bool_col'], [ + $command->batchInsert( + 'bool_values', + ['bool_col'], + [ [true], [false], ] diff --git a/tests/framework/db/pgsql/SchemaTest.php b/tests/framework/db/pgsql/SchemaTest.php index 89dfbfb8b3..66e7c5e84e 100644 --- a/tests/framework/db/pgsql/SchemaTest.php +++ b/tests/framework/db/pgsql/SchemaTest.php @@ -1,4 +1,5 @@ null, 'precision' => null, 'scale' => null, - 'defaultValue' => ["a" => 1], + 'defaultValue' => ['a' => 1], 'dimension' => 0 ]; $columns['jsonb_col'] = [ @@ -217,7 +218,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $connection->schema->refreshTableSchema('item'); $this->assertEquals('item_id_seq_2', $connection->schema->getTableSchema('item')->sequenceName); - $connection->createCommand('ALTER TABLE "item" ALTER COLUMN "id" SET DEFAULT nextval(\'' . $sequenceName . '\')')->execute(); + $connection->createCommand('ALTER TABLE "item" ALTER COLUMN "id" SET DEFAULT nextval(\'' . $sequenceName . '\')')->execute(); $connection->schema->refreshTableSchema('item'); $this->assertEquals($sequenceName, $connection->schema->getTableSchema('item')->sequenceName); } @@ -230,7 +231,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $config = $this->database; unset($config['fixture']); - $this->prepareDatabase($config, realpath(__DIR__.'/../../../data') . '/postgres12.sql'); + $this->prepareDatabase($config, realpath(__DIR__ . '/../../../data') . '/postgres12.sql'); $table = $this->getConnection(false)->schema->getTableSchema('generated'); $this->assertTrue($table->getColumn('id_always')->autoIncrement); @@ -247,7 +248,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $config = $this->database; unset($config['fixture']); - $this->prepareDatabase($config, realpath(__DIR__.'/../../../data') . '/postgres10.sql'); + $this->prepareDatabase($config, realpath(__DIR__ . '/../../../data') . '/postgres10.sql'); $this->assertNotNull($this->getConnection(false)->schema->getTableSchema('partitioned')); } diff --git a/tests/framework/db/pgsql/UniqueValidatorTest.php b/tests/framework/db/pgsql/UniqueValidatorTest.php index c94138a6dd..df4817872d 100644 --- a/tests/framework/db/pgsql/UniqueValidatorTest.php +++ b/tests/framework/db/pgsql/UniqueValidatorTest.php @@ -1,4 +1,5 @@ name = 'Angela'; $attribute = 'name'; diff --git a/tests/framework/db/pgsql/type/BooleanTest.php b/tests/framework/db/pgsql/type/BooleanTest.php index 4a9b21df24..6d7e600f11 100644 --- a/tests/framework/db/pgsql/type/BooleanTest.php +++ b/tests/framework/db/pgsql/type/BooleanTest.php @@ -1,4 +1,5 @@ assertInstanceOf(TestSubclass::className(), $app->get('test')); } - public function testShared() { // with configuration: shared diff --git a/tests/framework/di/stubs/Bar.php b/tests/framework/di/stubs/Bar.php index 193f144302..c817e95d76 100644 --- a/tests/framework/di/stubs/Bar.php +++ b/tests/framework/di/stubs/Bar.php @@ -1,4 +1,5 @@ 'user2'], null], // user2 is author, can only edit own posts - ['update', true, 'user2', function () { return ['authorID' => 'user2']; }, true], - ['update', true, 'user2', function () { return ['authorID' => 'user1']; }, null], + [ + 'update', + true, + 'user2', + function () { + return ['authorID' => 'user2']; + }, + true, + ], + [ + 'update', + true, + 'user2', + function () { + return ['authorID' => 'user1']; + }, + null, + ], // user1 is admin, can update all posts - ['update', true, 'user1', function () { return ['authorID' => 'user1']; }, true], - ['update', true, 'user1', function () { return ['authorID' => 'user2']; }, true], + [ + 'update', + true, + 'user1', + function () { + return ['authorID' => 'user1']; + }, + true, + ], + [ + 'update', + true, + 'user1', + function () { + return ['authorID' => 'user2']; + }, + true, + ], // unknown user can not edit anything - ['update', true, 'unknown', function () { return ['authorID' => 'user1']; }, null], - ['update', true, 'unknown', function () { return ['authorID' => 'user2']; }, null], + [ + 'update', + true, + 'unknown', + function () { + return ['authorID' => 'user1']; + }, + null, + ], + [ + 'update', + true, + 'unknown', + function () { + return ['authorID' => 'user2']; + }, + null, + ], ]; } diff --git a/tests/framework/filters/AjaxFilterTest.php b/tests/framework/filters/AjaxFilterTest.php index c101f0c4f2..b15efe59d6 100644 --- a/tests/framework/filters/AjaxFilterTest.php +++ b/tests/framework/filters/AjaxFilterTest.php @@ -1,4 +1,5 @@ mockWebApplication(); @@ -64,7 +64,8 @@ class CorsTest extends TestCase $this->assertEquals('*', $cors->response->getHeaders()->get('access-control-allow-origin')); } - public function testAccessControlAllowHeadersPreflight() { + public function testAccessControlAllowHeadersPreflight() + { $this->mockWebApplication(); $controller = new Controller('id', Yii::$app); $action = new Action('test', $controller); @@ -82,6 +83,4 @@ class CorsTest extends TestCase $this->assertTrue($cors->beforeAction($action)); $this->assertEquals('authorization, X-Requested-With, content-type, custom_header', $cors->response->getHeaders()->get('Access-Control-Allow-Headers')); } - - } diff --git a/tests/framework/filters/HostControlTest.php b/tests/framework/filters/HostControlTest.php index 4f5a32eb8b..9ae7a8207a 100644 --- a/tests/framework/filters/HostControlTest.php +++ b/tests/framework/filters/HostControlTest.php @@ -1,4 +1,5 @@ allowedHosts = ['example.com']; $filter->fallbackHostInfo = 'http://yiiframework.com'; - $filter->denyCallback = function () {}; + $filter->denyCallback = function () { + }; $controller = new Controller('test', Yii::$app); $action = new Action('test', $controller); diff --git a/tests/framework/filters/HttpCacheTest.php b/tests/framework/filters/HttpCacheTest.php index da0526c9fb..20a235be49 100644 --- a/tests/framework/filters/HttpCacheTest.php +++ b/tests/framework/filters/HttpCacheTest.php @@ -1,4 +1,5 @@ invokeMethod(new PageCache([ - 'variations' => function() { + 'variations' => function () { return [ 'foobar' ]; @@ -486,7 +487,7 @@ class PageCacheTest extends TestCase // test type cast of string $keys = $this->invokeMethod(new PageCache([ - 'variations' => function() { + 'variations' => function () { return 'foobarstring'; } ]), 'calculateCacheKey'); diff --git a/tests/framework/filters/RateLimiterTest.php b/tests/framework/filters/RateLimiterTest.php index b0a95051f4..47c7e6eead 100644 --- a/tests/framework/filters/RateLimiterTest.php +++ b/tests/framework/filters/RateLimiterTest.php @@ -1,4 +1,5 @@ mockWebApplication(); } + protected function tearDown(): void { parent::tearDown(); @@ -156,7 +158,7 @@ class RateLimiterTest extends TestCase public function testUserWithClosureFunction() { $rateLimiter = new RateLimiter(); - $rateLimiter->user = function($action) { + $rateLimiter->user = function ($action) { return new User(['identityClass' => RateLimit::className()]); }; $rateLimiter->beforeAction('test'); diff --git a/tests/framework/filters/auth/AuthMethodTest.php b/tests/framework/filters/auth/AuthMethodTest.php index 8682a336e3..7c8e32cf81 100644 --- a/tests/framework/filters/auth/AuthMethodTest.php +++ b/tests/framework/filters/auth/AuthMethodTest.php @@ -1,4 +1,5 @@ createAction(); - $filter = $this->createFilter(function () {return new \stdClass();}); + $filter = $this->createFilter(function () { + return new \stdClass(); + }); $this->assertTrue($filter->beforeAction($action)); - $filter = $this->createFilter(function () {return null;}); + $filter = $this->createFilter(function () { + return null; + }); $this->expectException('yii\web\UnauthorizedHttpException'); $this->assertTrue($filter->beforeAction($action)); } @@ -80,7 +85,9 @@ class AuthMethodTest extends TestCase $method->setAccessible(true); } - $filter = $this->createFilter(function () {return new \stdClass();}); + $filter = $this->createFilter(function () { + return new \stdClass(); + }); $filter->optional = ['some']; $this->assertFalse($method->invokeArgs($filter, [$this->createAction(['id' => 'index'])])); diff --git a/tests/framework/filters/auth/AuthTest.php b/tests/framework/filters/auth/AuthTest.php index 50085223aa..b5498d87bb 100644 --- a/tests/framework/filters/auth/AuthTest.php +++ b/tests/framework/filters/auth/AuthTest.php @@ -1,4 +1,5 @@ request->headers->set('Authorization', "Bearer wrong_token"); + Yii::$app->request->headers->set('Authorization', 'Bearer wrong_token'); $filter = ['class' => HttpBearerAuth::className()]; $controller = Yii::$app->createController('test-auth')[0]; $controller->authenticatorConfig = ArrayHelper::merge($filter, ['only' => ['filtered']]); diff --git a/tests/framework/filters/auth/BasicAuthTest.php b/tests/framework/filters/auth/BasicAuthTest.php index 9de3a52321..7f0967c029 100644 --- a/tests/framework/filters/auth/BasicAuthTest.php +++ b/tests/framework/filters/auth/BasicAuthTest.php @@ -1,4 +1,5 @@ visibleButtons = [ - 'update' => function ($model, $key, $index) {return $model['id'] == 1;}, + 'update' => function ($model, $key, $index) { + return $model['id'] == 1; + }, ]; $columnContents = $column->renderDataCell(['id' => 1], 1, 0); $this->assertStringContainsString('update_button', $columnContents); @@ -95,7 +98,9 @@ class ActionColumnTest extends \yiiunit\TestCase //test invisible button (condition is callback) $column->visibleButtons = [ - 'update' => function ($model, $key, $index) {return $model['id'] != 1;}, + 'update' => function ($model, $key, $index) { + return $model['id'] != 1; + }, ]; $columnContents = $column->renderDataCell(['id' => 1], 1, 0); $this->assertStringNotContainsString('update_button', $columnContents); diff --git a/tests/framework/grid/CheckboxColumnTest.php b/tests/framework/grid/CheckboxColumnTest.php index b652ff2dc6..070d08cb9b 100644 --- a/tests/framework/grid/CheckboxColumnTest.php +++ b/tests/framework/grid/CheckboxColumnTest.php @@ -1,4 +1,5 @@ $this->getGrid(), ]); - $this->assertStringContainsString('', $column->renderDataCell([], 1, 0));; + $this->assertStringContainsString('', $column->renderDataCell([], 1, 0)); $column = new CheckboxColumn([ 'content' => function ($model, $key, $index, $column) { diff --git a/tests/framework/grid/DataColumnTest.php b/tests/framework/grid/DataColumnTest.php index a58819c8d4..5fe977d805 100644 --- a/tests/framework/grid/DataColumnTest.php +++ b/tests/framework/grid/DataColumnTest.php @@ -1,4 +1,5 @@ assertEquals($this->invokeMethod($dataColumn, 'renderFilterCellContent'), $filterInput); } - /** * @see DataColumn::$filter * @see DataColumn::renderFilterCellContent() @@ -165,14 +165,16 @@ class DataColumnTest extends \yiiunit\TestCase $dataColumn = $grid->columns[0]; - $this->assertEqualsWithoutLE(<<<'HTML' + $this->assertEqualsWithoutLE( + <<<'HTML' HTML - , $this->invokeMethod($dataColumn, 'renderFilterCellContent'), + , + $this->invokeMethod($dataColumn, 'renderFilterCellContent'), ); } @@ -213,14 +215,16 @@ HTML $dataColumn = $grid->columns[0]; - $this->assertEqualsWithoutLE(<<<'HTML' + $this->assertEqualsWithoutLE( + <<<'HTML' HTML - , $this->invokeMethod($dataColumn, 'renderFilterCellContent'), + , + $this->invokeMethod($dataColumn, 'renderFilterCellContent'), ); } diff --git a/tests/framework/grid/GridViewTest.php b/tests/framework/grid/GridViewTest.php index cdf63756c8..e9ab08045e 100644 --- a/tests/framework/grid/GridViewTest.php +++ b/tests/framework/grid/GridViewTest.php @@ -1,4 +1,5 @@ 'grid', - 'dataProvider' => new ArrayDataProvider(['allModels' => []]), - 'showHeader' => false, - 'showFooter' => true, - 'options' => [], - 'tableOptions' => [], - 'view' => new View(), - 'filterUrl' => '/', - ]; + /** + * @throws \Exception + */ + public function testFooter() + { + $config = [ + 'id' => 'grid', + 'dataProvider' => new ArrayDataProvider(['allModels' => []]), + 'showHeader' => false, + 'showFooter' => true, + 'options' => [], + 'tableOptions' => [], + 'view' => new View(), + 'filterUrl' => '/', + ]; - $html = GridView::widget($config); - $html = preg_replace("/\r|\n/", '', $html); + $html = GridView::widget($config); + $html = preg_replace("/\r|\n/", '', $html); - $this->assertTrue(preg_match("/<\/tfoot>/", $html) === 1); + $this->assertTrue(preg_match('/<\/tfoot>/', $html) === 1); - // Place footer after body - $config['placeFooterAfterBody'] = true; + // Place footer after body + $config['placeFooterAfterBody'] = true; - $html = GridView::widget($config); - $html = preg_replace("/\r|\n/", '', $html); + $html = GridView::widget($config); + $html = preg_replace("/\r|\n/", '', $html); - $this->assertTrue(preg_match("/<\/tbody>/", $html) === 1); - } + $this->assertTrue(preg_match('/<\/tbody>/', $html) === 1); + } public function testHeaderLabels() { @@ -200,5 +202,5 @@ class GridViewTest extends \yiiunit\TestCase // If NoAutoLabels::generateAttributeLabel() has not been called no exception will be thrown meaning this test passed successfully. $this->assertTrue(true); - } + } } diff --git a/tests/framework/grid/RadiobuttonColumnTest.php b/tests/framework/grid/RadiobuttonColumnTest.php index bdd15ccef6..958a441450 100644 --- a/tests/framework/grid/RadiobuttonColumnTest.php +++ b/tests/framework/grid/RadiobuttonColumnTest.php @@ -1,4 +1,5 @@ 'cccy', ], $result); - $result = ArrayHelper::map($array, + $result = ArrayHelper::map( + $array, static function (array $group) { return $group['id'] . $group['name']; }, @@ -1742,6 +1745,7 @@ class Post2 extends BaseObject public $id = 123; public $content = 'test'; private $secret = 's'; + public function getSecret() { return $this->secret; diff --git a/tests/framework/helpers/BaseConsoleTest.php b/tests/framework/helpers/BaseConsoleTest.php index aa7bc11061..d6e432ad79 100644 --- a/tests/framework/helpers/BaseConsoleTest.php +++ b/tests/framework/helpers/BaseConsoleTest.php @@ -1,4 +1,5 @@ assertEquals($expected, $actual); $actual = BaseConsole::renderColoredString($data, false); - $expected = "foo"; + $expected = 'foo'; $this->assertEquals($expected, $actual); } diff --git a/tests/framework/helpers/ConsoleStub.php b/tests/framework/helpers/ConsoleStub.php index 7b09f1ba4a..afd9baf4a4 100644 --- a/tests/framework/helpers/ConsoleStub.php +++ b/tests/framework/helpers/ConsoleStub.php @@ -1,4 +1,5 @@ assertFalse($result); $this->truncateStreams(); - foreach ([ - 'y' => true, - 'Y' => true, - 'yes' => true, - 'YeS' => true, - 'n' => false, - 'N' => false, - 'no' => false, - 'NO' => false, - 'WHAT?!' . PHP_EOL . 'yes' => true, - ] as $currInput => $currAssertion) { + foreach ( + [ + 'y' => true, + 'Y' => true, + 'yes' => true, + 'YeS' => true, + 'n' => false, + 'N' => false, + 'no' => false, + 'NO' => false, + 'WHAT?!' . PHP_EOL . 'yes' => true, + ] as $currInput => $currAssertion + ) { $this->sendInput($currInput); $result = ConsoleStub::confirm('Are you sure?'); $this->assertEquals($currAssertion, $result, $currInput); @@ -413,15 +416,15 @@ class ConsoleTest extends TestCase $result = ConsoleStub::select('Using help', $options); $this->assertEquals( 'Using help (c,d,m,?): ' - . ' c - cat' - . PHP_EOL - . ' d - dog' - . PHP_EOL - . ' m - mouse' - . PHP_EOL - . ' ? - Show help' - . PHP_EOL - . 'Using help (c,d,m,?): ', + . ' c - cat' + . PHP_EOL + . ' d - dog' + . PHP_EOL + . ' m - mouse' + . PHP_EOL + . ' ? - Show help' + . PHP_EOL + . 'Using help (c,d,m,?): ', $this->readOutput() ); $this->truncateStreams(); diff --git a/tests/framework/helpers/FallbackInflector.php b/tests/framework/helpers/FallbackInflector.php index 27cd226c0b..8c0f2983af 100644 --- a/tests/framework/helpers/FallbackInflector.php +++ b/tests/framework/helpers/FallbackInflector.php @@ -1,4 +1,5 @@ testFilePath = Yii::getAlias('@yiiunit/runtime') . DIRECTORY_SEPARATOR . get_class($this); + $this->testFilePath = Yii::getAlias('@yiiunit/runtime') . DIRECTORY_SEPARATOR . str_replace('\\', '_', get_class($this)) . uniqid(); $this->createDir($this->testFilePath); if (!file_exists($this->testFilePath)) { $this->markTestIncomplete('Unit tests runtime directory should have writable permissions!'); @@ -920,7 +925,7 @@ class FileHelperTest extends TestCase $dirName = 'test_dir'; $this->createFileStructure([ $dirName => [ - 'test_sub_dir' => [ + 'test_sub_dir' => [ 'file_1.txt' => 'sub dir file 1 content', ], 'second_sub_dir' => [ @@ -1003,7 +1008,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected created test file owner to be current user.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected created test file group to be current group.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be changed.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be changed.'); ///////////////// @@ -1016,7 +1021,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected file owner to be unchanged.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be changed.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be changed.'); if ($currentUserId !== 0) { $this->markTestInComplete(__METHOD__ . ' could only run partially, chown() can only to be tested as root user. Current user: ' . $currentUserName); @@ -1032,7 +1037,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership, fileowner($testFile), 'Expected file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as numeric string (should be treated as integer) $ownership = '10002'; @@ -1040,7 +1045,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals((int)$ownership, fileowner($testFile), 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as string $ownership = $currentUserName; @@ -1048,7 +1053,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership, posix_getpwuid(fileowner($testFile))['name'], 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as numeric string with trailing colon (should be treated as integer) $ownership = '10003:'; @@ -1056,7 +1061,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals((int)$ownership, fileowner($testFile), 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as string with trailing colon $ownership = $currentUserName . ':'; @@ -1064,7 +1069,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals(substr($ownership, 0, -1), posix_getpwuid(fileowner($testFile))['name'], 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as indexed array (integer value) $ownership = [10004]; @@ -1072,7 +1077,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership[0], fileowner($testFile), 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as indexed array (numeric string value) $ownership = ['10005']; @@ -1080,7 +1085,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals((int)$ownership[0], fileowner($testFile), 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user ownership as associative array (string value) $ownership = ['user' => $currentUserName]; @@ -1088,7 +1093,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership['user'], posix_getpwuid(fileowner($testFile))['name'], 'Expected created test file owner to be changed.'); $this->assertEquals($currentGroupId, filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); /////////////////////// /// Group Ownership /// @@ -1100,7 +1105,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected file owner to be unchanged.'); $this->assertEquals((int)substr($ownership, 1), filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test group ownership as string $ownership = ':' . $currentGroupName; @@ -1108,7 +1113,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected file owner to be unchanged.'); $this->assertEquals(substr($ownership, 1), posix_getgrgid(filegroup($testFile))['name'], 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test group ownership as associative array (integer value) $ownership = ['group' => 10007]; @@ -1116,7 +1121,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected file owner to be unchanged.'); $this->assertEquals($ownership['group'], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test group ownership as associative array (numeric string value) $ownership = ['group' => '10008']; @@ -1124,7 +1129,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected file owner to be unchanged.'); $this->assertEquals((int)$ownership['group'], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test group ownership as associative array (string value) $ownership = ['group' => $currentGroupName]; @@ -1132,7 +1137,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($currentUserId, fileowner($testFile), 'Expected file owner to be unchanged.'); $this->assertEquals($ownership['group'], posix_getgrgid(filegroup($testFile))['name'], 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); ///////////////////////////////// /// User- and Group Ownership /// @@ -1144,7 +1149,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals((int)explode(':', $ownership)[0], fileowner($testFile), 'Expected file owner to be changed.'); $this->assertEquals((int)explode(':', $ownership)[1], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as string $ownership = $currentUserName . ':' . $currentGroupName; @@ -1152,7 +1157,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals(explode(':', $ownership)[0], posix_getpwuid(fileowner($testFile))['name'], 'Expected file owner to be changed.'); $this->assertEquals(explode(':', $ownership)[1], posix_getgrgid(filegroup($testFile))['name'], 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as indexed array (integer values) $ownership = [10011, 10012]; @@ -1160,7 +1165,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership[0], fileowner($testFile), 'Expected file owner to be changed.'); $this->assertEquals($ownership[1], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as indexed array (numeric string values) $ownership = ['10013', '10014']; @@ -1168,7 +1173,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals((int)$ownership[0], fileowner($testFile), 'Expected file owner to be changed.'); $this->assertEquals((int)$ownership[1], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as indexed array (string values) $ownership = [$currentUserName, $currentGroupName]; @@ -1176,7 +1181,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership[0], posix_getpwuid(fileowner($testFile))['name'], 'Expected file owner to be changed.'); $this->assertEquals($ownership[1], posix_getgrgid(filegroup($testFile))['name'], 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as associative array (integer values) $ownership = ['group' => 10015, 'user' => 10016]; // user/group reversed on purpose @@ -1184,7 +1189,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership['user'], fileowner($testFile), 'Expected file owner to be changed.'); $this->assertEquals($ownership['group'], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as associative array (numeric string values) $ownership = ['group' => '10017', 'user' => '10018']; // user/group reversed on purpose @@ -1192,7 +1197,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals((int)$ownership['user'], fileowner($testFile), 'Expected file owner to be changed.'); $this->assertEquals((int)$ownership['group'], filegroup($testFile), 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); // Test user and group ownership as associative array (string values) $ownership = ['group' => $currentGroupName, 'user' => $currentUserName]; // user/group reversed on purpose @@ -1200,7 +1205,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals($ownership['user'], posix_getpwuid(fileowner($testFile))['name'], 'Expected file owner to be changed.'); $this->assertEquals($ownership['group'], posix_getgrgid(filegroup($testFile))['name'], 'Expected created test file group to be changed.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected file mode to be unchanged.'); /////////////////////////////////////// /// Mode, User- and Group Ownership /// @@ -1213,8 +1218,7 @@ class FileHelperTest extends TestCase clearstatcache(true, $testFile); $this->assertEquals(explode(':', $ownership)[0], fileowner($testFile), 'Expected created test file owner to be changed.'); $this->assertEquals(explode(':', $ownership)[1], filegroup($testFile), 'Expected file group to be unchanged.'); - $this->assertEquals('0'.decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected created test file mode to be changed.'); - + $this->assertEquals('0' . decoct($fileMode), substr(decoct(fileperms($testFile)), -4), 'Expected created test file mode to be changed.'); } public function testChangeOwnershipNonExistingUser() @@ -1234,7 +1238,7 @@ class FileHelperTest extends TestCase try { FileHelper::changeOwnership($testFile, $ownership); throw new \Exception('FileHelper::changeOwnership() should have thrown error for non existing user.'); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->assertEquals('chown(): Unable to find uid for non_existing_user', $e->getMessage()); } } diff --git a/tests/framework/helpers/FormatConverterTest.php b/tests/framework/helpers/FormatConverterTest.php index 42ed3acb1e..b18bf50c58 100644 --- a/tests/framework/helpers/FormatConverterTest.php +++ b/tests/framework/helpers/FormatConverterTest.php @@ -1,4 +1,5 @@ assertEqualsWithoutLE( $expected, - Html::dropDownList('test', new \ArrayObject(['1', 'value3']), $this->getDataItems3(), ['multiple' => 'true'] + Html::dropDownList( + 'test', + new \ArrayObject(['1', 'value3']), + $this->getDataItems3(), + ['multiple' => 'true'] ) ); } @@ -1559,7 +1564,6 @@ EOD; $this->assertEquals($expectedHtmlForAlias, Html::activeInput('text', $model, 'alias', $options)); } - /** * Data provider for [[testActivePasswordInput()]]. * @return array test data @@ -2002,22 +2006,22 @@ EOD; $expected = ''; $model = new HtmlTestModel(); - $actual = Html::activeFileInput($model, 'types', ['name' => 'foo', 'hiddenOptions'=>['id'=>'specific-id']]); + $actual = Html::activeFileInput($model, 'types', ['name' => 'foo', 'hiddenOptions' => ['id' => 'specific-id']]); $this->assertEqualsWithoutLE($expected, $actual); $expected = ''; $model = new HtmlTestModel(); - $actual = Html::activeFileInput($model, 'types', ['hiddenOptions'=>['id'=>'specific-id']]); + $actual = Html::activeFileInput($model, 'types', ['hiddenOptions' => ['id' => 'specific-id']]); $this->assertEqualsWithoutLE($expected, $actual); $expected = ''; $model = new HtmlTestModel(); - $actual = Html::activeFileInput($model, 'types', ['hiddenOptions'=>[]]); + $actual = Html::activeFileInput($model, 'types', ['hiddenOptions' => []]); $this->assertEqualsWithoutLE($expected, $actual); $expected = ''; $model = new HtmlTestModel(); - $actual = Html::activeFileInput($model, 'types', ['name' => 'foo', 'hiddenOptions'=>[]]); + $actual = Html::activeFileInput($model, 'types', ['name' => 'foo', 'hiddenOptions' => []]); $this->assertEqualsWithoutLE($expected, $actual); } @@ -2291,8 +2295,8 @@ HTML; * Class MyHtml * @package yiiunit\framework\helpers */ -class MyHtml extends Html{ - +class MyHtml extends Html +{ /** * @param \yii\base\Model $model * @param string $attribute @@ -2302,7 +2306,7 @@ class MyHtml extends Html{ { if (isset($options['placeholder']) && $options['placeholder'] === true) { $attribute = static::getAttributeName($attribute); - $options['placeholder'] = 'My placeholder: '. $model->getAttributeLabel($attribute); + $options['placeholder'] = 'My placeholder: ' . $model->getAttributeLabel($attribute); } } } diff --git a/tests/framework/helpers/InflectorTest.php b/tests/framework/helpers/InflectorTest.php index 644660e721..5e442d600a 100644 --- a/tests/framework/helpers/InflectorTest.php +++ b/tests/framework/helpers/InflectorTest.php @@ -1,4 +1,5 @@ expectException(\yii\base\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid JSON data.'); - + Json::decode([]); } diff --git a/tests/framework/helpers/MarkdownTest.php b/tests/framework/helpers/MarkdownTest.php index 4917848167..39e7142897 100644 --- a/tests/framework/helpers/MarkdownTest.php +++ b/tests/framework/helpers/MarkdownTest.php @@ -1,4 +1,5 @@ expectException(\yii\base\InvalidArgumentException::class); $this->expectExceptionMessage("Markdown flavor 'undefined' is not defined."); - + Markdown::process('foo', 'undefined'); } diff --git a/tests/framework/helpers/ReplaceArrayValueTest.php b/tests/framework/helpers/ReplaceArrayValueTest.php index 458746276f..b7d51233ea 100644 --- a/tests/framework/helpers/ReplaceArrayValueTest.php +++ b/tests/framework/helpers/ReplaceArrayValueTest.php @@ -1,4 +1,5 @@ assertEquals(['Здесь', 'multibyte', 'строка'], StringHelper::explode('Здесь我 multibyte我 строка', '我')); $this->assertEquals(['Disable', ' trim ', 'here but ignore empty'], StringHelper::explode('Disable, trim ,,,here but ignore empty', ',', false, true)); $this->assertEquals(['It/', ' is?', ' a', ' test with rtrim'], StringHelper::explode('It/, is?, a , test with rtrim', ',', 'rtrim')); - $this->assertEquals(['It', ' is', ' a ', ' test with closure'], StringHelper::explode('It/, is?, a , test with closure', ',', function ($value) { return trim($value, '/?'); })); + $this->assertEquals(['It', ' is', ' a ', ' test with closure'], StringHelper::explode('It/, is?, a , test with closure', ',', function ($value) { + return trim($value, '/?'); + })); } public function testWordCount() diff --git a/tests/framework/helpers/UnsetArrayValueTest.php b/tests/framework/helpers/UnsetArrayValueTest.php index 411b74ffa3..032f62869c 100644 --- a/tests/framework/helpers/UnsetArrayValueTest.php +++ b/tests/framework/helpers/UnsetArrayValueTest.php @@ -1,4 +1,5 @@ testFunction = function () {return 2;}; + $var->testFunction = function () { + return 2; + }; $exportResult = VarDumper::export($var); $this->assertNotEmpty($exportResult); @@ -181,7 +190,9 @@ RESULT; $slave = new \StdClass(); $master->slave = $slave; $slave->master = $master; - $master->function = function () {return true;}; + $master->function = function () { + return true; + }; $exportResult = VarDumper::export($master); $this->assertNotEmpty($exportResult); diff --git a/tests/framework/i18n/DbMessageSourceTest.php b/tests/framework/i18n/DbMessageSourceTest.php index 8e4dd725e8..5c764f0797 100644 --- a/tests/framework/i18n/DbMessageSourceTest.php +++ b/tests/framework/i18n/DbMessageSourceTest.php @@ -1,4 +1,5 @@ assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); - Event::on(DbMessageSource::className(), DbMessageSource::EVENT_MISSING_TRANSLATION, function ($event) {}); + Event::on(DbMessageSource::className(), DbMessageSource::EVENT_MISSING_TRANSLATION, function ($event) { + }); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); $this->assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); @@ -166,7 +168,6 @@ class DbMessageSourceTest extends I18NTest Event::off(DbMessageSource::className(), DbMessageSource::EVENT_MISSING_TRANSLATION); } - public function testIssue11429($sourceLanguage = null) { $this->markTestSkipped('DbMessageSource does not produce any errors when messages file is missing.'); diff --git a/tests/framework/i18n/FallbackMessageFormatterTest.php b/tests/framework/i18n/FallbackMessageFormatterTest.php index a42b69a597..be5b21ee89 100644 --- a/tests/framework/i18n/FallbackMessageFormatterTest.php +++ b/tests/framework/i18n/FallbackMessageFormatterTest.php @@ -1,4 +1,5 @@ formatter = null; } - public function testFormat() { $value = time(); @@ -581,7 +581,6 @@ class FormatterDateTest extends TestCase $this->assertSame($expected, $this->formatter->asDatetime($value, 'yyyy-MM-dd HH:mm:ss')); } - public function provideTimezones() { return [ @@ -734,7 +733,6 @@ class FormatterDateTest extends TestCase $this->assertSame('1407674460', $this->formatter->asTimestamp('2014-08-10 12:41:00 UTC')); } - public function testIntlDateOnlyValues() { $this->testDateOnlyValues(); diff --git a/tests/framework/i18n/FormatterNumberTest.php b/tests/framework/i18n/FormatterNumberTest.php index e572adb902..bb96347f46 100755 --- a/tests/framework/i18n/FormatterNumberTest.php +++ b/tests/framework/i18n/FormatterNumberTest.php @@ -1,4 +1,5 @@ assertSame( 'from: ' . date('Y-m-d', $value), $this->formatter->format($value, function ($value, Formatter $formatter) { - return 'from: ' . $formatter->asDate($value, 'php:Y-m-d'); + return 'from: ' . $formatter->asDate($value, 'php:Y-m-d'); }) ); } @@ -205,8 +206,10 @@ class FormatterTest extends TestCase $value = 'test@sample.com'; $this->assertSame("$value", $this->formatter->asEmail($value)); $value = 'test@sample.com'; - $this->assertSame("$value", - $this->formatter->asEmail($value, ['target' => '_blank'])); + $this->assertSame( + "$value", + $this->formatter->asEmail($value, ['target' => '_blank']) + ); // null display $this->assertSame($this->formatter->nullDisplay, $this->formatter->asEmail(null)); @@ -297,8 +300,10 @@ class FormatterTest extends TestCase ); $value = 'http://www.yiiframework.com/'; - $this->assertSame("$value", - $this->formatter->asUrl($value, ['target' => '_blank'])); + $this->assertSame( + "$value", + $this->formatter->asUrl($value, ['target' => '_blank']) + ); // null display $this->assertSame($this->formatter->nullDisplay, $this->formatter->asUrl(null)); diff --git a/tests/framework/i18n/GettextMessageSourceTest.php b/tests/framework/i18n/GettextMessageSourceTest.php index 24e678bbd5..524338e79b 100644 --- a/tests/framework/i18n/GettextMessageSourceTest.php +++ b/tests/framework/i18n/GettextMessageSourceTest.php @@ -1,4 +1,5 @@ [ - '*' => new PhpMessageSource([ + '*' => new PhpMessageSource( + [ 'basePath' => '@yiiunit/data/i18n/messages', 'sourceLanguage' => 'de-DE', 'fileMap' => [ @@ -208,7 +210,8 @@ class I18NTest extends TestCase $this->assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); - Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function ($event) {}); + Event::on(PhpMessageSource::className(), PhpMessageSource::EVENT_MISSING_TRANSLATION, function ($event) { + }); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); $this->assertEquals('Missing translation message.', $this->i18n->translate('test', 'Missing translation message.', [], 'de-DE')); $this->assertEquals('Hallo Welt!', $this->i18n->translate('test', 'Hello world!', [], 'de-DE')); diff --git a/tests/framework/i18n/IntlTestHelper.php b/tests/framework/i18n/IntlTestHelper.php index b90ee41d59..1d5423a909 100644 --- a/tests/framework/i18n/IntlTestHelper.php +++ b/tests/framework/i18n/IntlTestHelper.php @@ -1,4 +1,5 @@ withConsecutive( [$this->equalTo('messages'), $this->equalTo(true)], [ - $this->callback(function($arg) use ($target1) { + $this->callback(function ($arg) use ($target1) { if (!isset($arg[0][0], $arg[0][1], $arg[0][2], $arg[0][3])) { return false; } diff --git a/tests/framework/log/EmailTargetTest.php b/tests/framework/log/EmailTargetTest.php index a60046b6cd..6d68b2b117 100644 --- a/tests/framework/log/EmailTargetTest.php +++ b/tests/framework/log/EmailTargetTest.php @@ -1,4 +1,5 @@ expectException(\yii\base\InvalidConfigException::class); $this->expectExceptionMessage('The "to" option must be set for EmailTarget::message.'); - + new EmailTarget(['mailer' => $this->mailer]); } diff --git a/tests/framework/log/FileTargetTest.php b/tests/framework/log/FileTargetTest.php index 6c23837f23..13c35d8c01 100644 --- a/tests/framework/log/FileTargetTest.php +++ b/tests/framework/log/FileTargetTest.php @@ -1,4 +1,5 @@ assertEquals('application', $this->logger->messages[0][2]); $this->assertEquals([ 'file' => __FILE__, - 'line' => 67, + 'line' => 68, 'function' => 'log', 'class' => get_class($this->logger), 'type' => '->', @@ -195,18 +196,19 @@ class LoggerTest extends TestCase 'anyKey' => ['token', Logger::LEVEL_PROFILE_BEGIN, 'category', 10, 'trace', 1048576], 'anyKey2' => ['token', Logger::LEVEL_PROFILE_END, 'category', 15, 'trace', 2097152], ]; - $this->assertEquals([ + $this->assertEquals( [ - 'info' => 'token', - 'category' => 'category', - 'timestamp' => 10, - 'trace' => 'trace', - 'level' => 0, - 'duration' => 5, - 'memory' => 2097152, - 'memoryDiff' => 1048576, + [ + 'info' => 'token', + 'category' => 'category', + 'timestamp' => 10, + 'trace' => 'trace', + 'level' => 0, + 'duration' => 5, + 'memory' => 2097152, + 'memoryDiff' => 1048576, + ], ], - ], $this->logger->calculateTimings($messages) ); @@ -214,18 +216,19 @@ class LoggerTest extends TestCase 'anyKey' => [['a', 'b'], Logger::LEVEL_PROFILE_BEGIN, 'category', 10, 'trace', 1048576], 'anyKey2' => [['a', 'b'], Logger::LEVEL_PROFILE_END, 'category', 15, 'trace', 2097152], ]; - $this->assertEquals([ + $this->assertEquals( [ - 'info' => ['a', 'b'], - 'category' => 'category', - 'timestamp' => 10, - 'trace' => 'trace', - 'level' => 0, - 'duration' => 5, - 'memory' => 2097152, - 'memoryDiff' => 1048576, + [ + 'info' => ['a', 'b'], + 'category' => 'category', + 'timestamp' => 10, + 'trace' => 'trace', + 'level' => 0, + 'duration' => 5, + 'memory' => 2097152, + 'memoryDiff' => 1048576, + ], ], - ], $this->logger->calculateTimings($messages) ); } @@ -241,28 +244,29 @@ class LoggerTest extends TestCase ['secondLevel', Logger::LEVEL_PROFILE_END, 'secondLevelCategory', 55, 'secondTrace', 3145728], ['firstLevel', Logger::LEVEL_PROFILE_END, 'firstLevelCategory', 80, 'firstTrace', 4194304], ]; - $this->assertEquals([ + $this->assertEquals( [ - 'info' => 'firstLevel', - 'category' => 'firstLevelCategory', - 'timestamp' => 10, - 'trace' => 'firstTrace', - 'level' => 0, - 'duration' => 70, - 'memory' => 4194304, - 'memoryDiff' => 3145728, + [ + 'info' => 'firstLevel', + 'category' => 'firstLevelCategory', + 'timestamp' => 10, + 'trace' => 'firstTrace', + 'level' => 0, + 'duration' => 70, + 'memory' => 4194304, + 'memoryDiff' => 3145728, + ], + [ + 'info' => 'secondLevel', + 'category' => 'secondLevelCategory', + 'timestamp' => 15, + 'trace' => 'secondTrace', + 'level' => 1, + 'duration' => 40, + 'memory' => 3145728, + 'memoryDiff' => 1048576, + ], ], - [ - 'info' => 'secondLevel', - 'category' => 'secondLevelCategory', - 'timestamp' => 15, - 'trace' => 'secondTrace', - 'level' => 1, - 'duration' => 40, - 'memory' => 3145728, - 'memoryDiff' => 1048576, - ], - ], $this->logger->calculateTimings($messages) ); } @@ -280,28 +284,29 @@ class LoggerTest extends TestCase ['firstLevel', Logger::LEVEL_PROFILE_END, 'firstLevelCategory', 80, 'firstTrace', 4194304], ['secondLevel', Logger::LEVEL_PROFILE_END, 'secondLevelCategory', 55, 'secondTrace', 3145728], ]; - $this->assertEquals([ + $this->assertEquals( [ - 'info' => 'firstLevel', - 'category' => 'firstLevelCategory', - 'timestamp' => 10, - 'trace' => 'firstTrace', - 'level' => 1, - 'duration' => 70, - 'memory' => 4194304, - 'memoryDiff' => 3145728, + [ + 'info' => 'firstLevel', + 'category' => 'firstLevelCategory', + 'timestamp' => 10, + 'trace' => 'firstTrace', + 'level' => 1, + 'duration' => 70, + 'memory' => 4194304, + 'memoryDiff' => 3145728, + ], + [ + 'info' => 'secondLevel', + 'category' => 'secondLevelCategory', + 'timestamp' => 15, + 'trace' => 'secondTrace', + 'level' => 0, + 'duration' => 40, + 'memory' => 3145728, + 'memoryDiff' => 1048576, + ], ], - [ - 'info' => 'secondLevel', - 'category' => 'secondLevelCategory', - 'timestamp' => 15, - 'trace' => 'secondTrace', - 'level' => 0, - 'duration' => 40, - 'memory' => 3145728, - 'memoryDiff' => 1048576, - ], - ], $this->logger->calculateTimings($messages) ); } diff --git a/tests/framework/log/MySQLTargetTest.php b/tests/framework/log/MySQLTargetTest.php index 74a264ad7c..0317f37064 100644 --- a/tests/framework/log/MySQLTargetTest.php +++ b/tests/framework/log/MySQLTargetTest.php @@ -1,4 +1,5 @@ collectOverride !== null) { + if ($this->collectOverride !== null) { call_user_func($this->collectOverride, $messages, $final); return; } diff --git a/tests/framework/log/mocks/typed_error.php b/tests/framework/log/mocks/typed_error.php index fba864d9f2..d362bc32d0 100644 --- a/tests/framework/log/mocks/typed_error.php +++ b/tests/framework/log/mocks/typed_error.php @@ -1,4 +1,5 @@ defineAttribute('name'); + $this->defineAttribute('name'); } /** diff --git a/tests/framework/mutex/FileMutexTest.php b/tests/framework/mutex/FileMutexTest.php index 60947e750a..028f38f5ab 100644 --- a/tests/framework/mutex/FileMutexTest.php +++ b/tests/framework/mutex/FileMutexTest.php @@ -1,4 +1,5 @@ createMutex(['keyPrefix' => new Expression('1+1')]); $this->assertInstanceOf(MysqlMutex::classname(), $mutex); $this->assertInstanceOf(Expression::classname(), $mutex->keyPrefix); - $this->assertSame("1+1", $mutex->keyPrefix->expression); + $this->assertSame('1+1', $mutex->keyPrefix->expression); } } diff --git a/tests/framework/mutex/PgsqlMutexTest.php b/tests/framework/mutex/PgsqlMutexTest.php index e8a3507cfd..5df78b6b1d 100644 --- a/tests/framework/mutex/PgsqlMutexTest.php +++ b/tests/framework/mutex/PgsqlMutexTest.php @@ -1,4 +1,5 @@ assertEquals(['123', 'reader A'], $this->auth->getUserIdsByRole('reader'), '', 0.0, 10, true); $this->assertEquals(['author B'], $this->auth->getUserIdsByRole('author')); $this->assertEquals(['admin C'], $this->auth->getUserIdsByRole('admin')); - } + } protected static function runConsoleAction($route, $params = []) { @@ -409,7 +410,8 @@ abstract class DbManagerTestCase extends ManagerTestCase $this->assertCount(1, $messages, 'Only one query should have been performed, but there are the following logs: ' . print_r($logTarget->messages, true)); $this->assertStringContainsString( 'auth_assignment', - $messages[0][0], 'Log message should be a query to auth_assignment table', + $messages[0][0], + 'Log message should be a query to auth_assignment table', ); $logTarget->messages = []; } diff --git a/tests/framework/rbac/ExposedPhpManager.php b/tests/framework/rbac/ExposedPhpManager.php index 092307313a..a07cbc00be 100644 --- a/tests/framework/rbac/ExposedPhpManager.php +++ b/tests/framework/rbac/ExposedPhpManager.php @@ -1,4 +1,5 @@ assertFalse($this->auth->canAddChild($reader, $author)); } - public function testRemoveAllRules() { $this->prepareData(); diff --git a/tests/framework/rbac/MySQLManagerCacheTest.php b/tests/framework/rbac/MySQLManagerCacheTest.php index 6bf268e371..4ae2819b72 100644 --- a/tests/framework/rbac/MySQLManagerCacheTest.php +++ b/tests/framework/rbac/MySQLManagerCacheTest.php @@ -1,4 +1,5 @@ controller = new RestController( 'rest', - new Module('rest'), [ - 'modelClass' => IndexActionModel::className(), - 'actions' => [ - 'index' => [ - 'class' => IndexAction::className(), - 'modelClass' => IndexActionModel::className(), - 'prepareSearchQuery' => function ($query, $requestParams) use (&$sql) { - $this->assertTrue($query instanceof Query); - $sql = $query->createCommand()->getRawSql(); + new Module('rest'), + [ + 'modelClass' => IndexActionModel::className(), + 'actions' => [ + 'index' => [ + 'class' => IndexAction::className(), + 'modelClass' => IndexActionModel::className(), + 'prepareSearchQuery' => function ($query, $requestParams) use (&$sql) { + $this->assertTrue($query instanceof Query); + $sql = $query->createCommand()->getRawSql(); - return $query; - }, + return $query; + }, + ], ], - ], - ]); + ] + ); Yii::$app->controller->run('index'); $this->assertEquals( @@ -89,17 +91,19 @@ class IndexActionTest extends TestCase $controller = new RestController( 'rest', - new Module('rest'), [ - 'modelClass' => IndexActionModel::className(), - 'actions' => [ - 'index' => [ - 'class' => IndexAction::className(), - 'modelClass' => IndexActionModel::className(), - 'pagination' => $pagination, - 'sort' => $sort, + new Module('rest'), + [ + 'modelClass' => IndexActionModel::className(), + 'actions' => [ + 'index' => [ + 'class' => IndexAction::className(), + 'modelClass' => IndexActionModel::className(), + 'pagination' => $pagination, + 'sort' => $sort, + ], ], - ], - ]); + ] + ); /** @var ActiveDataProvider $dataProvider */ $dataProvider = $controller->createAction('index')->runWithParams([]); @@ -197,7 +201,6 @@ class RestController extends ActiveController class Module extends \yii\base\Module { - } /** diff --git a/tests/framework/rest/SerializerTest.php b/tests/framework/rest/SerializerTest.php index d7516e0dae..120bcfaa6a 100644 --- a/tests/framework/rest/SerializerTest.php +++ b/tests/framework/rest/SerializerTest.php @@ -1,4 +1,5 @@ function() { - return $this->field3.'/'.$this->field4; + 'customField' => function () { + return $this->field3 . '/' . $this->field4; }, ]; } @@ -555,7 +556,7 @@ class TestModel4 implements \JsonSerializable public function jsonSerialize() { return [ - 'customField2' => $this->field5.'/'.$this->field6, + 'customField2' => $this->field5 . '/' . $this->field6, ]; } } @@ -572,13 +573,13 @@ class TestModel5 extends Model public function fields() { $fields = static::$fields; - $fields['testModel3'] = function() { + $fields['testModel3'] = function () { return $this->getTestModel3(); }; - $fields['testModel4'] = function() { + $fields['testModel4'] = function () { return $this->getTestModel4(); }; - $fields['testModelArray'] = function() { + $fields['testModelArray'] = function () { return [$this->getTestModel3(), $this->getTestModel4()]; }; return $fields; diff --git a/tests/framework/rest/UrlRuleTest.php b/tests/framework/rest/UrlRuleTest.php index 9cc39935f7..4aeb78e872 100644 --- a/tests/framework/rest/UrlRuleTest.php +++ b/tests/framework/rest/UrlRuleTest.php @@ -1,4 +1,5 @@ assertEquals(1, $directory->id); $this->assertEquals('directory@example.com', $directory['email']); $test->tearDown(); - } public function testDataPath() diff --git a/tests/framework/test/ArrayFixtureTest.php b/tests/framework/test/ArrayFixtureTest.php index 669dbc6cbc..9b2a3d14c8 100644 --- a/tests/framework/test/ArrayFixtureTest.php +++ b/tests/framework/test/ArrayFixtureTest.php @@ -1,4 +1,5 @@ _fixture->dataFile = 'wrong/fixtures/data/path/alias'; $this->expectException(\yii\base\InvalidConfigException::class); - + $this->_fixture->load(); } } diff --git a/tests/framework/test/FixtureTest.php b/tests/framework/test/FixtureTest.php index 6ec23bae97..c2b4f4e686 100644 --- a/tests/framework/test/FixtureTest.php +++ b/tests/framework/test/FixtureTest.php @@ -1,4 +1,5 @@ scenario) { - case 0: return []; - case 1: return [ - 'fixture1' => Fixture1::className(), - ]; - case 2: return [ - 'fixture2' => Fixture2::className(), - ]; - case 3: return [ - 'fixture3' => Fixture3::className(), - ]; - case 4: return [ - 'fixture1' => Fixture1::className(), - 'fixture2' => Fixture2::className(), - ]; - case 5: return [ - 'fixture2' => Fixture2::className(), - 'fixture3' => Fixture3::className(), - ]; - case 6: return [ - 'fixture1' => Fixture1::className(), - 'fixture3' => Fixture3::className(), - ]; - case 7: return [ - 'fixture1' => Fixture1::className(), - 'fixture2' => Fixture2::className(), - 'fixture3' => Fixture3::className(), - ]; - case 8: return [ - 'fixture4' => Fixture4::className(), - ]; - case 9: return [ - 'fixture5' => Fixture5::className(), - 'fixture4' => Fixture4::className(), - ]; - case 10: return [ - 'fixture3a' => Fixture3::className(), // duplicate fixtures may occur two fixtures depend on the same fixture. - 'fixture3b' => Fixture3::className(), - ]; - default: return []; + case 0: + return []; + case 1: + return [ + 'fixture1' => Fixture1::className(), + ]; + case 2: + return [ + 'fixture2' => Fixture2::className(), + ]; + case 3: + return [ + 'fixture3' => Fixture3::className(), + ]; + case 4: + return [ + 'fixture1' => Fixture1::className(), + 'fixture2' => Fixture2::className(), + ]; + case 5: + return [ + 'fixture2' => Fixture2::className(), + 'fixture3' => Fixture3::className(), + ]; + case 6: + return [ + 'fixture1' => Fixture1::className(), + 'fixture3' => Fixture3::className(), + ]; + case 7: + return [ + 'fixture1' => Fixture1::className(), + 'fixture2' => Fixture2::className(), + 'fixture3' => Fixture3::className(), + ]; + case 8: + return [ + 'fixture4' => Fixture4::className(), + ]; + case 9: + return [ + 'fixture5' => Fixture5::className(), + 'fixture4' => Fixture4::className(), + ]; + case 10: + return [ + 'fixture3a' => Fixture3::className(), // duplicate fixtures may occur two fixtures depend on the same fixture. + 'fixture3b' => Fixture3::className(), + ]; + default: + return []; } } } diff --git a/tests/framework/test/custom/customer.php b/tests/framework/test/custom/customer.php index ac5876acba..c37d6b8e06 100644 --- a/tests/framework/test/custom/customer.php +++ b/tests/framework/test/custom/customer.php @@ -1,4 +1,5 @@ assertFalse($val->validate($value + 1)); // Using a closure for compareValue - $val = new CompareValidator(['compareValue' => function() use ($value) { + $val = new CompareValidator(['compareValue' => function () use ($value) { return $value; }]); $this->assertTrue($val->validate($value)); diff --git a/tests/framework/validators/DateValidatorTest.php b/tests/framework/validators/DateValidatorTest.php index c00017cb46..7e75a23ecb 100644 --- a/tests/framework/validators/DateValidatorTest.php +++ b/tests/framework/validators/DateValidatorTest.php @@ -1,4 +1,5 @@ assertFalse($validator->validate('Short Name ')); $this->assertFalse($validator->validate('Short Name ')); $this->assertFalse($validator->validate(['developer@yiiframework.com'])); - } public function testValidateValueIdn() diff --git a/tests/framework/validators/ExistValidatorTest.php b/tests/framework/validators/ExistValidatorTest.php index 1fc2e27b5e..1727c46b4f 100644 --- a/tests/framework/validators/ExistValidatorTest.php +++ b/tests/framework/validators/ExistValidatorTest.php @@ -1,4 +1,5 @@ OrderItem::className(), - 'targetAttribute' => ['id' => 'COALESCE([[order_id]], 0)'], - ]); + 'targetClass' => OrderItem::className(), + 'targetAttribute' => ['id' => 'COALESCE([[order_id]], 0)'], + ]); $m = new Order(['id' => 1]); $val->validateAttribute($m, 'id'); @@ -250,7 +251,7 @@ abstract class ExistValidatorTest extends DatabaseTestCase ActiveRecord::$db = $connection; $model = null; - $connection->useMaster(function() use (&$model) { + $connection->useMaster(function () use (&$model) { $model = ValidatorTestMainModel::findOne(2); }); diff --git a/tests/framework/validators/FileValidatorTest.php b/tests/framework/validators/FileValidatorTest.php index 0009db6dbf..dac2e98ccf 100644 --- a/tests/framework/validators/FileValidatorTest.php +++ b/tests/framework/validators/FileValidatorTest.php @@ -1,4 +1,5 @@ setScenario('validateMultipleFiles'); $this->assertFalse($m->validate()); - $this->assertNotFalse(stripos(current($m->getErrors('attr_images')), - 'Only files with these extensions are allowed')); + $this->assertNotFalse(stripos( + current($m->getErrors('attr_images')), + 'Only files with these extensions are allowed' + )); $m = FakedValidationModel::createWithAttributes( [ @@ -669,7 +672,8 @@ class FileValidatorTest extends TestCase * @param bool $expected * @dataProvider mimeTypeCaseInsensitive */ - public function testValidateMimeTypeCaseInsensitive($mask, $fileMimeType, $expected) { + public function testValidateMimeTypeCaseInsensitive($mask, $fileMimeType, $expected) + { $validator = $this->getMockBuilder(\yii\validators\FileValidator::class) ->onlyMethods(['getMimeTypeByFile']) ->getMock(); diff --git a/tests/framework/validators/FilterValidatorTest.php b/tests/framework/validators/FilterValidatorTest.php index f574f259b5..f7589e2877 100644 --- a/tests/framework/validators/FilterValidatorTest.php +++ b/tests/framework/validators/FilterValidatorTest.php @@ -1,4 +1,5 @@ assertEquals($expectedRange, $validator->ranges); } - public function testValidateOrder() { $validator = new IpValidator([ @@ -147,7 +147,6 @@ class IpValidatorTest extends TestCase $this->assertFalse($validator->validate('!!192.168.5.32/32')); } - public function testValidateValueIPv6() { $validator = new IpValidator(); @@ -346,7 +345,6 @@ class IpValidatorTest extends TestCase $this->assertEquals('8.8.8.8/32', $model->attr_ip); } - public function testValidateAttributeIPv6() { $validator = new IpValidator(); diff --git a/tests/framework/validators/NumberValidatorTest.php b/tests/framework/validators/NumberValidatorTest.php index 7114e16735..75c6e3a9d5 100644 --- a/tests/framework/validators/NumberValidatorTest.php +++ b/tests/framework/validators/NumberValidatorTest.php @@ -1,4 +1,5 @@ useMaster(function() use (&$model) { + $connection->useMaster(function () use (&$model) { $model = WithCustomer::find()->one(); }); @@ -534,8 +535,10 @@ abstract class UniqueValidatorTest extends DatabaseTestCase } } -class WithCustomer extends Customer { - public static function find() { +class WithCustomer extends Customer +{ + public static function find() + { $res = parent::find(); $res->with('profile'); @@ -544,8 +547,10 @@ class WithCustomer extends Customer { } } -class JoinWithCustomer extends Customer { - public static function find() { +class JoinWithCustomer extends Customer +{ + public static function find() + { $res = parent::find(); $res->joinWith('profile'); diff --git a/tests/framework/validators/UrlValidatorTest.php b/tests/framework/validators/UrlValidatorTest.php index 99866a9655..06480a41a4 100644 --- a/tests/framework/validators/UrlValidatorTest.php +++ b/tests/framework/validators/UrlValidatorTest.php @@ -1,4 +1,5 @@ 234 EOF; - break; + break; case View::POS_BEGIN: $expected = <<<'EOF' 12 34 EOF; - break; + break; default: case View::POS_END: $expected = <<<'EOF' 123 4 EOF; - break; + break; } $this->assertEqualsWithoutLE($expected, $view->renderFile('@yiiunit/data/views/rawlayout.php')); } diff --git a/tests/framework/web/AssetConverterTest.php b/tests/framework/web/AssetConverterTest.php index 0d439ee4e2..d790534c92 100644 --- a/tests/framework/web/AssetConverterTest.php +++ b/tests/framework/web/AssetConverterTest.php @@ -1,4 +1,5 @@ tmpPath; - file_put_contents($tmpPath . '/test.php', <<tmpPath; - file_put_contents($tmpPath . '/test.php', <<<'EOF' + file_put_contents( + $tmpPath . '/test.php', + <<<'EOF' assertNull($args[1]); } - public function testModelBindingHttpException() { + public function testModelBindingHttpException() + { $this->controller = new FakePhp71Controller('fake', new \yii\web\Application([ 'id' => 'app', 'basePath' => __DIR__, 'container' => [ 'definitions' => [ - \yiiunit\framework\web\stubs\ModelBindingStub::className() => [ \yiiunit\framework\web\stubs\ModelBindingStub::className() , "build"], - ] + \yiiunit\framework\web\stubs\ModelBindingStub::className() => [ + \yiiunit\framework\web\stubs\ModelBindingStub::className(), + 'build', + ], + ], ], 'components' => [ 'request' => [ @@ -103,7 +108,7 @@ class ControllerTest extends TestCase Yii::$container->set(VendorImage::className(), VendorImage::className()); $this->mockWebApplication(['controller' => $this->controller]); $injectionAction = new InlineAction('injection', $this->controller, 'actionModelBindingInjection'); - $this->expectException(get_class(new NotFoundHttpException("Not Found Item."))); + $this->expectException(get_class(new NotFoundHttpException('Not Found Item.'))); $this->expectExceptionMessage('Not Found Item.'); $this->controller->bindActionParams($injectionAction, []); } @@ -127,7 +132,9 @@ class ControllerTest extends TestCase $injectionAction = new InlineAction('injection', $this->controller, 'actionInjection'); $params = ['between' => 'test', 'after' => 'another', 'before' => 'test']; - Yii::$container->set(VendorImage::className(), function() { throw new \RuntimeException('uh oh'); }); + Yii::$container->set(VendorImage::className(), function () { + throw new \RuntimeException('uh oh'); + }); $this->expectException(get_class(new RuntimeException())); $this->expectExceptionMessage('uh oh'); @@ -359,15 +366,15 @@ class ControllerTest extends TestCase } // Use the PHP80 controller for this test $this->controller = new FakePhp80Controller('fake', new \yii\web\Application([ - 'id' => 'app', - 'basePath' => __DIR__, - 'components' => [ - 'request' => [ - 'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq', - 'scriptFile' => __DIR__ . '/index.php', - 'scriptUrl' => '/index.php', - ], - ], + 'id' => 'app', + 'basePath' => __DIR__, + 'components' => [ + 'request' => [ + 'cookieValidationKey' => 'wefJDF8sfdsfSDefwqdxj9oq', + 'scriptFile' => __DIR__ . '/index.php', + 'scriptUrl' => '/index.php', + ], + ], ])); $this->mockWebApplication(['controller' => $this->controller]); @@ -376,7 +383,7 @@ class ControllerTest extends TestCase $params = ['foo' => 1]; try { - $args = $this->controller->bindActionParams($injectionAction, $params); + $args = $this->controller->bindActionParams($injectionAction, $params); $this->assertSame(1, $args[0]); } catch (BadRequestHttpException $e) { $this->fail('Failed to bind int param for array|int union type!'); diff --git a/tests/framework/web/CookieCollectionTest.php b/tests/framework/web/CookieCollectionTest.php index 272d98a220..2f5ce34c47 100644 --- a/tests/framework/web/CookieCollectionTest.php +++ b/tests/framework/web/CookieCollectionTest.php @@ -1,4 +1,5 @@ invokeMethod($handler, 'renderException', [new \Exception('Some Exception')]); ob_get_clean(); $out = Yii::$app->response->data; - $this->assertEquals('Exception View -', $out); + $this->assertEquals("Exception View\n", $out); } public function testClearAssetFilesInErrorActionView() @@ -143,7 +143,7 @@ Exception: yii\web\NotFoundHttpException', $out); ], [ "'hello world'", - "'hello world'", + ''hello world'', ], [ 'Chip&Dale', diff --git a/tests/framework/web/FakeController.php b/tests/framework/web/FakeController.php index 0124456f3e..0db3b91011 100644 --- a/tests/framework/web/FakeController.php +++ b/tests/framework/web/FakeController.php @@ -1,4 +1,5 @@ assertEquals('text/plain', $_FILES['Item']['type']['file']); $this->assertStringEqualsFile($_FILES['Item']['tmp_name']['file'], 'item file content'); } + /** * @depends testParse */ @@ -168,7 +170,8 @@ class MultipartFormDataParserTest extends TestCase $this->assertEquals(UPLOAD_ERR_INI_SIZE, $_FILES['thirdFile']['error']); } - public function testUploadFileAsArray(){ + public function testUploadFileAsArray() + { $parser = new MultipartFormDataParser(); $boundary = '---------------------------22472926011618'; diff --git a/tests/framework/web/Post.php b/tests/framework/web/Post.php index 3422273db8..9380de037a 100644 --- a/tests/framework/web/Post.php +++ b/tests/framework/web/Post.php @@ -1,4 +1,5 @@ assertNotEmpty($request->getCsrfToken()); - } + /** * Test CSRF token validation by POST param. */ @@ -534,7 +535,6 @@ class RequestTest extends TestCase $_SERVER = $original; } - public function testSetHostInfo() { $request = new Request(); @@ -564,7 +564,7 @@ class RequestTest extends TestCase $_SERVER = []; $this->expectException(\yii\base\InvalidConfigException::class); - + $request->getScriptUrl(); } @@ -954,28 +954,28 @@ class RequestTest extends TestCase * @param array $server * @param string $expected */ - public function testGetUserIPWithoutTrustedHost($server, $expected) - { - $original = $_SERVER; - $_SERVER = $server; + public function testGetUserIPWithoutTrustedHost($server, $expected) + { + $original = $_SERVER; + $_SERVER = $server; - $request = new Request([ - 'trustedHosts' => [ - '192.168.0.0/24' => ['X-Forwarded-For'], - ], - 'secureHeaders' => [ - 'Front-End-Https', - 'X-Rewrite-Url', - 'X-Forwarded-For', - 'X-Forwarded-Host', - 'X-Forwarded-Proto', - 'forwarded', - ], - ]); - $this->assertEquals($expected, $request->getUserIP()); + $request = new Request([ + 'trustedHosts' => [ + '192.168.0.0/24' => ['X-Forwarded-For'], + ], + 'secureHeaders' => [ + 'Front-End-Https', + 'X-Rewrite-Url', + 'X-Forwarded-For', + 'X-Forwarded-Host', + 'X-Forwarded-Proto', + 'forwarded', + ], + ]); + $this->assertEquals($expected, $request->getUserIP()); - $_SERVER = $original; - } + $_SERVER = $original; + } public function getMethodDataProvider() { @@ -1220,7 +1220,7 @@ class RequestTest extends TestCase $params = [ 'trustedHosts' => $trustedHosts, ]; - if($ipHeaders !== null) { + if ($ipHeaders !== null) { $params['ipHeaders'] = $ipHeaders; } $request = new Request($params); @@ -1271,7 +1271,8 @@ class RequestTest extends TestCase $this->assertSame($expectedMethod, $request->getMethod()); } - public function alreadyResolvedIpDataProvider() { + public function alreadyResolvedIpDataProvider() + { return [ 'resolvedXForwardedFor' => [ '50.0.0.1', @@ -1299,7 +1300,8 @@ class RequestTest extends TestCase /** * @dataProvider alreadyResolvedIpDataProvider */ - public function testAlreadyResolvedIp($remoteAddress, $xForwardedFor, $xForwardedProto, $trustedHosts, $expectedRemoteAddress, $expectedUserIp, $expectedIsSecureConnection) { + public function testAlreadyResolvedIp($remoteAddress, $xForwardedFor, $xForwardedProto, $trustedHosts, $expectedRemoteAddress, $expectedUserIp, $expectedIsSecureConnection) + { $_SERVER['REMOTE_ADDR'] = $remoteAddress; $_SERVER['HTTP_X_FORWARDED_FOR'] = $xForwardedFor; $_SERVER['HTTP_X_FORWARDED_PROTO'] = $xForwardedProto; diff --git a/tests/framework/web/ResponseTest.php b/tests/framework/web/ResponseTest.php index 7a89debf23..ce164d741f 100644 --- a/tests/framework/web/ResponseTest.php +++ b/tests/framework/web/ResponseTest.php @@ -1,4 +1,5 @@ request; + $request = Yii::$app->request; /** @var TestRequestComponent $request */ $request->getIssAjaxOverride = true; $request->getUserAgentOverride = $userAgent; - foreach([true, false] as $pjaxOverride) { + foreach ([true, false] as $pjaxOverride) { $request->getIsPjaxOverride = $pjaxOverride; - foreach(['GET', 'POST'] as $methodOverride) { + foreach (['GET', 'POST'] as $methodOverride) { $request->getMethodOverride = $methodOverride; - foreach($statusCodes as $statusCode => $expectStatusCode) { + foreach ($statusCodes as $statusCode => $expectStatusCode) { $this->assertEquals($expectStatusCode, $this->response->redirect(['view'], $statusCode)->statusCode); } } @@ -208,7 +210,8 @@ class ResponseTest extends \yiiunit\TestCase * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox * @return array */ - public function dataProviderAjaxRedirectInternetExplorer11() { + public function dataProviderAjaxRedirectInternetExplorer11() + { return [ ['Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0', [301 => 301, 302 => 302]], // Firefox ['Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko', [301 => 200, 302 => 200]], // IE 11 @@ -452,14 +455,14 @@ class ResponseTest extends \yiiunit\TestCase * @param $name * @return array|false */ - protected function parseHeaderCookies() { - + protected function parseHeaderCookies() + { if (!function_exists('xdebug_get_headers')) { return false; } $cookies = []; - foreach(xdebug_get_headers() as $header) { + foreach (xdebug_get_headers() as $header) { if (strpos($header, 'Set-Cookie: ') !== 0) { continue; } @@ -467,7 +470,7 @@ class ResponseTest extends \yiiunit\TestCase $name = null; $params = []; $pairs = explode(';', substr($header, 12)); - foreach ($pairs as $index => $pair) { + foreach ($pairs as $index => $pair) { $pair = trim($pair); if (strpos($pair, '=') === false) { $params[strtolower($pair)] = true; diff --git a/tests/framework/web/UploadedFileTest.php b/tests/framework/web/UploadedFileTest.php index 35f0d11086..ead42ad555 100644 --- a/tests/framework/web/UploadedFileTest.php +++ b/tests/framework/web/UploadedFileTest.php @@ -1,4 +1,5 @@ testParse(); + (new MultipartFormDataParserTest())->testParse(); $_FILES['ModelStub'] = $_FILES['Item']; // $_FILES[Item] here from testParse() above $tmpFile = UploadedFile::getInstance($model, 'file'); diff --git a/tests/framework/web/UrlManagerCreateUrlTest.php b/tests/framework/web/UrlManagerCreateUrlTest.php index f56c442582..a5c0850f88 100644 --- a/tests/framework/web/UrlManagerCreateUrlTest.php +++ b/tests/framework/web/UrlManagerCreateUrlTest.php @@ -1,4 +1,5 @@ assertEquals("$prefix/site/index?param2=123", $url); } - /** * Test createUrl() and createAbsoluteUrl() * with varying $showScriptName @@ -522,7 +521,6 @@ class UrlManagerCreateUrlTest extends TestCase $assertations($manager); } - public function absolutePatternsVariations() { $baseUrlConfig = [ diff --git a/tests/framework/web/UrlManagerParseUrlTest.php b/tests/framework/web/UrlManagerParseUrlTest.php index ee09e05bd0..7eab079fcb 100644 --- a/tests/framework/web/UrlManagerParseUrlTest.php +++ b/tests/framework/web/UrlManagerParseUrlTest.php @@ -1,4 +1,5 @@ assertCount(1, $manager->rules); $firstRule = $manager->rules[0]; $this->assertInstanceOf('yii\web\UrlRuleInterface', $firstRule); - $this->assertCount(1, $this->getInaccessibleProperty($arrayCache, '_cache'), + $this->assertCount( + 1, + $this->getInaccessibleProperty($arrayCache, '_cache'), 'Cache contains the only one record that represents initial built rules' ); @@ -405,7 +406,9 @@ class UrlManagerParseUrlTest extends TestCase $this->assertCount(4, $manager->rules); $this->assertSame($firstRule, $manager->rules[0]); - $this->assertCount(3, $this->getInaccessibleProperty($arrayCache, '_cache'), + $this->assertCount( + 3, + $this->getInaccessibleProperty($arrayCache, '_cache'), 'The addRules() method was called twice, adding 3 new rules to the UrlManager, but we have only ' . 'two additional caches: one for each addRules() method call.' ); @@ -460,6 +463,5 @@ class UrlManagerParseUrlTest extends TestCase $result = $manager->parseRequest($this->getRequest('users/somecontroller/someaction')); $this->assertEquals(['site/index', ['url' => 'users/somecontroller/someaction']], $result); - } } diff --git a/tests/framework/web/UrlManagerTest.php b/tests/framework/web/UrlManagerTest.php index 3de942ba8f..15ca7efd88 100644 --- a/tests/framework/web/UrlManagerTest.php +++ b/tests/framework/web/UrlManagerTest.php @@ -1,4 +1,5 @@ assertEquals('/index.php?r=post%2Fview', $url); } - /** * @return array provides different names for UrlManager::$routeParam */ diff --git a/tests/framework/web/UrlNormalizerTest.php b/tests/framework/web/UrlNormalizerTest.php index 236eea0f3a..af2a8911ff 100644 --- a/tests/framework/web/UrlNormalizerTest.php +++ b/tests/framework/web/UrlNormalizerTest.php @@ -1,4 +1,5 @@ user->login(UserIdentity::findIdentity('user1')); -// print_r(Yii::$app->session); -// print_r($_SESSION); + // print_r(Yii::$app->session); + // print_r($_SESSION); $this->mockWebApplication($appConfig); $this->assertFalse(Yii::$app->user->isGuest); @@ -215,6 +216,7 @@ class UserTest extends TestCase ]); Yii::$app->user->setReturnUrl(null); } + public function testLoginRequired() { $appConfig = [ @@ -591,7 +593,6 @@ class MockResponse extends \yii\web\Response class AccessChecker extends BaseObject implements CheckAccessInterface { - public function checkAccess($userId, $permissionName, $params = []) { // Implement checkAccess() method. diff --git a/tests/framework/web/ViewTest.php b/tests/framework/web/ViewTest.php index 1bc25bf57c..c367eec0cc 100644 --- a/tests/framework/web/ViewTest.php +++ b/tests/framework/web/ViewTest.php @@ -1,4 +1,5 @@ assertStringContainsString('', $html); $view = new View(); - $view->registerJsVar('objectTest', + $view->registerJsVar( + 'objectTest', [ 'number' => 42, 'question' => 'Unknown', - ]); + ] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -101,8 +104,10 @@ class ViewTest extends TestCase // with depends $view = new View(); - $view->registerCssFile('@web/css/somefile.css', - ['position' => View::POS_END, 'depends' => 'yii\web\AssetBundle']); + $view->registerCssFile( + '@web/css/somefile.css', + ['position' => View::POS_END, 'depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString('', $html); } @@ -183,24 +188,30 @@ class ViewTest extends TestCase // will be used AssetManager and timestamp $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', - ['depends' => 'yii\web\AssetBundle']); // + $view->registerJsFile( + '/assetSources/js/jquery.js', + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // test append timestamp when @web is prefixed in url \Yii::setAlias('@web', '/test-app'); $view = new View(); - $view->registerJsFile(\Yii::getAlias('@web/assetSources/js/jquery.js'), - ['depends' => 'yii\web\AssetBundle']); // + $view->registerJsFile( + \Yii::getAlias('@web/assetSources/js/jquery.js'), + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // test append timestamp when @web has the same name as the asset-source folder \Yii::setAlias('@web', '/assetSources/'); $view = new View(); - $view->registerJsFile(\Yii::getAlias('@web/assetSources/js/jquery.js'), - ['depends' => 'yii\web\AssetBundle']); // + $view->registerJsFile( + \Yii::getAlias('@web/assetSources/js/jquery.js'), + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // reset aliases @@ -213,15 +224,19 @@ class ViewTest extends TestCase $this->assertMatchesRegularExpression($pattern, $html); $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', - ['appendTimestamp' => true]); // + $view->registerJsFile( + '/assetSources/js/jquery.js', + ['appendTimestamp' => true] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // redefine AssetManager timestamp setting $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', - ['appendTimestamp' => false]); // + $view->registerJsFile( + '/assetSources/js/jquery.js', + ['appendTimestamp' => false] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -234,18 +249,22 @@ class ViewTest extends TestCase // with alias but wo timestamp // redefine AssetManager timestamp setting $view = new View(); - $view->registerJsFile('@web/assetSources/js/jquery.js', + $view->registerJsFile( + '@web/assetSources/js/jquery.js', [ 'appendTimestamp' => false, 'depends' => 'yii\web\AssetBundle', - ]); // + ] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); // wo depends == wo AssetManager $view = new View(); - $view->registerJsFile('@web/assetSources/js/jquery.js', - ['appendTimestamp' => false]); // + $view->registerJsFile( + '@web/assetSources/js/jquery.js', + ['appendTimestamp' => false] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -259,8 +278,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerJsFile('//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', - ['depends' => 'yii\web\AssetBundle']); + $view->registerJsFile( + '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -268,8 +289,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerJsFile('http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', - ['depends' => 'yii\web\AssetBundle']); + $view->registerJsFile( + 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -279,8 +302,10 @@ class ViewTest extends TestCase \Yii::$app->assetManager->appendTimestamp = false; $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', - ['depends' => 'yii\web\AssetBundle']); // + $view->registerJsFile( + '/assetSources/js/jquery.js', + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -290,24 +315,30 @@ class ViewTest extends TestCase $this->assertDoesNotMatchRegularExpression($pattern, $html); $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', - ['appendTimestamp' => true]); // + $view->registerJsFile( + '/assetSources/js/jquery.js', + ['appendTimestamp' => true] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // redefine AssetManager timestamp setting $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', + $view->registerJsFile( + '/assetSources/js/jquery.js', [ 'appendTimestamp' => true, 'depends' => 'yii\web\AssetBundle', - ]); // + ] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); $view = new View(); - $view->registerJsFile('/assetSources/js/jquery.js', - ['appendTimestamp' => false]); // + $view->registerJsFile( + '/assetSources/js/jquery.js', + ['appendTimestamp' => false] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -321,8 +352,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerJsFile('//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', - ['depends' => 'yii\web\AssetBundle']); + $view->registerJsFile( + '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -330,14 +363,15 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerJsFile('http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', - ['depends' => 'yii\web\AssetBundle']); + $view->registerJsFile( + 'http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', $html ); - } public function testAppendTimestampForRegisterCssFile() @@ -359,24 +393,30 @@ class ViewTest extends TestCase // will be used AssetManager and timestamp $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', - ['depends' => 'yii\web\AssetBundle']); // + $view->registerCssFile( + '/assetSources/css/stub.css', + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // test append timestamp when @web is prefixed in url \Yii::setAlias('@web', '/test-app'); $view = new View(); - $view->registerCssFile(\Yii::getAlias('@web/assetSources/css/stub.css'), - ['depends' => 'yii\web\AssetBundle']); // + $view->registerCssFile( + \Yii::getAlias('@web/assetSources/css/stub.css'), + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // test append timestamp when @web has the same name as the asset-source folder \Yii::setAlias('@web', '/assetSources/'); $view = new View(); - $view->registerCssFile(\Yii::getAlias('@web/assetSources/css/stub.css'), - ['depends' => 'yii\web\AssetBundle']); // + $view->registerCssFile( + \Yii::getAlias('@web/assetSources/css/stub.css'), + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // reset aliases @@ -389,15 +429,19 @@ class ViewTest extends TestCase $this->assertMatchesRegularExpression($pattern, $html); $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', - ['appendTimestamp' => true]); // + $view->registerCssFile( + '/assetSources/css/stub.css', + ['appendTimestamp' => true] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // redefine AssetManager timestamp setting $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', - ['appendTimestamp' => false]); // + $view->registerCssFile( + '/assetSources/css/stub.css', + ['appendTimestamp' => false] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -410,18 +454,22 @@ class ViewTest extends TestCase // with alias but wo timestamp // redefine AssetManager timestamp setting $view = new View(); - $view->registerCssFile('@web/assetSources/css/stub.css', + $view->registerCssFile( + '@web/assetSources/css/stub.css', [ 'appendTimestamp' => false, 'depends' => 'yii\web\AssetBundle', - ]); // + ] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); // wo depends == wo AssetManager $view = new View(); - $view->registerCssFile('@web/assetSources/css/stub.css', - ['appendTimestamp' => false]); // + $view->registerCssFile( + '@web/assetSources/css/stub.css', + ['appendTimestamp' => false] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -435,8 +483,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerCssFile('//cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', - ['depends' => 'yii\web\AssetBundle']); + $view->registerCssFile( + '//cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -444,8 +494,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerCssFile('https://cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', - ['depends' => 'yii\web\AssetBundle']); + $view->registerCssFile( + 'https://cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -455,8 +507,10 @@ class ViewTest extends TestCase \Yii::$app->assetManager->appendTimestamp = false; $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', - ['depends' => 'yii\web\AssetBundle']); // + $view->registerCssFile( + '/assetSources/css/stub.css', + ['depends' => 'yii\web\AssetBundle'] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -466,24 +520,30 @@ class ViewTest extends TestCase $this->assertDoesNotMatchRegularExpression($pattern, $html); $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', - ['appendTimestamp' => true]); // + $view->registerCssFile( + '/assetSources/css/stub.css', + ['appendTimestamp' => true] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); // redefine AssetManager timestamp setting $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', + $view->registerCssFile( + '/assetSources/css/stub.css', [ 'appendTimestamp' => true, 'depends' => 'yii\web\AssetBundle', - ]); // + ] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertMatchesRegularExpression($pattern, $html); $view = new View(); - $view->registerCssFile('/assetSources/css/stub.css', - ['appendTimestamp' => false]); // + $view->registerCssFile( + '/assetSources/css/stub.css', + ['appendTimestamp' => false] + ); // $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertDoesNotMatchRegularExpression($pattern, $html); @@ -497,8 +557,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerCssFile('//cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', - ['depends' => 'yii\web\AssetBundle']); + $view->registerCssFile( + '//cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', @@ -506,8 +568,10 @@ class ViewTest extends TestCase ); $view = new View(); - $view->registerCssFile('https://cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', - ['depends' => 'yii\web\AssetBundle']); + $view->registerCssFile( + 'https://cdnjs.cloudflare.com/ajax/libs/balloon-css/1.0.3/balloon.css', + ['depends' => 'yii\web\AssetBundle'] + ); $html = $view->render('@yiiunit/data/views/layout.php', ['content' => 'content']); $this->assertStringContainsString( '', diff --git a/tests/framework/web/XmlResponseFormatterTest.php b/tests/framework/web/XmlResponseFormatterTest.php index a1050ef165..90f64e84ea 100644 --- a/tests/framework/web/XmlResponseFormatterTest.php +++ b/tests/framework/web/XmlResponseFormatterTest.php @@ -1,4 +1,5 @@ getMethodOverride !== null) { + if ($this->getMethodOverride !== null) { return $this->getMethodOverride; } return parent::getMethod(); // TODO: Change the autogenerated stub @@ -69,7 +70,7 @@ class TestRequestComponent extends Request */ public function getUserAgent() { - if($this->getUserAgentOverride !== null) { + if ($this->getUserAgentOverride !== null) { return $this->getUserAgentOverride; } return parent::getUserAgent(); diff --git a/tests/framework/web/session/AbstractDbSessionTest.php b/tests/framework/web/session/AbstractDbSessionTest.php index 2fe0fa2cdf..e88122b805 100644 --- a/tests/framework/web/session/AbstractDbSessionTest.php +++ b/tests/framework/web/session/AbstractDbSessionTest.php @@ -1,4 +1,5 @@ set('user_id', 12345); // add mapped custom column - $migration = new Migration; + $migration = new Migration(); $migration->compact = true; $migration->addColumn($session->sessionTable, 'user_id', $migration->integer()); diff --git a/tests/framework/web/session/CacheSessionTest.php b/tests/framework/web/session/CacheSessionTest.php index cc62e1b368..f8cbee55b8 100644 --- a/tests/framework/web/session/CacheSessionTest.php +++ b/tests/framework/web/session/CacheSessionTest.php @@ -1,4 +1,5 @@ activeField->attribute = '[0]'.$this->attributeName; + $this->activeField->attribute = '[0]' . $this->attributeName; $this->helperModel->addError($this->attributeName, 'Error Message'); $expectedValue = '
'; @@ -845,14 +846,17 @@ class TestMaskedInput extends MaskedInput self::$lastInstance = $this; } - public function getOptions() { + public function getOptions() + { return $this->options; } public function run() { return 'Options: ' . implode(', ', array_map( - function ($v, $k) { return sprintf('%s="%s"', $k, $v); }, + function ($v, $k) { + return sprintf('%s="%s"', $k, $v); + }, $this->options, array_keys($this->options) )); @@ -866,4 +870,3 @@ class TestActiveFieldWithException extends ActiveField throw new \Exception('Test exception in toString.'); } } - diff --git a/tests/framework/widgets/ActiveFormTest.php b/tests/framework/widgets/ActiveFormTest.php index 313b345907..d017f286a3 100644 --- a/tests/framework/widgets/ActiveFormTest.php +++ b/tests/framework/widgets/ActiveFormTest.php @@ -1,4 +1,5 @@ assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
-EOF -, (string) $form->field($model, 'name', $o)->input('email', ['required' => true])); +EOF, + (string) $form->field($model, 'name', $o)->input('email', ['required' => true]) + ); - $this->assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
-EOF - , (string) $form->field($model, 'name', $o)->input('email', ['required' => false])); +EOF, + (string) $form->field($model, 'name', $o)->input('email', ['required' => false]) + ); - $this->assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
-EOF - , (string) $form->field($model, 'name', $o)->input('email', ['required' => 'test'])); +EOF, + (string) $form->field($model, 'name', $o)->input('email', ['required' => 'test']) + ); } public function testIssue5356() @@ -68,7 +75,8 @@ EOF ob_end_clean(); // https://github.com/yiisoft/yii2/issues/5356 - $this->assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
-EOF - , (string) $form->field($model, 'categories', $o)->listBox(['apple', 'banana', 'avocado'], ['multiple' => true])); +EOF, + (string) $form->field($model, 'categories', $o)->listBox(['apple', 'banana', 'avocado'], ['multiple' => true]) + ); } public function testOutputBuffering() @@ -95,7 +104,8 @@ EOF $this->assertEquals($obLevel, ob_get_level(), 'Output buffers not closed correctly.'); - $this->assertEqualsWithoutLE(<<<'HTML' + $this->assertEqualsWithoutLE( + <<<'HTML'
@@ -104,8 +114,9 @@ EOF
-HTML -, $content); +HTML, + $content + ); } public function testRegisterClientScript() @@ -175,35 +186,41 @@ HTML ActiveForm::end(); ob_end_clean(); - $this->assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
I have an error!
-EOF - , (string) $form->field($model, 'name')); +EOF, + (string) $form->field($model, 'name') + ); - $this->assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
I have an error!
-EOF - , (string) $form->field($model, 'name')->checkbox()); +EOF, + (string) $form->field($model, 'name')->checkbox() + ); - $this->assertEqualsWithoutLE(<<<'EOF' + $this->assertEqualsWithoutLE( + <<<'EOF'
I have an error!
-EOF - , (string) $form->field($model, 'name')->radio()); +EOF, + (string) $form->field($model, 'name')->radio() + ); } } diff --git a/tests/framework/widgets/BlockTest.php b/tests/framework/widgets/BlockTest.php index a6b6d7fc9c..50ed5fceb7 100644 --- a/tests/framework/widgets/BlockTest.php +++ b/tests/framework/widgets/BlockTest.php @@ -1,4 +1,5 @@ assertEquals($expectedHtml, $actualHtml); } - public function testHomeLink() { $this->breadcrumbs->homeLink = ['label' => 'home-link']; diff --git a/tests/framework/widgets/ContentDecoratorTest.php b/tests/framework/widgets/ContentDecoratorTest.php index c33c507ea7..5af53edcbc 100644 --- a/tests/framework/widgets/ContentDecoratorTest.php +++ b/tests/framework/widgets/ContentDecoratorTest.php @@ -1,4 +1,5 @@ setOutputCallback(function($output) { + $this->setOutputCallback(function ($output) { return null; }); diff --git a/tests/framework/widgets/LinkPagerTest.php b/tests/framework/widgets/LinkPagerTest.php index 92a652f42b..43efb8c39c 100644 --- a/tests/framework/widgets/LinkPagerTest.php +++ b/tests/framework/widgets/LinkPagerTest.php @@ -1,4 +1,5 @@ assertNotFalse(strpos($actualHtml, - 'Customer')); - $this->assertNotFalse(strpos($actualHtml, - 'Invoice Total')); + $this->assertNotFalse(strpos( + $actualHtml, + 'Customer' + )); + $this->assertNotFalse(strpos( + $actualHtml, + 'Invoice Total' + )); } public function testLabelsExplicit() @@ -72,10 +77,14 @@ class LinkSorterTest extends DatabaseTestCase ]); $actualHtml = ob_get_clean(); - $this->assertFalse(strpos($actualHtml, - 'Customer')); - $this->assertNotFalse(strpos($actualHtml, - 'Invoice Total')); + $this->assertFalse(strpos( + $actualHtml, + 'Customer' + )); + $this->assertNotFalse(strpos( + $actualHtml, + 'Invoice Total' + )); } /** diff --git a/tests/framework/widgets/ListViewTest.php b/tests/framework/widgets/ListViewTest.php index 8f01b9e78b..a00caede36 100644 --- a/tests/framework/widgets/ListViewTest.php +++ b/tests/framework/widgets/ListViewTest.php @@ -1,4 +1,5 @@ run(); $out = ob_get_clean(); - $this->assertEqualsWithoutLE(<<<'HTML' + $this->assertEqualsWithoutLE( + <<<'HTML'
-HTML - , $out); +HTML, + $out + ); } /** @@ -97,14 +100,16 @@ HTML $this->getListView()->run(); $out = ob_get_clean(); - $this->assertEqualsWithoutLE(<<<'HTML' + $this->assertEqualsWithoutLE( + <<<'HTML'
Showing 1-3 of 3 items.
0
1
2
-HTML - , $out); +HTML, + $out + ); } public function testWidgetOptions() @@ -113,12 +118,14 @@ HTML $this->getListView(['options' => ['class' => 'test-passed'], 'separator' => ''])->run(); $out = ob_get_clean(); - $this->assertEqualsWithoutLE(<<<'HTML' + $this->assertEqualsWithoutLE( + <<<'HTML'
Showing 1-3 of 3 items.
0
1
2
-HTML - , $out); +HTML, + $out + ); } public function itemViewOptions() @@ -234,7 +241,8 @@ HTML ])->run(); $out = ob_get_clean(); - $this->assertEqualsWithoutLE(<<assertEqualsWithoutLE( + <<
Showing 1-3 of 3 items.
0
@@ -245,9 +253,9 @@ HTML
2
-HTML - , $out -); +HTML, + $out + ); } /** diff --git a/tests/framework/widgets/MenuTest.php b/tests/framework/widgets/MenuTest.php index 43809672d2..b59a1773b7 100644 --- a/tests/framework/widgets/MenuTest.php +++ b/tests/framework/widgets/MenuTest.php @@ -1,4 +1,5 @@ mockWebApplication([ - 'components'=>[ + 'components' => [ 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, @@ -319,7 +320,7 @@ HTML; [ 'label' => 'another item', // use non relative route to avoid error in BaseUrl::normalizeRoute (missing controller) - 'url' => ['/test/another'], + 'url' => ['/test/another'], 'template' => 'label: {label}; url: {url}', ], [ @@ -330,7 +331,7 @@ HTML; return $widget->route === 'test/logic'; }, ], - + ], ], ], @@ -456,19 +457,19 @@ HTML; $output = Menu::widget([ 'route' => 'test/item2', 'params' => [ - 'page'=>'5', + 'page' => '5', ], 'items' => [ [ 'label' => 'item1', - 'url' => ['/test/item1'] + 'url' => ['/test/item1'] ], [ 'label' => 'item2', // use non relative route to avoid error in BaseUrl::normalizeRoute (missing controller) - 'url' => ['/test/item2','page'=>'5'] + 'url' => ['/test/item2','page' => '5'] ], - + ], ]); diff --git a/tests/framework/widgets/PjaxTest.php b/tests/framework/widgets/PjaxTest.php index 209fa16e0c..adab82eee9 100644 --- a/tests/framework/widgets/PjaxTest.php +++ b/tests/framework/widgets/PjaxTest.php @@ -1,4 +1,5 @@