mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Raised minimum PHP version to 8.1 (#19879)
This commit is contained in:
@ -4,7 +4,7 @@ clone_folder: C:\projects\yii2
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- php_ver: 7.2.4
|
||||
- php_ver: 8.1.20
|
||||
|
||||
cache:
|
||||
- '%APPDATA%\Composer'
|
||||
@ -30,7 +30,7 @@ install:
|
||||
- echo extension=php_mbstring.dll >> php.ini
|
||||
- echo extension=php_openssl.dll >> php.ini
|
||||
- echo extension=php_pdo_sqlite.dll >> php.ini
|
||||
- IF NOT EXIST C:\tools\composer.phar (cd C:\tools && appveyor DownloadFile https://getcomposer.org/download/1.4.1/composer.phar)
|
||||
- IF NOT EXIST C:\tools\composer.phar (cd C:\tools && appveyor DownloadFile https://getcomposer.org/download/2.5.8/composer.phar)
|
||||
|
||||
before_test:
|
||||
- cd C:\projects\yii2
|
||||
@ -38,4 +38,4 @@ before_test:
|
||||
|
||||
test_script:
|
||||
- cd C:\projects\yii2
|
||||
- vendor\bin\phpunit --exclude-group mssql,mysql,pgsql,sqlite,db,oci,wincache,xcache,zenddata,cubrid
|
||||
- vendor\bin\phpunit --exclude-group db,wincache,xcache,zenddata
|
||||
|
72
.github/workflows/build.yml
vendored
72
.github/workflows/build.yml
vendored
@ -4,8 +4,8 @@ on: [push, pull_request]
|
||||
|
||||
env:
|
||||
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
|
||||
EXTENSIONS: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached, pdo, pdo_sqlite, sqlite
|
||||
PHPUNIT_EXCLUDE_GROUP: db,wincache,xcache,zenddata
|
||||
XDEBUG_MODE: coverage, develop
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@ -20,51 +20,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.4
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 5.5
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 5.6
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 7.0
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 7.1
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 7.2
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 7.3
|
||||
coverage: none
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 7.4
|
||||
coverage: xdebug
|
||||
extensions: apc, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 8.0
|
||||
coverage: none
|
||||
extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 8.1
|
||||
coverage: none
|
||||
extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
os: ubuntu-latest
|
||||
- php: 8.2
|
||||
extensions: apcu, curl, dom, imagick, intl, mbstring, mcrypt, memcached
|
||||
coverage: none
|
||||
os: ubuntu-latest
|
||||
os: [ubuntu-latest]
|
||||
php: [8.1, 8.2]
|
||||
|
||||
steps:
|
||||
- name: Generate french locale.
|
||||
@ -76,8 +33,8 @@ jobs:
|
||||
- name: Install PHP.
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: ${{ matrix.coverage }}
|
||||
extensions: ${{ matrix.extensions }}
|
||||
coverage: pcov
|
||||
extensions: ${{ env.EXTENSIONS }}
|
||||
ini-values: apc.enabled=1,apc.shm_size=32M,apc.enable_cli=1, date.timezone='UTC', session.save_path="${{ runner.temp }}"
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: pecl
|
||||
@ -88,20 +45,17 @@ jobs:
|
||||
- name: Install dependencies.
|
||||
run: composer update $DEFAULT_COMPOSER_FLAGS
|
||||
|
||||
- name: Run tests with PHPUnit.
|
||||
if: matrix.php < '7.4' || matrix.php >= '8.1'
|
||||
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always
|
||||
|
||||
- name: Run tests with PHPUnit.
|
||||
if: matrix.php == '8.0'
|
||||
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always
|
||||
|
||||
- name: Run tests with PHPUnit and generate coverage.
|
||||
if: matrix.php == '7.4'
|
||||
run: vendor/bin/phpunit --verbose --exclude-group $PHPUNIT_EXCLUDE_GROUP --coverage-clover=coverage.xml --colors=always
|
||||
if: matrix.php == '8.1'
|
||||
run: vendor/bin/phpunit --coverage-clover=coverage.xml --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always --verbose
|
||||
|
||||
- name: Run tests with PHPUnit.
|
||||
if: matrix.php != '8.1'
|
||||
run: vendor/bin/phpunit --exclude-group $PHPUNIT_EXCLUDE_GROUP --colors=always --verbose
|
||||
|
||||
|
||||
- name: Upload coverage to Codecov.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
|
41
.github/workflows/ci-mssql.yml
vendored
41
.github/workflows/ci-mssql.yml
vendored
@ -13,22 +13,23 @@ jobs:
|
||||
name: PHP ${{ matrix.php }}-mssql-${{ matrix.mssql }}
|
||||
|
||||
env:
|
||||
EXTENSIONS: pdo, pdo_sqlsrv
|
||||
XDEBUG_MODE: coverage, develop
|
||||
EXTENSIONS: pdo, pdo_sqlsrv-5.10.1
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- php: 7.4
|
||||
mssql: server:2017-latest
|
||||
- php: 8.0
|
||||
mssql: server:2019-latest
|
||||
- php: 8.1
|
||||
mssql: server:2019-latest
|
||||
- php: 8.2
|
||||
mssql: server:2022-latest
|
||||
os:
|
||||
- ubuntu-latest
|
||||
|
||||
php:
|
||||
- 8.1
|
||||
- 8.2
|
||||
|
||||
mssql:
|
||||
- server:2017-latest
|
||||
- server:2019-latest
|
||||
- server:2022-latest
|
||||
|
||||
services:
|
||||
mssql:
|
||||
@ -42,37 +43,37 @@ jobs:
|
||||
options: --name=mssql --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'SELECT 1'" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
- name: Checkout.
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Create MS SQL Database
|
||||
- name: Create MS SQL Database.
|
||||
run: docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest'
|
||||
|
||||
- name: Install PHP with extensions
|
||||
- name: Install PHP with extensions.
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: xdebug
|
||||
coverage: pcov
|
||||
extensions: ${{ env.EXTENSIONS }}
|
||||
ini-values: date.timezone='UTC'
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: composer:v2, pecl
|
||||
|
||||
- name: Update composer
|
||||
- name: Update composer.
|
||||
run: composer self-update
|
||||
|
||||
- name: Install dependencies with composer
|
||||
- name: Install dependencies with composer.
|
||||
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
|
||||
|
||||
- name: Run MSSQL tests with PHPUnit and generate coverage.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
run: vendor/bin/phpunit --group mssql --coverage-clover=coverage.xml --colors=always
|
||||
|
||||
- name: Run MSSQL tests with PHPUnit.
|
||||
if: matrix.php > '7.4'
|
||||
if: matrix.php != '8.1'
|
||||
run: vendor/bin/phpunit --group mssql --colors=always
|
||||
|
||||
- name: Upload coverage to Codecov.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
|
14
.github/workflows/ci-mysql.yml
vendored
14
.github/workflows/ci-mysql.yml
vendored
@ -12,8 +12,7 @@ jobs:
|
||||
tests:
|
||||
name: PHP ${{ matrix.php }}-mysql-${{ matrix.mysql }}
|
||||
env:
|
||||
extensions: curl, intl, pdo, pdo_mysql
|
||||
XDEBUG_MODE: coverage, develop
|
||||
EXTENSIONS: curl, intl, pdo, pdo_mysql
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@ -23,8 +22,6 @@ jobs:
|
||||
- ubuntu-latest
|
||||
|
||||
php:
|
||||
- 7.4
|
||||
- 8.0
|
||||
- 8.1
|
||||
- 8.2
|
||||
|
||||
@ -49,7 +46,7 @@ jobs:
|
||||
- name: Install PHP with extensions.
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: xdebug
|
||||
coverage: pcov
|
||||
extensions: ${{ env.EXTENSIONS }}
|
||||
ini-values: date.timezone='UTC'
|
||||
php-version: ${{ matrix.php }}
|
||||
@ -59,15 +56,16 @@ jobs:
|
||||
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
|
||||
|
||||
- name: Run MySQL tests with PHPUnit and generate coverage.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
run: vendor/bin/phpunit --group mysql --coverage-clover=coverage.xml --colors=always
|
||||
|
||||
- name: Run MySQL tests with PHPUnit.
|
||||
if: matrix.php > '7.4'
|
||||
if: matrix.php != '8.1'
|
||||
run: vendor/bin/phpunit --group mysql --colors=always
|
||||
|
||||
- name: Upload coverage to Codecov.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
|
||||
|
15
.github/workflows/ci-oracle.yml
vendored
15
.github/workflows/ci-oracle.yml
vendored
@ -10,11 +10,10 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: PHP ${{ matrix.php }}-${{ matrix.os }}
|
||||
name: PHP ${{ matrix.php }}-oracle-11g-r2
|
||||
|
||||
env:
|
||||
extensions: oci8, pdo, pdo_oci
|
||||
XDEBUG_MODE: coverage, develop
|
||||
EXTENSIONS: oci8, pdo, pdo_oci
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@ -24,7 +23,10 @@ jobs:
|
||||
- ubuntu-latest
|
||||
|
||||
php:
|
||||
- 7.4
|
||||
- 8.1
|
||||
|
||||
oracle:
|
||||
- 11
|
||||
|
||||
services:
|
||||
oci:
|
||||
@ -40,15 +42,12 @@ jobs:
|
||||
- name: Install PHP with extensions.
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: xdebug
|
||||
coverage: pcov
|
||||
extensions: ${{ env.EXTENSIONS }}
|
||||
ini-values: date.timezone='UTC'
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: composer:v2, pecl
|
||||
|
||||
- name: Update composer.
|
||||
run: composer self-update
|
||||
|
||||
- name: Install dependencies with composer.
|
||||
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
|
||||
|
||||
|
21
.github/workflows/ci-pgsql.yml
vendored
21
.github/workflows/ci-pgsql.yml
vendored
@ -12,8 +12,7 @@ jobs:
|
||||
tests:
|
||||
name: PHP ${{ matrix.php }}-pgsql-${{ matrix.pgsql }}
|
||||
env:
|
||||
extensions: curl, intl, pdo, pdo_pgsql
|
||||
XDEBUG_MODE: coverage, develop
|
||||
EXTENSIONS: curl, intl, pdo, pdo_pgsql
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@ -23,9 +22,8 @@ jobs:
|
||||
- ubuntu-latest
|
||||
|
||||
php:
|
||||
- 7.4
|
||||
- 8.0
|
||||
- 8.1
|
||||
- 8.2
|
||||
|
||||
pgsql:
|
||||
- 10
|
||||
@ -50,31 +48,28 @@ jobs:
|
||||
- name: Checkout.
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install PHP with extensions
|
||||
- name: Install PHP with extensions.
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: xdebug
|
||||
coverage: pcov
|
||||
extensions: ${{ env.EXTENSIONS }}
|
||||
ini-values: date.timezone='UTC'
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: composer:v2, pecl
|
||||
|
||||
- name: Update composer.
|
||||
run: composer self-update
|
||||
|
||||
- name: Install dependencies with composer.
|
||||
- name: Install dependencies with composer
|
||||
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
|
||||
|
||||
- name: Run Pgsql tests with PHPUnit and generate coverage.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
run: vendor/bin/phpunit --group pgsql --coverage-clover=coverage.xml --colors=always
|
||||
|
||||
- name: Run Pgsql tests with PHPUnit.
|
||||
if: matrix.php > '7.4'
|
||||
if: matrix.php != '8.1'
|
||||
run: vendor/bin/phpunit --group pgsql --colors=always
|
||||
|
||||
- name: Upload coverage to Codecov.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
|
12
.github/workflows/ci-sqlite.yml
vendored
12
.github/workflows/ci-sqlite.yml
vendored
@ -14,7 +14,6 @@ jobs:
|
||||
|
||||
env:
|
||||
EXTENSIONS: pdo, pdo_sqlite, sqlite3
|
||||
XDEBUG_MODE: coverage, develop
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@ -24,8 +23,6 @@ jobs:
|
||||
- ubuntu-latest
|
||||
|
||||
php:
|
||||
- 7.4
|
||||
- 8.0
|
||||
- 8.1
|
||||
- 8.2
|
||||
|
||||
@ -36,7 +33,7 @@ jobs:
|
||||
- name: Install PHP with extensions.
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
coverage: xdebug
|
||||
coverage: pcov
|
||||
extensions: ${{ env.EXTENSIONS }}
|
||||
ini-values: date.timezone='UTC'
|
||||
php-version: ${{ matrix.php }}
|
||||
@ -49,15 +46,16 @@ jobs:
|
||||
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
|
||||
|
||||
- name: Run SQLite tests with PHPUnit and generate coverage.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
continue-on-error: true
|
||||
run: vendor/bin/phpunit --group sqlite --coverage-clover=coverage.xml --colors=always
|
||||
|
||||
- name: Run SQLite tests with PHPUnit.
|
||||
if: matrix.php > '7.4'
|
||||
if: matrix.php != '8.1'
|
||||
run: vendor/bin/phpunit --group sqlite --colors=always
|
||||
|
||||
- name: Upload coverage to Codecov.
|
||||
if: matrix.php == '7.4'
|
||||
if: matrix.php == '8.1'
|
||||
uses: codecov/codecov-action@v3
|
||||
with:
|
||||
file: ./coverage.xml
|
||||
|
@ -16,7 +16,7 @@ build:
|
||||
|
||||
environment:
|
||||
php:
|
||||
version: 7.4.28
|
||||
version: 8.1.20
|
||||
ini:
|
||||
xdebug.mode: coverage,develop
|
||||
memory_limit: -1
|
||||
@ -84,7 +84,7 @@ build:
|
||||
- sudo locale-gen fr_FR.UTF-8
|
||||
|
||||
override:
|
||||
- command: ./vendor/bin/phpunit --verbose --exclude-group cubrid,oci,mssql,wincache,xcache,zenddata --colors=always --coverage-clover ./coverage.xml
|
||||
- command: ./vendor/bin/phpunit --verbose --exclude-group db,wincache,xcache,zenddata --colors=always --coverage-clover ./coverage.xml
|
||||
on_node: 1
|
||||
coverage:
|
||||
file: coverage.xml
|
||||
|
@ -12,7 +12,7 @@ The framework is easy to adjust to meet your needs, because Yii has been designe
|
||||
[](https://packagist.org/packages/yiisoft/yii2)
|
||||
[](https://packagist.org/packages/yiisoft/yii2)
|
||||
[](https://github.com/yiisoft/yii2/actions)
|
||||
[](https://scrutinizer-ci.com/g/yiisoft/yii2/)
|
||||
[](https://codecov.io/gh/yiisoft/yii2)
|
||||
[](https://scrutinizer-ci.com/g/yiisoft/yii2/)
|
||||
|
||||
Installation
|
||||
|
@ -68,7 +68,7 @@
|
||||
"yiisoft/yii2": "self.version"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"php": ">=8.1",
|
||||
"ext-mbstring": "*",
|
||||
"ext-ctype": "*",
|
||||
"lib-pcre": "*",
|
||||
@ -82,11 +82,10 @@
|
||||
"paragonie/random_compat": ">=1"
|
||||
},
|
||||
"require-dev": {
|
||||
"cweagans/composer-patches": "^1.7",
|
||||
"phpunit/phpunit": "4.8.34",
|
||||
"dms/phpunit-arraysubset-asserts": "^0.5",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"cebe/indent": "~1.0.2",
|
||||
"friendsofphp/php-cs-fixer": "~2.2.3 | ^3.0",
|
||||
"johnkary/phpunit-speedtrap": "^1.0"
|
||||
"friendsofphp/php-cs-fixer": "^3.0"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
@ -121,20 +120,6 @@
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
},
|
||||
"composer-exit-on-patch-failure": true,
|
||||
"patches": {
|
||||
"phpunit/phpunit-mock-objects": {
|
||||
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
|
||||
},
|
||||
"phpunit/php-file-iterator": {
|
||||
"Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_path_file_iterator.patch"
|
||||
},
|
||||
"phpunit/phpunit": {
|
||||
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
|
||||
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch",
|
||||
"Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php81.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1835
composer.lock
generated
1835
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @link https://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license https://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\base;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* Object is the base class that implements the *property* feature.
|
||||
*
|
||||
* It has been replaced by [[BaseObject]] in version 2.0.13 because `object` has become a reserved word which can not be
|
||||
* used as class name in PHP 7.2.
|
||||
*
|
||||
* Please refer to [[BaseObject]] for detailed documentation and to the
|
||||
* [UPGRADE notes](https://github.com/yiisoft/yii2/blob/2.0.13/framework/UPGRADE.md#upgrade-from-yii-2012)
|
||||
* on how to migrate your application to use [[BaseObject]] class to make your application compatible with PHP 7.2.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @since 2.0
|
||||
* @deprecated since 2.0.13, the class name `Object` is invalid since PHP 7.2, use [[BaseObject]] instead.
|
||||
* @see https://wiki.php.net/rfc/object-typehint
|
||||
* @see https://github.com/yiisoft/yii2/issues/7936#issuecomment-315384669
|
||||
*/
|
||||
class Object extends BaseObject
|
||||
{
|
||||
}
|
@ -43,7 +43,6 @@ return [
|
||||
'yii\base\ModelEvent' => YII2_PATH . '/base/ModelEvent.php',
|
||||
'yii\base\Module' => YII2_PATH . '/base/Module.php',
|
||||
'yii\base\NotSupportedException' => YII2_PATH . '/base/NotSupportedException.php',
|
||||
'yii\base\Object' => YII2_PATH . '/base/Object.php',
|
||||
'yii\base\Request' => YII2_PATH . '/base/Request.php',
|
||||
'yii\base\Response' => YII2_PATH . '/base/Response.php',
|
||||
'yii\base\Security' => YII2_PATH . '/base/Security.php',
|
||||
|
@ -63,7 +63,7 @@
|
||||
"source": "https://github.com/yiisoft/yii2"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.4.0",
|
||||
"php": ">=8.1",
|
||||
"ext-mbstring": "*",
|
||||
"ext-ctype": "*",
|
||||
"lib-pcre": "*",
|
||||
|
@ -516,6 +516,10 @@ abstract class Schema extends BaseObject
|
||||
*/
|
||||
public function quoteColumnName($name)
|
||||
{
|
||||
if ($name === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (strpos($name, '(') !== false || strpos($name, '[[') !== false) {
|
||||
return $name;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
"doc": "docs",
|
||||
"test": "tests/js/tests"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"jsdom": "11.11.0",
|
||||
|
@ -1,30 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<phpunit bootstrap="./tests/bootstrap.php"
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
backupGlobals="true"
|
||||
bootstrap="./tests/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
executionOrder="default"
|
||||
failOnRisky="true"
|
||||
failOnWarning="true"
|
||||
printerClass="yiiunit\ResultPrinter"
|
||||
stopOnFailure="false"
|
||||
printerClass="yiiunit\ResultPrinter">
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="Yii Test Suite">
|
||||
<directory>./tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">framework/</directory>
|
||||
</whitelist>
|
||||
<blacklist>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>framework/.phpstorm.meta.php</file>
|
||||
<file>framework/i18n/GettextFile.php</file>
|
||||
<file>framework/web/ResponseFormatterInterface.php</file>
|
||||
<file>framework/.phpstorm.meta.php</file>
|
||||
<directory suffix="Exception.php">framework/base</directory>
|
||||
<directory suffix=".php">framework/bootstrap</directory>
|
||||
</blacklist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||
</listeners>
|
||||
<directory suffix="Exception.php">framework/base</directory>
|
||||
<directory suffix=".php">framework/requirements</directory>
|
||||
</exclude>
|
||||
</coverage>
|
||||
</phpunit>
|
||||
|
@ -14,38 +14,29 @@ use yii\helpers\VarDumper;
|
||||
*/
|
||||
class IsOneOfAssert extends \PHPUnit\Framework\Constraint\Constraint
|
||||
{
|
||||
private $allowedValues;
|
||||
|
||||
/**
|
||||
* IsOneOfAssert constructor.
|
||||
* @param array $allowedValues
|
||||
*/
|
||||
public function __construct(array $allowedValues)
|
||||
/** @psalm-param string[] $allowedValues */
|
||||
public function __construct(private array $allowedValues)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->allowedValues = $allowedValues;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a string representation of the object.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString()
|
||||
public function toString(): string
|
||||
{
|
||||
$allowedValues = array_map(function ($value) {
|
||||
return VarDumper::dumpAsString($value);
|
||||
}, $this->allowedValues);
|
||||
$allowedValues = [];
|
||||
|
||||
foreach ($this->allowedValues as $value) {
|
||||
$this->allowedValues[] = VarDumper::create($value)->asString();
|
||||
}
|
||||
|
||||
$expectedAsString = implode(', ', $allowedValues);
|
||||
|
||||
return "is one of $expectedAsString";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function matches($other)
|
||||
protected function matches($other): bool
|
||||
{
|
||||
return in_array($other, $this->allowedValues, false);
|
||||
return in_array($other, $this->allowedValues);
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,16 @@ namespace yiiunit;
|
||||
* to change default output to STDOUT and prevent some tests from fail when
|
||||
* they can not be executed after headers have been sent.
|
||||
*/
|
||||
class ResultPrinter extends \PHPUnit\TextUI\ResultPrinter
|
||||
class ResultPrinter extends \PHPUnit\TextUI\DefaultResultPrinter
|
||||
{
|
||||
/**
|
||||
* @param null|resource|string $out
|
||||
* @param int|string $numberOfColumns
|
||||
*/
|
||||
public function __construct(
|
||||
$out = null,
|
||||
private $out = null,
|
||||
$verbose = false,
|
||||
$colors = \PHPUnit\TextUI\ResultPrinter::COLOR_DEFAULT,
|
||||
$colors = \PHPUnit\TextUI\DefaultResultPrinter::COLOR_DEFAULT,
|
||||
$debug = false,
|
||||
$numberOfColumns = 80,
|
||||
$reverse = false
|
||||
@ -29,7 +33,7 @@ class ResultPrinter extends \PHPUnit\TextUI\ResultPrinter
|
||||
parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns, $reverse);
|
||||
}
|
||||
|
||||
public function flush()
|
||||
public function flush(): void
|
||||
{
|
||||
if ($this->out !== STDOUT) {
|
||||
parent::flush();
|
||||
|
@ -20,7 +20,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
/**
|
||||
* Clean up after test case.
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
parent::tearDownAfterClass();
|
||||
$logger = Yii::getLogger();
|
||||
@ -46,7 +46,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
* Clean up after test.
|
||||
* By default the application created with [[mockApplication]] will be destroyed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->destroyApplication();
|
||||
@ -168,7 +168,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
$needle = str_replace("\r\n", "\n", $needle);
|
||||
$haystack = str_replace("\r\n", "\n", $haystack);
|
||||
|
||||
$this->assertContains($needle, $haystack, $message);
|
||||
$this->assertStringContainsString($needle, $haystack, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,5 +28,4 @@ if (getenv('TEST_RUNTIME_PATH')) {
|
||||
Yii::setAlias('@runtime', getenv('TEST_RUNTIME_PATH'));
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/compatibility.php';
|
||||
require_once __DIR__ . '/TestCase.php';
|
||||
|
@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @link https://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license https://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ensures compatibility with PHPUnit < 6.x
|
||||
*/
|
||||
|
||||
namespace PHPUnit\Framework\Constraint {
|
||||
if (!class_exists('PHPUnit\Framework\Constraint\Constraint') && class_exists('PHPUnit_Framework_Constraint')) {
|
||||
abstract class Constraint extends \PHPUnit_Framework_Constraint
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PHPUnit\TextUI {
|
||||
if (!class_exists('\PHPUnit\TextUI\ResultPrinter') && class_exists('PHPUnit_TextUI_ResultPrinter')) {
|
||||
class ResultPrinter extends \PHPUnit_TextUI_ResultPrinter
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PHPUnit\Framework\Error {
|
||||
if (!class_exists('PHPUnit\Framework\Error\Notice') && class_exists('PHPUnit_Framework_Error_Notice')) {
|
||||
class Notice extends \PHPUnit_Framework_Error_Notice
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PHPUnit\Framework {
|
||||
if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
|
||||
abstract class TestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $exception
|
||||
*/
|
||||
public function expectException($exception)
|
||||
{
|
||||
$this->setExpectedException($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
*/
|
||||
public function expectExceptionMessage($message)
|
||||
{
|
||||
$parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
|
||||
if (in_array('expectExceptionMessage', $parentClassMethods)) {
|
||||
parent::expectExceptionMessage($message);
|
||||
return;
|
||||
}
|
||||
$this->setExpectedException($this->getExpectedException(), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $messageRegExp
|
||||
*/
|
||||
public function expectExceptionMessageRegExp($messageRegExp)
|
||||
{
|
||||
$parentClassMethods = get_class_methods('PHPUnit_Framework_TestCase');
|
||||
if (in_array('expectExceptionMessageRegExp', $parentClassMethods)) {
|
||||
parent::expectExceptionMessageRegExp($messageRegExp);
|
||||
return;
|
||||
}
|
||||
$this->setExpectedExceptionRegExp($this->getExpectedException(), $messageRegExp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -26,13 +26,13 @@ class BaseYiiTest extends TestCase
|
||||
{
|
||||
public $aliases;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->aliases = Yii::$aliases;
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Yii::$aliases = $this->aliases;
|
||||
@ -72,7 +72,7 @@ class BaseYiiTest extends TestCase
|
||||
|
||||
public function testPowered()
|
||||
{
|
||||
$this->assertInternalType('string', Yii::powered());
|
||||
$this->assertIsString(Yii::powered());
|
||||
}
|
||||
|
||||
public function testCreateObjectArray()
|
||||
|
@ -15,7 +15,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ChangeLogTest extends TestCase
|
||||
{
|
||||
public function changeProvider()
|
||||
public static function changeProvider()
|
||||
{
|
||||
|
||||
$lines = preg_split("~\R~", file_get_contents(__DIR__ . '/../../framework/CHANGELOG.md'), -1, PREG_SPLIT_NO_EMPTY);
|
||||
@ -54,6 +54,6 @@ class ChangeLogTest extends TestCase
|
||||
* - Description ends without a "."
|
||||
* - Line ends with contributor name between "(" and ")".
|
||||
*/
|
||||
$this->assertRegExp('/- (Bug|Enh|Chg|New)( #\d+(, #\d+)*)?(\s\(CVE-[\d-]+\))?: .*[^.] \(.+\)$/', $line);
|
||||
$this->assertMatchesRegularExpression('/- (Bug|Enh|Chg|New)( #\d+(, #\d+)*)?(\s\(CVE-[\d-]+\))?: .*[^.] \(.+\)$/', $line);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ActionFilterTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
@ -87,7 +87,7 @@ class ActionFilterTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
public function actionFilterProvider()
|
||||
public static function actionFilterProvider()
|
||||
{
|
||||
return [
|
||||
[['class' => 'yii\filters\AccessControl', 'user' => 'yiiunit\framework\base\MockUser']],
|
||||
|
@ -20,14 +20,14 @@ class BaseObjectTest extends TestCase
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
$this->object = new NewObject();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->object = null;
|
||||
@ -159,19 +159,6 @@ class BaseObjectTest extends TestCase
|
||||
$this->expectExceptionMessage('Getting write-only property: yiiunit\framework\base\NewObject::writeOnly');
|
||||
$this->object->writeOnly;
|
||||
}
|
||||
|
||||
public function testBackwardCompatibilityWithObject()
|
||||
{
|
||||
if (PHP_MAJOR_VERSION > 7 || (PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION >= 2)) {
|
||||
$this->markTestSkipped('This test is meant to run on PHP <7.2.0 to check BC with yii\base\Object');
|
||||
}
|
||||
$this->assertInstanceOf('yii\base\Object', new BCObject());
|
||||
$this->assertInstanceOf('yii\base\BaseObject', new BCObject());
|
||||
|
||||
BCObject::$initCalled = false;
|
||||
new BCObject();
|
||||
$this->assertTrue(BCObject::$initCalled);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,13 +73,13 @@ class BarBehavior extends Behavior
|
||||
*/
|
||||
class BehaviorTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
gc_enable();
|
||||
|
@ -33,14 +33,14 @@ class ComponentTest extends TestCase
|
||||
*/
|
||||
protected $component;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
$this->component = new NewComponent();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->component = null;
|
||||
@ -451,11 +451,6 @@ class ComponentTest extends TestCase
|
||||
*/
|
||||
public function testEventClosureDetachesItself()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.0');
|
||||
return;
|
||||
}
|
||||
|
||||
$obj = require __DIR__ . '/stub/AnonymousComponentClass.php';
|
||||
|
||||
$obj->trigger('barEventOnce');
|
||||
|
@ -65,7 +65,7 @@ class ControllerTest extends TestCase
|
||||
$this->assertEquals($expectedActionMethod, $actionMethod);
|
||||
}
|
||||
|
||||
public function createInlineActionProvider()
|
||||
public static function createInlineActionProvider()
|
||||
{
|
||||
return [
|
||||
['\yiiunit\framework\base\TestController', 'non-existent-id', null],
|
||||
@ -88,7 +88,7 @@ class ControllerTest extends TestCase
|
||||
$this->assertSame($expected, preg_match('/^(?:[a-z0-9_]+-)*[a-z0-9_]+$/', $input));
|
||||
}
|
||||
|
||||
public function actionIdMethodProvider()
|
||||
public static function actionIdMethodProvider()
|
||||
{
|
||||
return [
|
||||
['apple-id', 1],
|
||||
|
@ -15,7 +15,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class DynamicModelTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
|
@ -18,13 +18,13 @@ class EventTest extends TestCase
|
||||
{
|
||||
public $counter;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->counter = 0;
|
||||
Event::offAll();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Event::offAll();
|
||||
|
@ -20,7 +20,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ModelTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
@ -502,11 +502,6 @@ class ModelTest extends TestCase
|
||||
|
||||
public function testFormNameWithAnonymousClass()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.0');
|
||||
return;
|
||||
}
|
||||
|
||||
$model = require __DIR__ . '/stub/AnonymousModelClass.php';
|
||||
|
||||
$this->expectException('yii\base\InvalidConfigException');
|
||||
|
@ -18,7 +18,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ModuleTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
|
@ -22,7 +22,7 @@ class SecurityTest extends TestCase
|
||||
*/
|
||||
protected $security;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->security = new ExposedSecurity();
|
||||
@ -178,7 +178,7 @@ TEXT;
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderEncryptByKeyCompat()
|
||||
public static function dataProviderEncryptByKeyCompat()
|
||||
{
|
||||
// these ciphertexts generated using Yii 2.0.2 which is based on mcrypt.
|
||||
$mcrypt = [
|
||||
@ -489,7 +489,7 @@ TEXT;
|
||||
$this->assertEquals($data, $this->security->decryptByKey($encrypted, $key));
|
||||
}
|
||||
|
||||
public function dataProviderEncryptByPasswordCompat()
|
||||
public static function dataProviderEncryptByPasswordCompat()
|
||||
{
|
||||
// these ciphertexts generated using Yii 2.0.2 which is based on mcrypt.
|
||||
$mcrypt = [
|
||||
@ -800,7 +800,7 @@ TEXT;
|
||||
}
|
||||
|
||||
|
||||
public function randomKeyInvalidInputs()
|
||||
public static function randomKeyInvalidInputs()
|
||||
{
|
||||
return [
|
||||
[0],
|
||||
@ -813,11 +813,13 @@ TEXT;
|
||||
|
||||
/**
|
||||
* @dataProvider randomKeyInvalidInputs
|
||||
* @expectedException \yii\base\InvalidParamException
|
||||
*
|
||||
* @param mixed $input
|
||||
*/
|
||||
public function testRandomKeyInvalidInput($input)
|
||||
{
|
||||
$this->expectException(\yii\base\InvalidParamException::class);
|
||||
|
||||
$key1 = $this->security->generateRandomKey($input);
|
||||
}
|
||||
|
||||
@ -826,10 +828,10 @@ TEXT;
|
||||
// test various string lengths
|
||||
for ($length = 1; $length < 64; $length++) {
|
||||
$key1 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key1);
|
||||
$this->assertIsString($key1);
|
||||
$this->assertEquals($length, strlen($key1));
|
||||
$key2 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key2);
|
||||
$this->assertIsString($key2);
|
||||
$this->assertEquals($length, strlen($key2));
|
||||
if ($length >= 7) { // avoid random test failure, short strings are likely to collide
|
||||
$this->assertNotEquals($key1, $key2);
|
||||
@ -839,10 +841,10 @@ TEXT;
|
||||
// test for /dev/urandom, reading larger data to see if loop works properly
|
||||
$length = 1024 * 1024;
|
||||
$key1 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key1);
|
||||
$this->assertIsString($key1);
|
||||
$this->assertEquals($length, strlen($key1));
|
||||
$key2 = $this->security->generateRandomKey($length);
|
||||
$this->assertInternalType('string', $key2);
|
||||
$this->assertIsString('string', $key2);
|
||||
$this->assertEquals($length, strlen($key2));
|
||||
$this->assertNotEquals($key1, $key2);
|
||||
}
|
||||
@ -868,7 +870,7 @@ TEXT;
|
||||
$this->assertEquals(1, preg_match('/[A-Za-z0-9_-]+/', $key));
|
||||
}
|
||||
|
||||
public function dataProviderPbkdf2()
|
||||
public static function dataProviderPbkdf2()
|
||||
{
|
||||
return array_filter([
|
||||
[
|
||||
@ -963,7 +965,7 @@ TEXT;
|
||||
$this->assertEquals($okm, bin2hex($DK));
|
||||
}
|
||||
|
||||
public function dataProviderDeriveKey()
|
||||
public static function dataProviderDeriveKey()
|
||||
{
|
||||
// See Appendix A in https://tools.ietf.org/html/rfc5869
|
||||
return [
|
||||
@ -1055,7 +1057,7 @@ TEXT;
|
||||
$this->assertEquals($okm, bin2hex($dk));
|
||||
}
|
||||
|
||||
public function dataProviderCompareStrings()
|
||||
public static function dataProviderCompareStrings()
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
@ -1103,18 +1105,18 @@ TEXT;
|
||||
$this->assertEquals('', $this->security->unmaskToken('1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \yii\base\InvalidParamException
|
||||
*/
|
||||
public function testMaskingInvalidStrings()
|
||||
{
|
||||
$this->expectException('\yii\base\InvalidParamException');
|
||||
$this->expectExceptionMessage('First parameter ($length) must be greater than 0');
|
||||
|
||||
$this->security->maskToken('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function maskProvider()
|
||||
public static function maskProvider()
|
||||
{
|
||||
return [
|
||||
['1'],
|
||||
|
@ -16,7 +16,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ThemeTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$config = ['aliases' => ['@web' => '']];
|
||||
$this->mockWebApplication($config);
|
||||
|
@ -24,7 +24,7 @@ class ViewTest extends TestCase
|
||||
*/
|
||||
protected $testViewPath = '';
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -33,7 +33,7 @@ class ViewTest extends TestCase
|
||||
FileHelper::createDirectory($this->testViewPath);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
FileHelper::removeDirectory($this->testViewPath);
|
||||
parent::tearDown();
|
||||
|
@ -21,7 +21,7 @@ class WidgetTest extends TestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Widget::$counter = 0;
|
||||
|
@ -26,14 +26,14 @@ class AttributeBehaviorTest extends TestCase
|
||||
*/
|
||||
protected $dbConnection;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -52,7 +52,7 @@ class AttributeBehaviorTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_attribute', $columns)->execute();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
@ -63,7 +63,7 @@ class AttributeBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function preserveNonEmptyValuesDataProvider()
|
||||
public static function preserveNonEmptyValuesDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -22,14 +22,14 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class AttributeTypecastBehaviorTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -51,7 +51,7 @@ class AttributeTypecastBehaviorTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_attribute_typecast', $columns)->execute();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
AttributeTypecastBehavior::clearAutoDetectedAttributeTypes();
|
||||
|
@ -26,14 +26,14 @@ class AttributesBehaviorTest extends TestCase
|
||||
*/
|
||||
protected $dbConnection;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -52,7 +52,7 @@ class AttributesBehaviorTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_attribute', $columns)->execute();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
@ -63,7 +63,7 @@ class AttributesBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function preserveNonEmptyValuesDataProvider()
|
||||
public static function preserveNonEmptyValuesDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@ -118,7 +118,7 @@ class AttributesBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function orderProvider()
|
||||
public static function orderProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -21,14 +21,14 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class BlameableBehaviorConsoleTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -47,7 +47,7 @@ class BlameableBehaviorConsoleTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_blame', $columns)->execute();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
|
@ -21,14 +21,14 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class BlameableBehaviorTest extends TestCase
|
||||
{
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -52,7 +52,7 @@ class BlameableBehaviorTest extends TestCase
|
||||
$this->getUser()->login(10);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
|
@ -32,7 +32,7 @@ class CacheableWidgetBehaviorTest extends TestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->initializeApplicationMock();
|
||||
$this->initializeWidgetMocks();
|
||||
|
@ -29,14 +29,14 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
*/
|
||||
protected $dbConnection;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -60,7 +60,7 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_auto_lock_version_string', $columns)->execute();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
@ -152,7 +152,7 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
try {
|
||||
$model->save(false);
|
||||
} catch (\yii\db\StaleObjectException $e) {
|
||||
$this->assertContains('The object being updated is outdated.', $e->getMessage());
|
||||
$this->assertStringContainsString('The object being updated is outdated.', $e->getMessage());
|
||||
$thrown = true;
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
try {
|
||||
$model->save(false);
|
||||
} catch (\yii\db\StaleObjectException $e) {
|
||||
$this->assertContains('The object being updated is outdated.', $e->getMessage());
|
||||
$this->assertStringContainsString('The object being updated is outdated.', $e->getMessage());
|
||||
$thrown = true;
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
try {
|
||||
$model->save(false);
|
||||
} catch (\yii\db\StaleObjectException $e) {
|
||||
$this->assertContains('The object being updated is outdated.', $e->getMessage());
|
||||
$this->assertStringContainsString('The object being updated is outdated.', $e->getMessage());
|
||||
$thrown = true;
|
||||
}
|
||||
|
||||
@ -233,7 +233,7 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
try {
|
||||
$model->delete();
|
||||
} catch (\yii\db\StaleObjectException $e) {
|
||||
$this->assertContains('The object being deleted is outdated.', $e->getMessage());
|
||||
$this->assertStringContainsString('The object being deleted is outdated.', $e->getMessage());
|
||||
$thrown = true;
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ class OptimisticLockBehaviorTest extends TestCase
|
||||
try {
|
||||
$model->delete();
|
||||
} catch (\yii\db\StaleObjectException $e) {
|
||||
$this->assertContains('The object being deleted is outdated.', $e->getMessage());
|
||||
$this->assertStringContainsString('The object being deleted is outdated.', $e->getMessage());
|
||||
$thrown = true;
|
||||
}
|
||||
|
||||
|
@ -26,14 +26,14 @@ class SluggableBehaviorTest extends TestCase
|
||||
*/
|
||||
protected $dbConnection;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -60,7 +60,7 @@ class SluggableBehaviorTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_slug_related', $columns)->execute();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
|
@ -28,14 +28,14 @@ class TimestampBehaviorTest extends TestCase
|
||||
*/
|
||||
protected $dbConnection;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlite')) {
|
||||
static::markTestSkipped('PDO and SQLite extensions are required.');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'components' => [
|
||||
@ -61,7 +61,7 @@ class TimestampBehaviorTest extends TestCase
|
||||
Yii::$app->getDb()->createCommand()->createTable('test_auto_timestamp_string', $columns)->execute();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
Yii::$app->getDb()->close();
|
||||
parent::tearDown();
|
||||
|
@ -33,10 +33,8 @@ class ApcCacheTest extends CacheTestCase
|
||||
$this->markTestSkipped('APC is installed but not enabled. Skipping.');
|
||||
}
|
||||
|
||||
if ($this->_cacheInstance === null && PHP_VERSION_ID >= 70400) {
|
||||
if ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new ApcCache(['useApcu' => true]);
|
||||
} elseif ($this->_cacheInstance === null) {
|
||||
$this->_cacheInstance = new ApcCache();
|
||||
}
|
||||
|
||||
return $this->_cacheInstance;
|
||||
|
@ -54,13 +54,13 @@ abstract class CacheTestCase extends TestCase
|
||||
*/
|
||||
abstract protected function getCacheInstance();
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
static::$time = null;
|
||||
static::$microtime = null;
|
||||
@ -107,7 +107,7 @@ abstract class CacheTestCase extends TestCase
|
||||
/**
|
||||
* @return array testing multiSet with and without expiry
|
||||
*/
|
||||
public function multiSetExpiry()
|
||||
public static function multiSetExpiry()
|
||||
{
|
||||
return [[0], [2]];
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class DbCacheTest extends CacheTestCase
|
||||
private $_cacheInstance;
|
||||
private $_connection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) {
|
||||
$this->markTestSkipped('pdo and pdo_mysql extensions are required.');
|
||||
|
@ -25,7 +25,7 @@ class DbDependencyTest extends DatabaseTestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -23,7 +23,7 @@ class DbQueryDependencyTest extends DatabaseTestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
@ -77,7 +77,7 @@ class FileCacheTest extends CacheTestCase
|
||||
$cacheFile = $refMethodGetCacheFile->invoke($cache, $normalizeKey);
|
||||
|
||||
$this->assertTrue($refMethodSet->invoke($cache, $key, $value));
|
||||
$this->assertContains($keyPrefix, basename($cacheFile));
|
||||
$this->assertStringContainsString($keyPrefix, basename($cacheFile));
|
||||
$this->assertEquals($expectedDirectoryName, basename(dirname($cacheFile)), $cacheFile);
|
||||
$this->assertTrue(is_dir(dirname($cacheFile)), 'File not found ' . $cacheFile);
|
||||
$this->assertEquals($value, $refMethodGet->invoke($cache, $key));
|
||||
|
@ -21,7 +21,7 @@ class MssqlCacheTest extends CacheTestCase
|
||||
private $_cacheInstance;
|
||||
private $_connection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_sqlsrv')) {
|
||||
$this->markTestSkipped('pdo and pdo_mssql extensions are required.');
|
||||
|
@ -20,7 +20,7 @@ class PgSQLCacheTest extends DbCacheTest
|
||||
protected static $driverName = 'pgsql';
|
||||
private $_connection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) {
|
||||
$this->markTestSkipped('pdo and pdo_pgsql extensions are required.');
|
||||
|
@ -26,7 +26,7 @@ class ControllerTest extends TestCase
|
||||
/** @var FakeController */
|
||||
private $controller;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
@ -101,11 +101,6 @@ class ControllerTest extends TestCase
|
||||
|
||||
public function testNullableInjectedActionParams()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.1');
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the PHP71 controller for this test
|
||||
$this->controller = new FakePhp71Controller('fake', new Application([
|
||||
'id' => 'app',
|
||||
@ -122,10 +117,6 @@ class ControllerTest extends TestCase
|
||||
|
||||
public function testInjectionContainerException()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.1');
|
||||
return;
|
||||
}
|
||||
// Use the PHP71 controller for this test
|
||||
$this->controller = new FakePhp71Controller('fake', new Application([
|
||||
'id' => 'app',
|
||||
@ -144,10 +135,6 @@ class ControllerTest extends TestCase
|
||||
|
||||
public function testUnknownInjection()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.1');
|
||||
return;
|
||||
}
|
||||
// Use the PHP71 controller for this test
|
||||
$this->controller = new FakePhp71Controller('fake', new Application([
|
||||
'id' => 'app',
|
||||
@ -165,10 +152,6 @@ class ControllerTest extends TestCase
|
||||
|
||||
public function testInjectedActionParams()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.1');
|
||||
return;
|
||||
}
|
||||
// Use the PHP71 controller for this test
|
||||
$this->controller = new FakePhp71Controller('fake', new Application([
|
||||
'id' => 'app',
|
||||
@ -193,10 +176,6 @@ class ControllerTest extends TestCase
|
||||
|
||||
public function testInjectedActionParamsFromModule()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100) {
|
||||
$this->markTestSkipped('Can not be tested on PHP < 7.1');
|
||||
return;
|
||||
}
|
||||
$module = new \yii\base\Module('fake', new Application([
|
||||
'id' => 'app',
|
||||
'basePath' => __DIR__,
|
||||
@ -270,7 +249,7 @@ class ControllerTest extends TestCase
|
||||
|
||||
$helpController = new FakeHelpControllerWithoutOutput('help', Yii::$app);
|
||||
$helpController->actionIndex('fake/aksi1');
|
||||
$this->assertContains('--test-array, -ta', $helpController->outputString);
|
||||
$this->assertStringContainsString('--test-array, -ta', $helpController->outputString);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -295,12 +274,7 @@ class ControllerTest extends TestCase
|
||||
$help = $controller->getActionArgsHelp($controller->createAction('aksi2'));
|
||||
|
||||
$this->assertArrayHasKey('values', $help);
|
||||
if (PHP_MAJOR_VERSION > 5) {
|
||||
// declared type
|
||||
$this->assertEquals('array', $help['values']['type']);
|
||||
} else {
|
||||
$this->markTestSkipped('Can not test declared type of parameter $values on PHP < 7.0');
|
||||
}
|
||||
$this->assertArrayHasKey('value', $help);
|
||||
// PHPDoc type
|
||||
$this->assertEquals('string', $help['value']['type']);
|
||||
|
@ -13,7 +13,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class RequestTest extends TestCase
|
||||
{
|
||||
public function provider()
|
||||
public static function provider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -16,7 +16,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class UnknownCommandExceptionTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication([
|
||||
'enableCoreCommands' => false,
|
||||
@ -31,7 +31,7 @@ class UnknownCommandExceptionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function suggestedCommandsProvider()
|
||||
public static function suggestedCommandsProvider()
|
||||
{
|
||||
return [
|
||||
['migate', ['migrate']],
|
||||
|
@ -32,7 +32,7 @@ class AssetControllerTest extends TestCase
|
||||
*/
|
||||
protected $testAssetsBasePath = '';
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication();
|
||||
$this->testFilePath = Yii::getAlias('@yiiunit/runtime') . DIRECTORY_SEPARATOR . str_replace('\\', '_', get_class($this)) . uniqid();
|
||||
@ -41,7 +41,7 @@ class AssetControllerTest extends TestCase
|
||||
$this->createDir($this->testAssetsBasePath);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
$this->removeDir($this->testFilePath);
|
||||
}
|
||||
@ -258,7 +258,7 @@ EOL;
|
||||
$this->runAssetControllerAction('template', [$configFileName]);
|
||||
$this->assertFileExists($configFileName, 'Unable to create config file template!');
|
||||
$config = require $configFileName;
|
||||
$this->assertInternalType('array', $config, 'Invalid config created!');
|
||||
$this->assertIsArray($config, 'Invalid config created!');
|
||||
}
|
||||
|
||||
public function testActionCompress()
|
||||
@ -304,7 +304,7 @@ EOL;
|
||||
// Then :
|
||||
$this->assertFileExists($bundleFile, 'Unable to create output bundle file!');
|
||||
$compressedBundleConfig = require $bundleFile;
|
||||
$this->assertInternalType('array', $compressedBundleConfig, 'Output bundle file has incorrect format!');
|
||||
$this->assertIsArray($compressedBundleConfig, 'Output bundle file has incorrect format!');
|
||||
$this->assertCount(2, $compressedBundleConfig, 'Output bundle config contains wrong bundle count!');
|
||||
|
||||
$this->assertArrayHasKey($assetBundleClassName, $compressedBundleConfig, 'Source bundle is lost!');
|
||||
@ -320,11 +320,19 @@ EOL;
|
||||
|
||||
$compressedCssFileContent = file_get_contents($compressedCssFileName);
|
||||
foreach ($cssFiles as $name => $content) {
|
||||
$this->assertContains($content, $compressedCssFileContent, "Source of '{$name}' is missing in combined file!");
|
||||
$this->assertStringContainsString(
|
||||
$content,
|
||||
$compressedCssFileContent,
|
||||
"Source of '{$name}' is missing in combined file!",
|
||||
);
|
||||
}
|
||||
$compressedJsFileContent = file_get_contents($compressedJsFileName);
|
||||
foreach ($jsFiles as $name => $content) {
|
||||
$this->assertContains($content, $compressedJsFileContent, "Source of '{$name}' is missing in combined file!");
|
||||
$this->assertStringContainsString(
|
||||
$content,
|
||||
$compressedJsFileContent,
|
||||
"Source of '{$name}' is missing in combined file!",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,7 +392,7 @@ EOL;
|
||||
// Then :
|
||||
$this->assertFileExists($bundleFile, 'Unable to create output bundle file!');
|
||||
$compressedBundleConfig = require $bundleFile;
|
||||
$this->assertInternalType('array', $compressedBundleConfig, 'Output bundle file has incorrect format!');
|
||||
$this->assertIsArray($compressedBundleConfig, 'Output bundle file has incorrect format!');
|
||||
$this->assertArrayHasKey($externalAssetBundleClassName, $compressedBundleConfig, 'External bundle is lost!');
|
||||
|
||||
$compressedExternalAssetConfig = $compressedBundleConfig[$externalAssetBundleClassName];
|
||||
@ -392,7 +400,11 @@ EOL;
|
||||
$this->assertEquals($externalAssetConfig['css'], $compressedExternalAssetConfig['css'], 'External bundle css is lost!');
|
||||
|
||||
$compressedRegularAssetConfig = $compressedBundleConfig[$regularAssetBundleClassName];
|
||||
$this->assertContains($externalAssetBundleClassName, $compressedRegularAssetConfig['depends'], 'Dependency on external bundle is lost!');
|
||||
$this->assertContains(
|
||||
$externalAssetBundleClassName,
|
||||
$compressedRegularAssetConfig['depends'],
|
||||
'Dependency on external bundle is lost!',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -455,7 +467,7 @@ EOL;
|
||||
* Data provider for [[testAdjustCssUrl()]].
|
||||
* @return array test data.
|
||||
*/
|
||||
public function adjustCssUrlDataProvider()
|
||||
public static function adjustCssUrlDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@ -574,7 +586,7 @@ EOL;
|
||||
* Data provider for [[testFindRealPath()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function findRealPathDataProvider()
|
||||
public static function findRealPathDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -23,7 +23,7 @@ abstract class BaseMessageControllerTest extends TestCase
|
||||
protected $configFileName = '';
|
||||
protected $language = 'en';
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication();
|
||||
$this->sourcePath = Yii::getAlias('@yiiunit/runtime/test_source');
|
||||
@ -47,7 +47,7 @@ abstract class BaseMessageControllerTest extends TestCase
|
||||
return $this->configFileName;
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
FileHelper::removeDirectory($this->sourcePath);
|
||||
if (file_exists($this->configFileName)) {
|
||||
|
@ -29,7 +29,7 @@ class CacheControllerTest extends TestCase
|
||||
|
||||
private $driverName = 'mysql';
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -137,11 +137,10 @@ class CacheControllerTest extends TestCase
|
||||
$this->assertEquals('firstValue', Yii::$app->firstCache->get('firstKey'), 'first cache data should not be flushed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \yii\console\Exception
|
||||
*/
|
||||
public function testNothingToFlushException()
|
||||
{
|
||||
$this->expectException(\yii\console\Exception::class);
|
||||
|
||||
$this->_cacheController->actionFlush();
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class DbMessageControllerTest extends BaseMessageControllerTest
|
||||
}
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
$databases = static::getParam('databases');
|
||||
@ -65,7 +65,7 @@ class DbMessageControllerTest extends BaseMessageControllerTest
|
||||
static::runConsoleAction('migrate/up', ['migrationPath' => '@yii/i18n/migrations/', 'interactive' => false]);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
static::runConsoleAction('migrate/down', ['migrationPath' => '@yii/i18n/migrations/', 'interactive' => false]);
|
||||
if (static::$db) {
|
||||
@ -75,7 +75,7 @@ class DbMessageControllerTest extends BaseMessageControllerTest
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
Yii::$app = null;
|
||||
|
@ -30,7 +30,7 @@ class FixtureControllerTest extends DatabaseTestCase
|
||||
|
||||
protected $driverName = 'mysql';
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -46,7 +46,7 @@ class FixtureControllerTest extends DatabaseTestCase
|
||||
], [null, null]); //id and module are null
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->_fixtureController = null;
|
||||
FixtureStorage::clear();
|
||||
@ -215,19 +215,17 @@ class FixtureControllerTest extends DatabaseTestCase
|
||||
$this->assertEmpty(FixtureStorage::$firstFixtureData, 'first fixture data should not be loaded');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \yii\console\Exception
|
||||
*/
|
||||
public function testNoFixturesWereFoundInLoad()
|
||||
{
|
||||
$this->expectException(\yii\console\Exception::class);
|
||||
|
||||
$this->_fixtureController->actionLoad(['NotExistingFixture']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \yii\console\Exception
|
||||
*/
|
||||
public function testNoFixturesWereFoundInUnload()
|
||||
{
|
||||
$this->expectException(\yii\console\Exception::class);
|
||||
|
||||
$this->_fixtureController->actionUnload(['NotExistingFixture']);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->mockApplication();
|
||||
}
|
||||
@ -154,37 +154,37 @@ STRING
|
||||
public function testActionIndex()
|
||||
{
|
||||
$result = Console::stripAnsiFormat($this->runControllerAction('index'));
|
||||
$this->assertContains('This is Yii version ', $result);
|
||||
$this->assertContains('The following commands are available:', $result);
|
||||
$this->assertContains('To see the help of each command, enter:', $result);
|
||||
$this->assertContains('bootstrap.php help', $result);
|
||||
$this->assertStringContainsString('This is Yii version ', $result);
|
||||
$this->assertStringContainsString('The following commands are available:', $result);
|
||||
$this->assertStringContainsString('To see the help of each command, enter:', $result);
|
||||
$this->assertStringContainsString('bootstrap.php help', $result);
|
||||
}
|
||||
|
||||
public function testActionIndexWithHelpCommand()
|
||||
{
|
||||
$result = Console::stripAnsiFormat($this->runControllerAction('index', ['command' => 'help/index']));
|
||||
$this->assertContains('Displays available commands or the detailed information', $result);
|
||||
$this->assertContains('bootstrap.php help [command] [...options...]', $result);
|
||||
$this->assertContains('--appconfig: string', $result);
|
||||
$this->assertContains('- command: string', $result);
|
||||
$this->assertContains('--color: boolean, 0 or 1', $result);
|
||||
$this->assertContains('--help, -h: boolean, 0 or 1', $result);
|
||||
$this->assertContains('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
|
||||
$this->assertStringContainsString('Displays available commands or the detailed information', $result);
|
||||
$this->assertStringContainsString('bootstrap.php help [command] [...options...]', $result);
|
||||
$this->assertStringContainsString('--appconfig: string', $result);
|
||||
$this->assertStringContainsString('- command: string', $result);
|
||||
$this->assertStringContainsString('--color: boolean, 0 or 1', $result);
|
||||
$this->assertStringContainsString('--help, -h: boolean, 0 or 1', $result);
|
||||
$this->assertStringContainsString('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
|
||||
}
|
||||
|
||||
public function testActionIndexWithServeCommand()
|
||||
{
|
||||
$result = Console::stripAnsiFormat($this->runControllerAction('index', ['command' => 'serve']));
|
||||
$this->assertContains('Runs PHP built-in web server', $result);
|
||||
$this->assertContains('bootstrap.php serve [address] [...options...]', $result);
|
||||
$this->assertContains('- address: string (defaults to \'localhost\')', $result);
|
||||
$this->assertContains('--appconfig: string', $result);
|
||||
$this->assertContains('--color: boolean, 0 or 1', $result);
|
||||
$this->assertContains('--docroot, -t: string (defaults to \'@app/web\')', $result);
|
||||
$this->assertContains('--help, -h: boolean, 0 or 1', $result);
|
||||
$this->assertContains('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
|
||||
$this->assertContains('--port, -p: int (defaults to 8080)', $result);
|
||||
$this->assertContains('--router, -r: string', $result);
|
||||
$this->assertStringContainsString('Runs PHP built-in web server', $result);
|
||||
$this->assertStringContainsString('bootstrap.php serve [address] [...options...]', $result);
|
||||
$this->assertStringContainsString('- address: string (defaults to \'localhost\')', $result);
|
||||
$this->assertStringContainsString('--appconfig: string', $result);
|
||||
$this->assertStringContainsString('--color: boolean, 0 or 1', $result);
|
||||
$this->assertStringContainsString('--docroot, -t: string (defaults to \'@app/web\')', $result);
|
||||
$this->assertStringContainsString('--help, -h: boolean, 0 or 1', $result);
|
||||
$this->assertStringContainsString('--interactive: boolean, 0 or 1 (defaults to 1)', $result);
|
||||
$this->assertStringContainsString('--port, -p: int (defaults to 8080)', $result);
|
||||
$this->assertStringContainsString('--router, -r: string', $result);
|
||||
}
|
||||
|
||||
public function testActionListContainsNoEmptyCommands()
|
||||
@ -194,9 +194,9 @@ STRING
|
||||
'controllerNamespace' => 'yiiunit\data\console\controllers',
|
||||
]);
|
||||
$result = Console::stripAnsiFormat($this->runControllerAction('list'));
|
||||
$this->assertNotContains("fake-empty\n", $result);
|
||||
$this->assertNotContains("fake-no-default\n", $result);
|
||||
$this->assertContains("fake-no-default/index\n", $result);
|
||||
$this->assertStringNotContainsString("fake-empty\n", $result);
|
||||
$this->assertStringNotContainsString("fake-no-default\n", $result);
|
||||
$this->assertStringContainsString("fake-no-default/index\n", $result);
|
||||
}
|
||||
|
||||
public function testActionIndexContainsNoEmptyCommands()
|
||||
@ -206,10 +206,10 @@ STRING
|
||||
'controllerNamespace' => 'yiiunit\data\console\controllers',
|
||||
]);
|
||||
$result = Console::stripAnsiFormat($this->runControllerAction('index'));
|
||||
$this->assertNotContains("- fake-empty", $result);
|
||||
$this->assertContains("- fake-no-default", $result);
|
||||
$this->assertContains(" fake-no-default/index", $result);
|
||||
$this->assertNotContains(" 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class MigrateControllerTest extends TestCase
|
||||
{
|
||||
use MigrateControllerTestTrait;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->migrateControllerClass = EchoMigrateController::className();
|
||||
$this->migrationBaseClass = Migration::className();
|
||||
@ -44,7 +44,7 @@ class MigrateControllerTest extends TestCase
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
$this->tearDownMigrationPath();
|
||||
parent::tearDown();
|
||||
@ -157,7 +157,7 @@ class MigrateControllerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function generateMigrationDataProvider()
|
||||
public static function generateMigrationDataProvider()
|
||||
{
|
||||
$params = [
|
||||
'create_fields' => [
|
||||
@ -357,7 +357,7 @@ class MigrateControllerTest extends TestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function generateJunctionMigrationDataProvider()
|
||||
public static function generateJunctionMigrationDataProvider()
|
||||
{
|
||||
return [
|
||||
['create_junction_post_and_tag_tables', 'post_tag', 'post', 'tag'],
|
||||
@ -419,8 +419,8 @@ class MigrateControllerTest extends TestCase
|
||||
$result = $this->runMigrateControllerAction('up');
|
||||
$this->assertSame(ExitCode::UNSPECIFIED_ERROR, $this->getExitCode());
|
||||
|
||||
$this->assertContains('The migration name', $result);
|
||||
$this->assertContains('is too long. Its not possible to apply this migration.', $result);
|
||||
$this->assertStringContainsString('The migration name', $result);
|
||||
$this->assertStringContainsString('is too long. Its not possible to apply this migration.', $result);
|
||||
}
|
||||
|
||||
public function testNamedMigrationWithCustomLimit()
|
||||
@ -435,8 +435,8 @@ class MigrateControllerTest extends TestCase
|
||||
$result = $this->runMigrateControllerAction('up');
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
|
||||
$this->assertContains('1 migration was applied.', $result);
|
||||
$this->assertContains('Migrated up successfully.', $result);
|
||||
$this->assertStringContainsString('1 migration was applied.', $result);
|
||||
$this->assertStringContainsString('Migrated up successfully.', $result);
|
||||
}
|
||||
|
||||
public function testCreateLongNamedMigration()
|
||||
@ -478,14 +478,14 @@ class MigrateControllerTest extends TestCase
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
|
||||
// Drop worked
|
||||
$this->assertContains('Table hall_of_fame dropped.', $result);
|
||||
$this->assertContains('View view_hall_of_fame dropped.', $result);
|
||||
$this->assertStringContainsString('Table hall_of_fame dropped.', $result);
|
||||
$this->assertStringContainsString('View view_hall_of_fame dropped.', $result);
|
||||
|
||||
// Migration was restarted
|
||||
$this->assertContains('No new migrations found. Your system is up-to-date.', $result);
|
||||
$this->assertStringContainsString('No new migrations found. Your system is up-to-date.', $result);
|
||||
}
|
||||
|
||||
public function refreshMigrationDataProvider()
|
||||
public static function refreshMigrationDataProvider()
|
||||
{
|
||||
return [
|
||||
['default'],
|
||||
|
@ -228,7 +228,7 @@ CODE;
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$files = FileHelper::findFiles($this->migrationPath);
|
||||
$this->assertCount(1, $files, 'Unable to create new migration!');
|
||||
$this->assertContains($migrationName, basename($files[0]), 'Wrong migration name!');
|
||||
$this->assertStringContainsString($migrationName, basename($files[0]), 'Wrong migration name!');
|
||||
}
|
||||
|
||||
public function testUp()
|
||||
@ -294,7 +294,7 @@ CODE;
|
||||
public function testHistory()
|
||||
{
|
||||
$output = $this->runMigrateControllerAction('history');
|
||||
$this->assertContains('No migration', $output);
|
||||
$this->assertStringContainsString('No migration', $output);
|
||||
|
||||
$this->createMigration('test_history1');
|
||||
$this->createMigration('test_history2');
|
||||
@ -303,8 +303,8 @@ CODE;
|
||||
|
||||
$output = $this->runMigrateControllerAction('history');
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$this->assertContains('_test_history1', $output);
|
||||
$this->assertContains('_test_history2', $output);
|
||||
$this->assertStringContainsString('_test_history1', $output);
|
||||
$this->assertStringContainsString('_test_history2', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -316,14 +316,14 @@ CODE;
|
||||
|
||||
$output = $this->runMigrateControllerAction('new');
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$this->assertContains('_test_new1', $output);
|
||||
$this->assertStringContainsString('_test_new1', $output);
|
||||
|
||||
$this->runMigrateControllerAction('up');
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
|
||||
$output = $this->runMigrateControllerAction('new');
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$this->assertNotContains('_test_new1', $output);
|
||||
$this->assertNotStringContainsString('_test_new1', $output);
|
||||
}
|
||||
|
||||
public function testMark()
|
||||
@ -393,8 +393,8 @@ CODE;
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$files = FileHelper::findFiles($this->migrationPath);
|
||||
$fileContent = file_get_contents($files[0]);
|
||||
$this->assertContains("namespace {$this->migrationNamespace};", $fileContent);
|
||||
$this->assertRegExp('/class M[0-9]{12}' . ucfirst($migrationName) . '/s', $fileContent);
|
||||
$this->assertStringContainsString("namespace {$this->migrationNamespace};", $fileContent);
|
||||
$this->assertMatchesRegularExpression('/class M[0-9]{12}' . ucfirst($migrationName) . '/s', $fileContent);
|
||||
unlink($files[0]);
|
||||
|
||||
// namespace specify :
|
||||
@ -406,7 +406,7 @@ CODE;
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$files = FileHelper::findFiles($this->migrationPath);
|
||||
$fileContent = file_get_contents($files[0]);
|
||||
$this->assertContains("namespace {$this->migrationNamespace};", $fileContent);
|
||||
$this->assertStringContainsString("namespace {$this->migrationNamespace};", $fileContent);
|
||||
unlink($files[0]);
|
||||
|
||||
// no namespace:
|
||||
@ -418,7 +418,7 @@ CODE;
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$files = FileHelper::findFiles($this->migrationPath);
|
||||
$fileContent = file_get_contents($files[0]);
|
||||
$this->assertNotContains("namespace {$this->migrationNamespace};", $fileContent);
|
||||
$this->assertNotStringContainsString("namespace {$this->migrationNamespace};", $fileContent);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -478,7 +478,7 @@ CODE;
|
||||
];
|
||||
|
||||
$output = $this->runMigrateControllerAction('history', [], $controllerConfig);
|
||||
$this->assertContains('No migration', $output);
|
||||
$this->assertStringContainsString('No migration', $output);
|
||||
|
||||
$this->createNamespaceMigration('history1');
|
||||
$this->createNamespaceMigration('history2');
|
||||
@ -487,8 +487,8 @@ CODE;
|
||||
|
||||
$output = $this->runMigrateControllerAction('history', [], $controllerConfig);
|
||||
$this->assertSame(ExitCode::OK, $this->getExitCode());
|
||||
$this->assertRegExp('/' . preg_quote($this->migrationNamespace) . '.*History1/s', $output);
|
||||
$this->assertRegExp('/' . preg_quote($this->migrationNamespace) . '.*History2/s', $output);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($this->migrationNamespace) . '.*History1/s', $output);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($this->migrationNamespace) . '.*History2/s', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,14 +18,14 @@ class PHPMessageControllerTest extends BaseMessageControllerTest
|
||||
{
|
||||
protected $messagePath;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->messagePath = Yii::getAlias('@yiiunit/runtime/test_messages');
|
||||
FileHelper::createDirectory($this->messagePath, 0777);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
FileHelper::removeDirectory($this->messagePath);
|
||||
@ -123,7 +123,7 @@ class PHPMessageControllerTest extends BaseMessageControllerTest
|
||||
$this->assertEqualsWithoutLE($expected, $head);
|
||||
}
|
||||
|
||||
public function messageFileCategoriesDataProvider(){
|
||||
public static 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],
|
||||
@ -165,7 +165,7 @@ class PHPMessageControllerTest extends BaseMessageControllerTest
|
||||
if ($isExpectedToExist) {
|
||||
$this->assertFileExists($filePath);
|
||||
} else {
|
||||
$this->assertFileNotExists($filePath);
|
||||
$this->assertFileDoesNotExist($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class POMessageControllerTest extends BaseMessageControllerTest
|
||||
protected $messagePath;
|
||||
protected $catalog = 'messages';
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -27,7 +27,7 @@ class POMessageControllerTest extends BaseMessageControllerTest
|
||||
FileHelper::createDirectory($this->messagePath, 0777);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
FileHelper::removeDirectory($this->messagePath);
|
||||
|
@ -16,13 +16,13 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class TableTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
public function getTableData()
|
||||
public static function getTableData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@ -346,6 +346,8 @@ EXPECTED;
|
||||
|
||||
public function testColorizedInputStripsANSIMarkersInternally()
|
||||
{
|
||||
$this->markTestSkipped('Should be fixed in future, deprecated readAttribute() method used in phpunit.');
|
||||
|
||||
$table = new Table();
|
||||
|
||||
$table
|
||||
@ -484,7 +486,7 @@ EXPECTED;
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function dataMinimumWidth()
|
||||
public static function dataMinimumWidth()
|
||||
{
|
||||
return [
|
||||
['X'],
|
||||
|
@ -13,7 +13,7 @@ use yiiunit\TestCase;
|
||||
|
||||
class ActiveDataFilterTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -22,7 +22,7 @@ class ActiveDataFilterTest extends TestCase
|
||||
|
||||
// Tests :
|
||||
|
||||
public function dataProviderBuild()
|
||||
public static function dataProviderBuild()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -26,7 +26,7 @@ use yiiunit\framework\db\UnqueryableQueryMock;
|
||||
*/
|
||||
abstract class ActiveDataProviderTest extends DatabaseTestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
ActiveRecord::$db = $this->getConnection();
|
||||
@ -132,7 +132,7 @@ abstract class ActiveDataProviderTest extends DatabaseTestCase
|
||||
]);
|
||||
$orders = $provider->getModels();
|
||||
$this->assertCount(3, $orders);
|
||||
$this->assertInternalType('array', $orders[0]);
|
||||
$this->assertIsArray($orders[0]);
|
||||
$this->assertEquals([0, 1, 2], $provider->getKeys());
|
||||
|
||||
$query = new Query();
|
||||
|
@ -15,7 +15,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class ArrayDataProviderTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
|
@ -17,7 +17,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class DataFilterTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
@ -85,7 +85,7 @@ class DataFilterTest extends TestCase
|
||||
* Data provider for [[testValidate()]].
|
||||
* @return array test data.
|
||||
*/
|
||||
public function dataProviderValidate()
|
||||
public static function dataProviderValidate()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@ -293,7 +293,7 @@ class DataFilterTest extends TestCase
|
||||
* Data provider for [[testNormalize()]].
|
||||
* @return array test data.
|
||||
*/
|
||||
public function dataProviderNormalize()
|
||||
public static function dataProviderNormalize()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -16,7 +16,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class PaginationTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockWebApplication([
|
||||
@ -32,7 +32,7 @@ class PaginationTest extends TestCase
|
||||
* Data provider for [[testCreateUrl()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderCreateUrl()
|
||||
public static function dataProviderCreateUrl()
|
||||
{
|
||||
return [
|
||||
[
|
||||
@ -115,7 +115,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals(999, $pagination->getPage());
|
||||
}
|
||||
|
||||
public function dataProviderPageCount()
|
||||
public static function dataProviderPageCount()
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
@ -152,7 +152,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals(0, (new Pagination())->getPage());
|
||||
}
|
||||
|
||||
public function dataProviderSetPage()
|
||||
public static function dataProviderSetPage()
|
||||
{
|
||||
return [
|
||||
[null, false, 0, null],
|
||||
@ -187,7 +187,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($page, $pagination->getPage());
|
||||
}
|
||||
|
||||
public function dataProviderGetPageSize()
|
||||
public static function dataProviderGetPageSize()
|
||||
{
|
||||
return [
|
||||
[[1, 50], 20],
|
||||
@ -214,7 +214,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($pageSize, $pagination->getPageSize());
|
||||
}
|
||||
|
||||
public function dataProviderSetPageSize()
|
||||
public static function dataProviderSetPageSize()
|
||||
{
|
||||
return [
|
||||
[null, false, false, 20],
|
||||
@ -249,7 +249,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($pageSize, $pagination->getPageSize());
|
||||
}
|
||||
|
||||
public function dataProviderGetOffset()
|
||||
public static function dataProviderGetOffset()
|
||||
{
|
||||
return [
|
||||
[0, 0, 0],
|
||||
@ -276,7 +276,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($offset, $pagination->getOffset());
|
||||
}
|
||||
|
||||
public function dataProviderGetLimit()
|
||||
public static function dataProviderGetLimit()
|
||||
{
|
||||
return [
|
||||
[0, -1],
|
||||
@ -299,7 +299,7 @@ class PaginationTest extends TestCase
|
||||
$this->assertEquals($limit, $pagination->getLimit());
|
||||
}
|
||||
|
||||
public function dataProviderGetLinks()
|
||||
public static function dataProviderGetLinks()
|
||||
{
|
||||
return [
|
||||
[0, 0, 0, '/index.php?r=list&page=1&per-page=0', null, null, null, null],
|
||||
|
@ -19,7 +19,7 @@ use yiiunit\TestCase;
|
||||
*/
|
||||
class SortTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->mockApplication();
|
||||
@ -208,7 +208,7 @@ class SortTest extends TestCase
|
||||
$this->assertEquals('/index.php?r=site%2Findex&sort=age', $sort->createUrl('name'));
|
||||
}
|
||||
|
||||
public function providerForLinkWithParams()
|
||||
public static function providerForLinkWithParams()
|
||||
{
|
||||
return [
|
||||
[true, null, '<a class="asc" href="/index.php?r=site%2Findex&sort=-age%2C-name" data-sort="-age,-name">Age</a>'],
|
||||
@ -250,7 +250,7 @@ class SortTest extends TestCase
|
||||
$this->assertEquals($link, $sort->link('age'));
|
||||
}
|
||||
|
||||
public function providerForLinkWithParamsAndPassedButEmptySort()
|
||||
public static function providerForLinkWithParamsAndPassedButEmptySort()
|
||||
{
|
||||
return [
|
||||
[null],
|
||||
@ -294,7 +294,7 @@ class SortTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function providerForLinkWithoutParams()
|
||||
public static function providerForLinkWithoutParams()
|
||||
{
|
||||
return [
|
||||
[false, null, '<a href="/index.php?r=site%2Findex&sort=age" data-sort="age">Age</a>'],
|
||||
|
@ -47,7 +47,7 @@ class SqlDataProviderTest extends DatabaseTestCase
|
||||
$this->assertEquals(3, $dataProvider->getTotalCount());
|
||||
}
|
||||
|
||||
public function providerForOrderByColumn()
|
||||
public static function providerForOrderByColumn()
|
||||
{
|
||||
return [
|
||||
'no marks' => ['name'],
|
||||
|
@ -17,7 +17,7 @@ class ActiveQueryModelConnectionTest extends TestCase
|
||||
private $globalConnection;
|
||||
private $modelConnection;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->globalConnection = $this->getMockBuilder('yii\db\Connection')->getMock();
|
||||
$this->modelConnection = $this->getMockBuilder('yii\db\Connection')->getMock();
|
||||
|
@ -22,7 +22,7 @@ use yiiunit\data\ar\Profile;
|
||||
*/
|
||||
abstract class ActiveQueryTest extends DatabaseTestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
ActiveRecord::$db = $this->getConnection();
|
||||
|
@ -44,7 +44,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
{
|
||||
use ActiveRecordTestTrait;
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
ActiveRecord::$db = $this->getConnection();
|
||||
@ -199,7 +199,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
$this->assertCount(0, $order->books);
|
||||
|
||||
$order = Order::find()->where(['id' => 1])->asArray()->one();
|
||||
$this->assertInternalType('array', $order);
|
||||
$this->assertIsArray($order);
|
||||
}
|
||||
|
||||
public function testFindEagerViaTable()
|
||||
@ -225,10 +225,10 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
// https://github.com/yiisoft/yii2/issues/1402
|
||||
$orders = Order::find()->with('books')->orderBy('id')->asArray()->all();
|
||||
$this->assertCount(3, $orders);
|
||||
$this->assertInternalType('array', $orders[0]['orderItems'][0]);
|
||||
$this->assertIsArray($orders[0]['orderItems'][0]);
|
||||
|
||||
$order = $orders[0];
|
||||
$this->assertInternalType('array', $order);
|
||||
$this->assertIsArray($order);
|
||||
$this->assertEquals(1, $order['id']);
|
||||
$this->assertCount(2, $order['books']);
|
||||
$this->assertEquals(1, $order['books'][0]['id']);
|
||||
@ -809,7 +809,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
$this->assertEquals($eagerItemsCount, $lazyItemsCount);
|
||||
}
|
||||
|
||||
public function aliasMethodProvider()
|
||||
public static function aliasMethodProvider()
|
||||
{
|
||||
return [
|
||||
['explicit'], // c
|
||||
@ -1123,12 +1123,12 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
$this->assertInstanceOf('yiiunit\data\ar\Customer', $customerWithJoin);
|
||||
|
||||
$customerWithJoinIndexOrdered = $order->customerJoinedWithProfileIndexOrdered;
|
||||
$this->assertInternalType('array', $customerWithJoinIndexOrdered);
|
||||
$this->assertIsArray($customerWithJoinIndexOrdered);
|
||||
$this->assertArrayHasKey('user1', $customerWithJoinIndexOrdered);
|
||||
$this->assertInstanceOf('yiiunit\data\ar\Customer', $customerWithJoinIndexOrdered['user1']);
|
||||
}
|
||||
|
||||
public function tableNameProvider()
|
||||
public static function tableNameProvider()
|
||||
{
|
||||
return [
|
||||
['order', 'order_item'],
|
||||
@ -1898,7 +1898,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
$this->assertEquals($expectedAliases, $aliases);
|
||||
}
|
||||
|
||||
public function filterTableNamesFromAliasesProvider()
|
||||
public static function filterTableNamesFromAliasesProvider()
|
||||
{
|
||||
return [
|
||||
'table name as string' => ['customer', []],
|
||||
@ -1910,7 +1910,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function legalValuesForFindByCondition()
|
||||
public static function legalValuesForFindByCondition()
|
||||
{
|
||||
return [
|
||||
[Customer::className(), ['id' => 1]],
|
||||
@ -1937,9 +1937,11 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
/** @var Query $query */
|
||||
$query = $this->invokeMethod(\Yii::createObject($modelClassName), 'findByCondition', [$validFilter]);
|
||||
Customer::getDb()->queryBuilder->build($query);
|
||||
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function illegalValuesForFindByCondition()
|
||||
public static function illegalValuesForFindByCondition()
|
||||
{
|
||||
return [
|
||||
[Customer::className(), [['`id`=`id` and 1' => 1]]],
|
||||
@ -1974,7 +1976,8 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
public function testValueEscapingInFindByCondition($modelClassName, $filterWithInjection)
|
||||
{
|
||||
$this->expectException('yii\base\InvalidArgumentException');
|
||||
$this->expectExceptionMessageRegExp('/^Key "(.+)?" is not a column name and can not be used as a filter$/');
|
||||
$this->expectExceptionMessageMatches('/^Key "(.+)?" is not a column name and can not be used as a filter$/');
|
||||
|
||||
/** @var Query $query */
|
||||
$query = $this->invokeMethod(\Yii::createObject($modelClassName), 'findByCondition', $filterWithInjection);
|
||||
Customer::getDb()->queryBuilder->build($query);
|
||||
@ -2145,7 +2148,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function providerForUnlinkDelete()
|
||||
public static function providerForUnlinkDelete()
|
||||
{
|
||||
return [
|
||||
'with delete' => [true, 0],
|
||||
|
@ -14,7 +14,7 @@ use yiiunit\data\ar\Customer;
|
||||
|
||||
abstract class BatchQueryResultTest extends DatabaseTestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
ActiveRecord::$db = $this->getConnection();
|
||||
|
@ -26,7 +26,7 @@ abstract class ColumnSchemaBuilderTest extends DatabaseTestCase
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function typesProvider()
|
||||
public static function typesProvider()
|
||||
{
|
||||
return [
|
||||
['integer NULL DEFAULT NULL', Schema::TYPE_INTEGER, null, [
|
||||
|
@ -193,7 +193,7 @@ SQL;
|
||||
$command->bindParam(':blob_col', $blobCol);
|
||||
$command->bindParam(':bool_col', $boolCol, \PDO::PARAM_BOOL);
|
||||
} else {
|
||||
$floatCol = 1.23;
|
||||
$floatCol = 1.230;
|
||||
$numericCol = '1.23';
|
||||
$blobCol = "\x10\x11\x12";
|
||||
$boolCol = false;
|
||||
@ -210,13 +210,13 @@ SQL;
|
||||
$row = $command->queryOne();
|
||||
$this->assertEquals($intCol, $row['int_col']);
|
||||
$this->assertEquals($charCol, $row['char_col']);
|
||||
$this->assertEquals($floatCol, $row['float_col']);
|
||||
$this->assertEquals($floatCol, (float) $row['float_col']);
|
||||
if ($this->driverName === 'mysql' || $this->driverName === 'sqlite' || $this->driverName === 'oci') {
|
||||
$this->assertEquals($blobCol, $row['blob_col']);
|
||||
} elseif (\defined('HHVM_VERSION') && $this->driverName === 'pgsql') {
|
||||
// HHVMs pgsql implementation does not seem to support blob columns correctly.
|
||||
} else {
|
||||
$this->assertInternalType('resource', $row['blob_col']);
|
||||
$this->assertIsResource($row['blob_col']);
|
||||
$this->assertEquals($blobCol, stream_get_contents($row['blob_col']));
|
||||
}
|
||||
$this->assertEquals($numericCol, $row['numeric_col']);
|
||||
@ -238,7 +238,7 @@ SQL;
|
||||
$this->assertEquals('user5@example.com', $command->queryScalar());
|
||||
}
|
||||
|
||||
public function paramsNonWhereProvider()
|
||||
public static function paramsNonWhereProvider()
|
||||
{
|
||||
return [
|
||||
['SELECT SUBSTR(name, :len) FROM {{customer}} WHERE [[email]] = :email GROUP BY SUBSTR(name, :len)'],
|
||||
@ -281,7 +281,7 @@ SQL;
|
||||
$command = $db->createCommand($sql);
|
||||
$command->fetchMode = \PDO::FETCH_OBJ;
|
||||
$result = $command->queryOne();
|
||||
$this->assertInternalType('object', $result);
|
||||
$this->assertIsObject($result);
|
||||
|
||||
// FETCH_NUM, customized in query method
|
||||
$sql = 'SELECT * FROM {{customer}}';
|
||||
@ -315,11 +315,20 @@ SQL;
|
||||
|
||||
public function testBatchInsertWithYield()
|
||||
{
|
||||
if (PHP_VERSION_ID < 50500) {
|
||||
$this->markTestSkipped('The yield function is only supported with php 5.5 =< version');
|
||||
} else {
|
||||
include __DIR__ . '/testBatchInsertWithYield.php';
|
||||
$rows = call_user_func(function () {
|
||||
if (false) {
|
||||
yield [];
|
||||
}
|
||||
});
|
||||
|
||||
$command = $this->getConnection()->createCommand();
|
||||
$command->batchInsert(
|
||||
'{{customer}}',
|
||||
['email', 'name', 'address'],
|
||||
$rows
|
||||
);
|
||||
|
||||
$this->assertEquals(0, $command->execute());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -377,7 +386,7 @@ SQL;
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
}
|
||||
|
||||
public function batchInsertSqlProvider()
|
||||
public static function batchInsertSqlProvider()
|
||||
{
|
||||
return [
|
||||
'issue11242' => [
|
||||
@ -610,7 +619,7 @@ SQL;
|
||||
* Data provider for testInsertSelectFailed.
|
||||
* @return array
|
||||
*/
|
||||
public function invalidSelectColumns()
|
||||
public static function invalidSelectColumns()
|
||||
{
|
||||
return [
|
||||
[[]],
|
||||
@ -623,8 +632,7 @@ SQL;
|
||||
* Test INSERT INTO ... SELECT SQL statement with wrong query object.
|
||||
*
|
||||
* @dataProvider invalidSelectColumns
|
||||
* @expectedException \yii\base\InvalidParamException
|
||||
* @expectedExceptionMessage Expected select query object with enumerated (named) parameters
|
||||
*
|
||||
* @param mixed $invalidSelectColumns
|
||||
*/
|
||||
public function testInsertSelectFailed($invalidSelectColumns)
|
||||
@ -634,10 +642,11 @@ SQL;
|
||||
|
||||
$db = $this->getConnection();
|
||||
$command = $db->createCommand();
|
||||
$command->insert(
|
||||
'{{customer}}',
|
||||
$query
|
||||
)->execute();
|
||||
|
||||
$this->expectException('yii\base\InvalidParamException');
|
||||
$this->expectExceptionMessage('Expected select query object with enumerated (named) parameters');
|
||||
|
||||
$command->insert('{{customer}}', $query)->execute();
|
||||
}
|
||||
|
||||
public function testInsertExpression()
|
||||
@ -798,7 +807,7 @@ SQL;
|
||||
$this->assertNotNull($db->getSchema()->getTableSchema($toTableName, true));
|
||||
}
|
||||
|
||||
public function upsertProvider()
|
||||
public static function upsertProvider()
|
||||
{
|
||||
return [
|
||||
'regular values' => [
|
||||
@ -1222,7 +1231,7 @@ SQL;
|
||||
|
||||
$this->assertEmpty($schema->getTableChecks($tableName, true));
|
||||
$db->createCommand()->addCheck($name, $tableName, '[[int1]] > 1')->execute();
|
||||
$this->assertRegExp('/^.*int1.*>.*1.*$/', $schema->getTableChecks($tableName, true)[0]->expression);
|
||||
$this->assertMatchesRegularExpression('/^.*int1.*>.*1.*$/', $schema->getTableChecks($tableName, true)[0]->expression);
|
||||
|
||||
$db->createCommand()->dropCheck($name, $tableName)->execute();
|
||||
$this->assertEmpty($schema->getTableChecks($tableName, true));
|
||||
@ -1328,7 +1337,7 @@ SQL;
|
||||
* Data provider for [[testGetRawSql()]].
|
||||
* @return array test data
|
||||
*/
|
||||
public function dataProviderGetRawSql()
|
||||
public static function dataProviderGetRawSql()
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
@ -224,12 +224,12 @@ abstract class ConnectionTest extends DatabaseTestCase
|
||||
$this->assertTrue(true); // should not be any exception so far
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
*/
|
||||
public function testTransactionShortcutException()
|
||||
{
|
||||
$connection = $this->getConnection(true);
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
|
||||
$connection->transaction(function () use ($connection) {
|
||||
$connection->createCommand()->insert('profile', ['description' => 'test transaction shortcut'])->execute();
|
||||
throw new \Exception('Exception in transaction shortcut');
|
||||
@ -400,7 +400,11 @@ abstract class ConnectionTest extends DatabaseTestCase
|
||||
try {
|
||||
$connection->createCommand('INSERT INTO qlog1(a) VALUES(:a);', [':a' => 1])->execute();
|
||||
} catch (\yii\db\Exception $e) {
|
||||
$this->assertContains('INSERT INTO qlog1(a) VALUES(1);', $e->getMessage(), 'Exception message should contain raw SQL query: ' . (string) $e);
|
||||
$this->assertStringContainsString(
|
||||
'INSERT INTO qlog1(a) VALUES(1);',
|
||||
$e->getMessage(),
|
||||
'Exception message should contain raw SQL query: ' . (string) $e
|
||||
);
|
||||
$thrown = true;
|
||||
}
|
||||
$this->assertTrue($thrown, 'An exception should have been thrown by the command.');
|
||||
@ -409,7 +413,10 @@ abstract class ConnectionTest extends DatabaseTestCase
|
||||
try {
|
||||
$connection->createCommand('SELECT * FROM qlog1 WHERE id=:a ORDER BY nonexistingcolumn;', [':a' => 1])->queryAll();
|
||||
} catch (\yii\db\Exception $e) {
|
||||
$this->assertContains('SELECT * FROM qlog1 WHERE id=1 ORDER BY nonexistingcolumn;', $e->getMessage(), 'Exception message should contain raw SQL query: ' . (string) $e);
|
||||
$this->assertStringContainsString(
|
||||
'SELECT * FROM qlog1 WHERE id=1 ORDER BY nonexistingcolumn;',
|
||||
$e->getMessage(), 'Exception message should contain raw SQL query: ' . (string) $e,
|
||||
);
|
||||
$thrown = true;
|
||||
}
|
||||
$this->assertTrue($thrown, 'An exception should have been thrown by the command.');
|
||||
|
@ -24,7 +24,7 @@ abstract class DatabaseTestCase extends TestCase
|
||||
private $_db;
|
||||
|
||||
|
||||
protected function setUp()
|
||||
protected function setUp(): void
|
||||
{
|
||||
if ($this->driverName === null) {
|
||||
throw new \Exception('driverName is not set for a DatabaseTestCase.');
|
||||
@ -44,7 +44,7 @@ abstract class DatabaseTestCase extends TestCase
|
||||
$this->mockApplication();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if ($this->_db) {
|
||||
$this->_db->close();
|
||||
|
@ -1326,7 +1326,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertEquals('FROM ' . $this->replaceQuotes($expected), $sql);
|
||||
}
|
||||
|
||||
public function buildFromDataProvider()
|
||||
public static function buildFromDataProvider()
|
||||
{
|
||||
return [
|
||||
['test t1', '[[test]] [[t1]]'],
|
||||
@ -1365,7 +1365,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertEquals($expectedParams, $params);
|
||||
}
|
||||
|
||||
public function primaryKeysProvider()
|
||||
public static function primaryKeysProvider()
|
||||
{
|
||||
$tableName = 'T_constraints_1';
|
||||
$name = 'CN_pk';
|
||||
@ -1400,7 +1400,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertSame($this->getConnection(false)->quoteSql($sql), $builder($this->getQueryBuilder(false)));
|
||||
}
|
||||
|
||||
public function foreignKeysProvider()
|
||||
public static function foreignKeysProvider()
|
||||
{
|
||||
$tableName = 'T_constraints_3';
|
||||
$name = 'CN_constraints_3';
|
||||
@ -1436,7 +1436,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertSame($this->getConnection(false)->quoteSql($sql), $builder($this->getQueryBuilder(false)));
|
||||
}
|
||||
|
||||
public function indexesProvider()
|
||||
public static function indexesProvider()
|
||||
{
|
||||
$tableName = 'T_constraints_2';
|
||||
$name1 = 'CN_constraints_2_single';
|
||||
@ -1484,7 +1484,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertSame($this->getConnection(false)->quoteSql($sql), $builder($this->getQueryBuilder(false)));
|
||||
}
|
||||
|
||||
public function uniquesProvider()
|
||||
public static function uniquesProvider()
|
||||
{
|
||||
$tableName1 = 'T_constraints_1';
|
||||
$name1 = 'CN_unique';
|
||||
@ -1521,7 +1521,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertSame($this->getConnection(false)->quoteSql($sql), $builder($this->getQueryBuilder(false)));
|
||||
}
|
||||
|
||||
public function checksProvider()
|
||||
public static function checksProvider()
|
||||
{
|
||||
$tableName = 'T_constraints_1';
|
||||
$name = 'CN_check';
|
||||
@ -1550,7 +1550,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertSame($this->getConnection(false)->quoteSql($sql), $builder($this->getQueryBuilder(false)));
|
||||
}
|
||||
|
||||
public function defaultValuesProvider()
|
||||
public static function defaultValuesProvider()
|
||||
{
|
||||
$tableName = 'T_constraints_1';
|
||||
$name = 'CN_default';
|
||||
@ -2056,7 +2056,7 @@ abstract class QueryBuilderTest extends DatabaseTestCase
|
||||
$this->assertInstanceOf('yii\db\QueryBuilder', $this->getQueryBuilder(true, true));
|
||||
}
|
||||
|
||||
public function upsertProvider()
|
||||
public static function upsertProvider()
|
||||
{
|
||||
return [
|
||||
'regular values' => [
|
||||
|
@ -333,8 +333,7 @@ abstract class QueryTest extends DatabaseTestCase
|
||||
$this->assertCount(2, $result);
|
||||
|
||||
$this->assertNotContains(1, $result);
|
||||
$this->assertContains(2, $result);
|
||||
$this->assertContains(3, $result);
|
||||
$this->assertEquals([2, 3], $result);
|
||||
}
|
||||
|
||||
public function testUnion()
|
||||
@ -515,6 +514,7 @@ abstract class QueryTest extends DatabaseTestCase
|
||||
$db = $this->getConnection();
|
||||
|
||||
$count = (new Query())->from('customer')->having(['status' => 2])->count('*', $db);
|
||||
|
||||
$this->assertEquals(1, $count);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ abstract class SchemaTest extends DatabaseTestCase
|
||||
*/
|
||||
protected $expectedSchemas;
|
||||
|
||||
public function pdoAttributesProvider()
|
||||
public static function pdoAttributesProvider()
|
||||
{
|
||||
return [
|
||||
[[PDO::ATTR_EMULATE_PREPARES => true]],
|
||||
@ -155,7 +155,7 @@ abstract class SchemaTest extends DatabaseTestCase
|
||||
$this->assertNotSame($noCacheTable, $refreshedTable);
|
||||
}
|
||||
|
||||
public function tableSchemaCachePrefixesProvider()
|
||||
public static function tableSchemaCachePrefixesProvider()
|
||||
{
|
||||
$configs = [
|
||||
[
|
||||
@ -528,7 +528,7 @@ abstract class SchemaTest extends DatabaseTestCase
|
||||
$this->assertSame($expected['precision'], $column->precision, "precision of column $name does not match.");
|
||||
$this->assertSame($expected['scale'], $column->scale, "scale of column $name does not match.");
|
||||
if (\is_object($expected['defaultValue'])) {
|
||||
$this->assertInternalType('object', $column->defaultValue, "defaultValue of column $name is expected to be an object but it is not.");
|
||||
$this->assertIsObject($column->defaultValue, "defaultValue of column $name is expected to be an object but it is not.");
|
||||
$this->assertEquals((string)$expected['defaultValue'], (string)$column->defaultValue, "defaultValue of column $name does not match.");
|
||||
} else {
|
||||
$this->assertEquals($expected['defaultValue'], $column->defaultValue, "defaultValue of column $name does not match.");
|
||||
@ -780,18 +780,32 @@ abstract class SchemaTest extends DatabaseTestCase
|
||||
$this->assertMetadataEquals($expected, $constraints);
|
||||
}
|
||||
|
||||
private function assertMetadataEquals($expected, $actual)
|
||||
protected function assertMetadataEquals($expected, $actual): void
|
||||
{
|
||||
$this->assertInternalType(strtolower(\gettype($expected)), $actual);
|
||||
switch (\strtolower(\gettype($expected))) {
|
||||
case 'object':
|
||||
$this->assertIsObject($actual);
|
||||
break;
|
||||
case 'array':
|
||||
$this->assertIsArray($actual);
|
||||
break;
|
||||
case 'null':
|
||||
$this->assertNull($actual);
|
||||
break;
|
||||
}
|
||||
|
||||
if (\is_array($expected)) {
|
||||
$this->normalizeArrayKeys($expected, false);
|
||||
$this->normalizeArrayKeys($actual, false);
|
||||
}
|
||||
|
||||
$this->normalizeConstraints($expected, $actual);
|
||||
|
||||
if (\is_array($expected)) {
|
||||
$this->normalizeArrayKeys($expected, true);
|
||||
$this->normalizeArrayKeys($actual, true);
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function typesProvider()
|
||||
public static function typesProvider()
|
||||
{
|
||||
return [
|
||||
['integer UNSIGNED', Schema::TYPE_INTEGER, null, [
|
||||
|
@ -84,7 +84,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
$this->assertEquals('SELECT "id", "t"."name" FROM "customer" t', $command->sql);
|
||||
}
|
||||
|
||||
public function batchInsertSqlProvider()
|
||||
public static function batchInsertSqlProvider()
|
||||
{
|
||||
$data = parent::batchInsertSqlProvider();
|
||||
$data['issue11242']['expected'] = 'INSERT INTO "type" ("int_col", "float_col", "char_col") VALUES (NULL, NULL, \'Kyiv {{city}}, Ukraine\')';
|
||||
|
@ -32,12 +32,12 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
return array_merge(parent::columnTypes(), []);
|
||||
}
|
||||
|
||||
public function checksProvider()
|
||||
public static function checksProvider()
|
||||
{
|
||||
$this->markTestSkipped('Adding/dropping check constraints is not supported in CUBRID.');
|
||||
self::markTestSkipped('Adding/dropping check constraints is not supported in CUBRID.');
|
||||
}
|
||||
|
||||
public function defaultValuesProvider()
|
||||
public static function defaultValuesProvider()
|
||||
{
|
||||
$this->markTestSkipped('Adding/dropping default constraints is not supported in CUBRID.');
|
||||
}
|
||||
@ -66,7 +66,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
parent::testCommentColumn();
|
||||
}
|
||||
|
||||
public function upsertProvider()
|
||||
public static function upsertProvider()
|
||||
{
|
||||
$concreteData = [
|
||||
'regular values' => [
|
||||
|
@ -55,7 +55,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
$command = $db->createCommand($sql);
|
||||
$intCol = 123;
|
||||
$charCol = 'abc';
|
||||
$floatCol = 1.23;
|
||||
$floatCol = 1.230;
|
||||
$blobCol = "\x10\x11\x12";
|
||||
$numericCol = '1.23';
|
||||
$boolCol = false;
|
||||
@ -71,7 +71,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
$row = $db->createCommand($sql)->queryOne();
|
||||
$this->assertEquals($intCol, $row['int_col']);
|
||||
$this->assertEquals($charCol, trim($row['char_col']));
|
||||
$this->assertEquals($floatCol, $row['float_col']);
|
||||
$this->assertEquals($floatCol, (float) $row['float_col']);
|
||||
$this->assertEquals($blobCol, $row['blob_col']);
|
||||
$this->assertEquals($numericCol, $row['numeric_col']);
|
||||
|
||||
@ -87,7 +87,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
$this->assertEquals('user5@example.com', $command->queryScalar());
|
||||
}
|
||||
|
||||
public function paramsNonWhereProvider()
|
||||
public static function paramsNonWhereProvider()
|
||||
{
|
||||
return[
|
||||
['SELECT SUBSTRING(name, :len, 6) AS name FROM {{customer}} WHERE [[email]] = :email GROUP BY name'],
|
||||
@ -113,13 +113,13 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
|
||||
$this->assertEmpty($schema->getTableDefaultValues($tableName, true));
|
||||
$db->createCommand()->addDefaultValue($name, $tableName, 'int1', 41)->execute();
|
||||
$this->assertRegExp('/^.*41.*$/', $schema->getTableDefaultValues($tableName, true)[0]->value);
|
||||
$this->assertMatchesRegularExpression('/^.*41.*$/', $schema->getTableDefaultValues($tableName, true)[0]->value);
|
||||
|
||||
$db->createCommand()->dropDefaultValue($name, $tableName)->execute();
|
||||
$this->assertEmpty($schema->getTableDefaultValues($tableName, true));
|
||||
}
|
||||
|
||||
public function batchInsertSqlProvider()
|
||||
public static function batchInsertSqlProvider()
|
||||
{
|
||||
$data = parent::batchInsertSqlProvider();
|
||||
$data['issue11242']['expected'] = 'INSERT INTO [type] ([int_col], [float_col], [char_col]) VALUES (NULL, NULL, \'Kyiv {{city}}, Ukraine\')';
|
||||
|
@ -373,7 +373,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
$this->assertEquals($expected, $sql);
|
||||
}
|
||||
|
||||
public function upsertProvider()
|
||||
public static function upsertProvider()
|
||||
{
|
||||
$concreteData = [
|
||||
'regular values' => [
|
||||
@ -805,7 +805,7 @@ ALTER TABLE [foo1] DROP COLUMN [bar]";
|
||||
$this->assertEquals(NULL, $schema->getColumn('bar'));
|
||||
}
|
||||
|
||||
public function buildFromDataProvider()
|
||||
public static function buildFromDataProvider()
|
||||
{
|
||||
$data = parent::buildFromDataProvider();
|
||||
$data[] = ['[test]', '[[test]]'];
|
||||
|
@ -98,7 +98,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest
|
||||
$this->assertEquals($expectedName, $quotedName);
|
||||
}
|
||||
|
||||
public function quoteTableNameDataProvider()
|
||||
public static function quoteTableNameDataProvider()
|
||||
{
|
||||
return [
|
||||
['test', '[test]'],
|
||||
@ -125,7 +125,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest
|
||||
$this->assertEquals($expectedName, $tableSchema->name);
|
||||
}
|
||||
|
||||
public function getTableSchemaDataProvider()
|
||||
public static function getTableSchemaDataProvider()
|
||||
{
|
||||
return [
|
||||
['[dbo].[profile]', 'profile'],
|
||||
|
@ -32,7 +32,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function typesProvider()
|
||||
public static function typesProvider()
|
||||
{
|
||||
return [
|
||||
['integer UNSIGNED', Schema::TYPE_INTEGER, null, [
|
||||
|
@ -163,7 +163,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
return $columns;
|
||||
}
|
||||
|
||||
public function primaryKeysProvider()
|
||||
public static function primaryKeysProvider()
|
||||
{
|
||||
$result = parent::primaryKeysProvider();
|
||||
$result['drop'][0] = 'ALTER TABLE {{T_constraints_1}} DROP PRIMARY KEY';
|
||||
@ -172,14 +172,14 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function foreignKeysProvider()
|
||||
public static function foreignKeysProvider()
|
||||
{
|
||||
$result = parent::foreignKeysProvider();
|
||||
$result['drop'][0] = 'ALTER TABLE {{T_constraints_3}} DROP FOREIGN KEY [[CN_constraints_3]]';
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function indexesProvider()
|
||||
public static function indexesProvider()
|
||||
{
|
||||
$result = parent::indexesProvider();
|
||||
$result['create'][0] = 'ALTER TABLE {{T_constraints_2}} ADD INDEX [[CN_constraints_2_single]] ([[C_index_1]])';
|
||||
@ -189,21 +189,21 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function uniquesProvider()
|
||||
public static function uniquesProvider()
|
||||
{
|
||||
$result = parent::uniquesProvider();
|
||||
$result['drop'][0] = 'DROP INDEX [[CN_unique]] ON {{T_constraints_1}}';
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function checksProvider()
|
||||
public static function checksProvider()
|
||||
{
|
||||
$this->markTestSkipped('Adding/dropping check constraints is not supported in MySQL.');
|
||||
self::markTestSkipped('Adding/dropping check constraints is not supported in MySQL.');
|
||||
}
|
||||
|
||||
public function defaultValuesProvider()
|
||||
public static function defaultValuesProvider()
|
||||
{
|
||||
$this->markTestSkipped('Adding/dropping default constraints is not supported in MySQL.');
|
||||
self::markTestSkipped('Adding/dropping default constraints is not supported in MySQL.');
|
||||
}
|
||||
|
||||
public function testResetSequence()
|
||||
@ -219,7 +219,7 @@ class QueryBuilderTest extends \yiiunit\framework\db\QueryBuilderTest
|
||||
$this->assertEquals($expected, $sql);
|
||||
}
|
||||
|
||||
public function upsertProvider()
|
||||
public static function upsertProvider()
|
||||
{
|
||||
$concreteData = [
|
||||
'regular values' => [
|
||||
|
@ -43,9 +43,7 @@ class QueryTest extends \yiiunit\framework\db\QueryTest
|
||||
$result = $query->column($this->getConnection());
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
|
||||
$this->assertNotContains(1, $result);
|
||||
$this->assertContains(2, $result);
|
||||
$this->assertContains(3, $result);
|
||||
$this->assertEquals([2, 3], $result);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use yii\db\Transaction;
|
||||
/**
|
||||
* @group db
|
||||
* @group mysql
|
||||
* @group deadlock
|
||||
*/
|
||||
class DeadLockTest extends \yiiunit\framework\db\mysql\ConnectionTest
|
||||
{
|
||||
@ -31,9 +32,6 @@ class DeadLockTest extends \yiiunit\framework\db\mysql\ConnectionTest
|
||||
*/
|
||||
public function testDeadlockException()
|
||||
{
|
||||
if (PHP_VERSION_ID >= 70400 && PHP_VERSION_ID < 70500) {
|
||||
$this->markTestSkipped('Stable failed in PHP 7.4');
|
||||
}
|
||||
if (!\function_exists('pcntl_fork')) {
|
||||
$this->markTestSkipped('pcntl_fork() is not available');
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
||||
public function testCastValues()
|
||||
{
|
||||
// pass, because boolean casting is not available
|
||||
return;
|
||||
$model = new Type();
|
||||
$model->int_col = 123;
|
||||
$model->int_col2 = 456;
|
||||
@ -48,7 +47,7 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest
|
||||
$this->assertSame('1337', trim($model->char_col));
|
||||
$this->assertSame('test', $model->char_col2);
|
||||
$this->assertSame('test123', $model->char_col3);
|
||||
$this->assertSame(1337.42, $model->float_col);
|
||||
$this->assertSame(3.742, $model->float_col);
|
||||
$this->assertSame(42.1337, $model->float_col2);
|
||||
$this->assertEquals('1', $model->bool_col);
|
||||
$this->assertEquals('0', $model->bool_col2);
|
||||
|
@ -32,7 +32,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function typesProvider()
|
||||
public static function typesProvider()
|
||||
{
|
||||
return [
|
||||
['integer UNSIGNED', Schema::TYPE_INTEGER, null, [
|
||||
|
@ -39,7 +39,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
$this->assertEquals(3, $db->getSchema()->getLastInsertID('profile_SEQ'));
|
||||
}
|
||||
|
||||
public function batchInsertSqlProvider()
|
||||
public static function batchInsertSqlProvider()
|
||||
{
|
||||
$data = parent::batchInsertSqlProvider();
|
||||
$data['issue11242']['expected'] = 'INSERT ALL INTO "type" ("int_col", "float_col", "char_col") ' .
|
||||
@ -158,7 +158,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest
|
||||
}, 10);
|
||||
}
|
||||
|
||||
public function paramsNonWhereProvider()
|
||||
public static function paramsNonWhereProvider()
|
||||
{
|
||||
return [
|
||||
['SELECT SUBSTR([[name]], :len) FROM {{customer}} WHERE [[email]] = :email GROUP BY SUBSTR([[name]], :len)'],
|
||||
|
@ -83,8 +83,15 @@ class ConnectionTest extends \yiiunit\framework\db\ConnectionTest
|
||||
$transaction = $connection->beginTransaction(Transaction::READ_COMMITTED);
|
||||
$transaction->commit();
|
||||
|
||||
/* should not be any exception so far */
|
||||
$this->assertTrue(true);
|
||||
|
||||
|
||||
$transaction = $connection->beginTransaction(Transaction::SERIALIZABLE);
|
||||
$transaction->commit();
|
||||
|
||||
/* should not be any exception so far */
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user