Commit 171e84ab by Qiang Xue

Merge branch 'master' into new-asset

parents 04f49de8 1336cff3
......@@ -14,6 +14,8 @@ Thumbs.db
# composer vendor dir
/vendor
# cubrid install dir
/cubrid
# composer itself is not needed
composer.phar
......
......@@ -7,6 +7,9 @@ php:
- hhvm
- hhvm-nightly
env:
- CUBRID_VERSION=9.3.0/CUBRID-9.3.0.0206 CUBRID_PDO_VERSION=9.2.0.0001
# run build against hhvm but allow them to fail
# http://docs.travis-ci.com/user/build-configuration/#Rows-That-are-Allowed-To-Fail
matrix:
......@@ -21,6 +24,15 @@ services:
- elasticsearch
- mongodb
# faster builds on new travis setup not using sudo
sudo: false
# cache vendor dirs
cache:
directories:
- cubrid
- vendor
# try running against postgres 9.3
addons:
postgresql: "9.3"
......@@ -35,9 +47,7 @@ install:
- tests/unit/data/travis/memcache-setup.sh
- tests/unit/data/travis/cubrid-setup.sh
# codeception
- composer global require "codeception/codeception=2.0.*"
- composer global require "codeception/specify=*"
- composer global require "codeception/verify=*"
- composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*"
# basic and advanced application:
- tests/unit/data/travis/setup-apps.sh
......
......@@ -6,57 +6,54 @@ After creating and setting up the advanced application, follow these steps to pr
1. Install Codeception if it's not yet installed:
```
composer global require "codeception/codeception=2.0.*"
composer global require "codeception/specify=*"
composer global require "codeception/verify=*"
```
```
composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*"
```
If you've never used Composer for global packages run `composer global status`. It should output:
If you've never used Composer for global packages run `composer global status`. It should output:
```
Changed current directory to <directory>
```
```
Changed current directory to <directory>
```
Then add `<directory>/vendor/bin` to you `PATH` environment variable. Now we're able to use `codecept` from command
line globally.
Then add `<directory>/vendor/bin` to you `PATH` environment variable. Now you're able to use `codecept` from command
line globally.
2. Install faker extension by running the following from template root directory where `composer.json` is:
```
composer require --dev yiisoft/yii2-faker:*
```
```
composer require --dev yiisoft/yii2-faker:*
```
3. Create `yii2_advanced_tests` database then update it by applying migrations:
```
codeception/bin/yii migrate
```
```
codeception/bin/yii migrate
```
4. In order to be able to run acceptance tests you need to start a webserver. The simplest way is to use PHP built in
webserver. In the root directory where `common`, `frontend` etc. are execute the following:
webserver. In the root directory where `common`, `frontend` etc. are execute the following:
```
php -S localhost:8080
```
```
php -S localhost:8080
```
5. Now you can run the tests with the following commands:
```
# frontend tests
cd frontend
codecept build
codecept run
# backend tests
cd backend
codecept build
codecept run
# etc.
```
If you already have run `codecept build` for each application, you can run all tests by a single `codecept run` in the
`tests` directory.
```
# frontend tests
cd frontend
codecept build
codecept run
# backend tests
cd backend
codecept build
codecept run
# etc.
```
If you already have run `codecept build` for each application, you can run all tests by a single `codecept run` in the
`tests` directory.
......@@ -17,7 +17,6 @@ To define a behavior, create a class that extends [[yii\base\Behavior]], or exte
```php
namespace app\components;
use yii\base\Model;
use yii\base\Behavior;
class MyBehavior extends Behavior
......
......@@ -459,13 +459,45 @@ public function init()
}
```
There where some problems with overriding the constructor of an ActiveRecord class in 1.1. These are not present in
There were some problems with overriding the constructor of an ActiveRecord class in 1.1. These are not present in
version 2.0 anymore. Note that when adding parameters to the constructor you might have to override [[yii\db\ActiveRecord::instantiate()]].
There are many other changes and enhancements to Active Record. Please refer to
the [Active Record](db-active-record.md) section for more details.
Active Record Behaviors
-----------------------
In 2.0, we have dropped the base behavior class `CActiveRecordBehavior`. If you want to create an Active Record Behavior,
you will have to extend directly from `yii\base\Behavior`. If the behavior class needs to respond to some events
of the owner, you have to override the `events()` method like the following,
```php
namespace app\components;
use yii\db\ActiveRecord;
use yii\base\Behavior;
class MyBehavior extends Behavior
{
// ...
public function events()
{
return [
ActiveRecord::EVENT_BEFORE_VALIDATE => 'beforeValidate',
];
}
public function beforeValidate($event)
{
// ...
}
}
```
User and IdentityInterface
--------------------------
......
{
"name": "yii2-bootstrap",
"version": "2.0.0",
"homepage": "http://www.yiiframework.com/",
"authors": [
"Qiang Xue <qiang.xue@gmail.com>"
],
"description": "The Twitter Bootstrap extension for the Yii framework",
"keywords": [
"yii2",
"bootstrap"
],
"license": "BSD-3-Clause",
"ignore": [
"**/.*",
"**/*"
],
"dependencies": {
"bootstrap": ">=3.0.0"
}
}
{
"name": "yii2-jui",
"version": "2.0.0",
"homepage": "http://www.yiiframework.com/",
"authors": [
"Qiang Xue <qiang.xue@gmail.com>"
],
"description": "The Jquery UI extension for the Yii framework",
"keywords": [
"yii2", "Jquery UI"
],
"license": "BSD-3-Clause",
"ignore": [
"**/.*",
"**/*"
],
"dependencies": {
"jquery.ui": ">=1.10.0"
}
}
{
"name": "yiisoft/yii2-jui",
"description": "The Jquery UI extension for the Yii framework",
"keywords": ["yii2", "Jquery UI", "renderer"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Ajui",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": {
"yiisoft/yii2": "*"
},
"autoload": {
"psr-4": { "yii\\jui\\": "" }
}
"name": "yiisoft/yii2-jui",
"description": "The Jquery UI extension for the Yii framework",
"keywords": ["yii2", "Jquery UI"],
"type": "yii2-extension",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?labels=ext%3Ajui",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"authors": [
{
"name": "Qiang Xue",
"email": "qiang.xue@gmail.com"
}
],
"require": {
"yiisoft/yii2": "*"
},
"autoload": {
"psr-4": {
"yii\\jui\\": ""
}
}
}
......@@ -82,6 +82,7 @@ Yii Framework 2 Change Log
- Bug #4519: `yii\base\Model::isAttributeRequired()` should check if the `when` option of the validator is set (thiagotalma)
- Bug #4592: Fixed `yii help` command was listing incorrect action names for methods like `actionSayNO` (samdark)
- Bug #4654: Fixed issue with PostgreSQL and inserting boolean values with batch insert (cebe)
- Bug #4672: Fixed issue with PostgreSQL handling of boolean values in queries, dropped support for using boolean value for integer columns (cebe)
- Bug #4727: Fixed wrong Stylus definition in `\yii\web\AssetConverter` (samdark)
- Bug #4813: Fixed MSSQL schema that was getting incorrect info about constraints (samdark, SerjRamone, o-rey)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
......@@ -242,7 +243,6 @@ Yii Framework 2 Change Log
- Chg #4586: Signed bigint and unsigned int will be converted into integers when they are loaded from DB by AR (qiangxue)
- Chg #4591: `yii\helpers\Url::to()` will no longer prefix relative URLs with the base URL (qiangxue)
- Chg #4595: `yii\widgets\LinkPager`'s `nextPageLabel`, `prevPageLabel`, `firstPageLabel`, `lastPageLabel` are now taking `false` instead of `null` for "no label" (samdark)
- Chg #4829: Removed `PARSING_ONLY` from `\yii\rest\UrlRule` to allow creating non-GET URLs for forms and tests (samdark)
- Chg: Replaced `clearAll()` and `clearAllAssignments()` in `yii\rbac\ManagerInterface` with `removeAll()`, `removeAllRoles()`, `removeAllPermissions()`, `removeAllRules()` and `removeAllAssignments()` (qiangxue)
- Chg: Added `$user` as the first parameter of `yii\rbac\Rule::execute()` (qiangxue)
- Chg: `yii\grid\DataColumn::getDataCellValue()` visibility is now `public` to allow accessing the value from a GridView directly (cebe)
......
......@@ -29,6 +29,7 @@
],
"dependencies": {
"jquery.inputmask": ">=3.0.0",
"punycode": ">=1.3.0"
"punycode": ">=1.3.0",
"yii2-pjax": ">=2.0.0"
}
}
......@@ -167,29 +167,6 @@ class Schema extends \yii\db\Schema
}
/**
* Determines the PDO type for the given PHP data value.
* @param mixed $data the data whose PDO type is to be determined
* @return integer the PDO type
* @see http://www.php.net/manual/en/pdo.constants.php
*/
public function getPdoType($data)
{
// php type => PDO type
static $typeMap = [
// https://github.com/yiisoft/yii2/issues/1115
// Cast boolean to integer values to work around problems with PDO casting false to string '' https://bugs.php.net/bug.php?id=33876
'boolean' => \PDO::PARAM_INT,
'integer' => \PDO::PARAM_INT,
'string' => \PDO::PARAM_STR,
'resource' => \PDO::PARAM_LOB,
'NULL' => \PDO::PARAM_NULL,
];
$type = gettype($data);
return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR;
}
/**
* Returns all table names in the database.
* @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema.
* @return array all table names in the database. The names have NO schema name prefix.
......
......@@ -201,6 +201,9 @@ class UrlRule extends CompositeUrlRule
$config['verb'] = $verbs;
$config['pattern'] = rtrim($prefix . '/' . strtr($pattern, $this->tokens), '/');
$config['route'] = $action;
if (!in_array('GET', $verbs)) {
$config['mode'] = \yii\web\UrlRule::PARSING_ONLY;
}
$config['suffix'] = $this->suffix;
return Yii::createObject($config);
......
......@@ -35,6 +35,7 @@ CREATE TABLE "customer" (
name varchar(128),
address text,
status integer DEFAULT 0,
bool_status boolean DEFAULT FALSE,
profile_id integer
);
......@@ -109,8 +110,8 @@ CREATE TABLE "type" (
blob_col bytea,
numeric_col decimal(5,2) DEFAULT '33.22',
time timestamp NOT NULL DEFAULT '2002-01-01 00:00:00',
bool_col smallint NOT NULL,
bool_col2 smallint DEFAULT '1',
bool_col boolean NOT NULL,
bool_col2 boolean DEFAULT TRUE,
ts_default TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
bit_col BIT(8) NOT NULL DEFAULT B'10000010'
);
......@@ -125,9 +126,9 @@ CREATE TABLE "bool_values" (
INSERT INTO "profile" (description) VALUES ('profile customer 1');
INSERT INTO "profile" (description) VALUES ('profile customer 3');
INSERT INTO "customer" (email, name, address, status, profile_id) VALUES ('user1@example.com', 'user1', 'address1', 1, 1);
INSERT INTO "customer" (email, name, address, status) VALUES ('user2@example.com', 'user2', 'address2', 1);
INSERT INTO "customer" (email, name, address, status, profile_id) VALUES ('user3@example.com', 'user3', 'address3', 2, 2);
INSERT INTO "customer" (email, name, address, status, bool_status, profile_id) VALUES ('user1@example.com', 'user1', 'address1', 1, true, 1);
INSERT INTO "customer" (email, name, address, status, bool_status) VALUES ('user2@example.com', 'user2', 'address2', 1, true);
INSERT INTO "customer" (email, name, address, status, bool_status, profile_id) VALUES ('user3@example.com', 'user3', 'address3', 2, false, 2);
INSERT INTO "category" (name) VALUES ('Books');
INSERT INTO "category" (name) VALUES ('Movies');
......
......@@ -68,7 +68,7 @@ source yii2_test_item_delta_src : yii2_test_item_src
index yii2_test_article_index
{
source = yii2_test_article_src
path = /var/lib/sphinx/yii2_test_article
path = SPHINX_BASE_DIR/yii2_test_article
docinfo = extern
charset_type = sbcs
}
......@@ -77,7 +77,7 @@ index yii2_test_article_index
index yii2_test_item_index
{
source = yii2_test_item_src
path = /var/lib/sphinx/yii2_test_item
path = SPHINX_BASE_DIR/yii2_test_item
docinfo = extern
charset_type = sbcs
}
......@@ -86,14 +86,14 @@ index yii2_test_item_index
index yii2_test_item_delta_index : yii2_test_item_index
{
source = yii2_test_item_delta_src
path = /var/lib/sphinx/yii2_test_item_delta
path = SPHINX_BASE_DIR/yii2_test_item_delta
}
index yii2_test_rt_index
{
type = rt
path = /var/lib/sphinx/yii2_test_rt
path = SPHINX_BASE_DIR/yii2_test_rt
rt_field = title
rt_field = content
rt_attr_uint = type_id
......@@ -118,15 +118,15 @@ searchd
{
listen = 127.0.0.1:9312
listen = 9306:mysql41
log = /var/log/sphinx/searchd.log
query_log = /var/log/sphinx/query.log
log = SPHINX_BASE_DIR/searchd.log
query_log = SPHINX_BASE_DIR/query.log
read_timeout = 5
max_children = 30
pid_file = /var/run/sphinx/searchd.pid
pid_file = SPHINX_BASE_DIR/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = /var/lib/sphinx
binlog_path = SPHINX_BASE_DIR
}
......@@ -7,24 +7,74 @@ if (php --version | grep -i HipHop > /dev/null); then
exit 0
fi
CWD=$(pwd)
# cubrid dbms
echo 'yes' | sudo add-apt-repository ppa:cubrid/cubrid
sudo apt-get update
sudo apt-get install cubrid
/etc/profile.d/cubrid.sh
sudo apt-get install cubrid-demodb
mkdir -p cubrid/$CUBRID_VERSION
cd cubrid
if (test -f $CUBRID_VERSION-linux.x86_64.tar.gz); then
echo "CUBRID is already installed"
else
wget http://ftp.cubrid.org/CUBRID_Engine/$CUBRID_VERSION-linux.x86_64.tar.gz -O $CUBRID_VERSION-linux.x86_64.tar.gz
fi
cd $CUBRID_VERSION
tar xzf ../../$CUBRID_VERSION-linux.x86_64.tar.gz
cd ../..
# setting cubrid env
CUBRID=$CWD/cubrid/$CUBRID_VERSION/CUBRID
CUBRID_DATABASES=$CUBRID/databases
CUBRID_LANG=en_US
ld_lib_path=`printenv LD_LIBRARY_PATH`
if [ "$ld_lib_path" = "" ]
then
LD_LIBRARY_PATH=$CUBRID/lib
else
LD_LIBRARY_PATH=$CUBRID/lib:$LD_LIBRARY_PATH
fi
SHLIB_PATH=$LD_LIBRARY_PATH
LIBPATH=$LD_LIBRARY_PATH
PATH=$CUBRID/bin:$CUBRID/cubridmanager:$PATH
export CUBRID
export CUBRID_DATABASES
export CUBRID_LANG
export LD_LIBRARY_PATH
export SHLIB_PATH
export LIBPATH
export PATH
# start cubrid
cubrid service start
# create and start the demo db
$CUBRID/demo/make_cubrid_demo.sh
cubrid server start demodb
echo ""
echo "Installed CUBRID $CUBRID_VERSION"
echo ""
# cubrid pdo
install_pdo_cubrid() {
wget "http://pecl.php.net/get/PDO_CUBRID-9.2.0.0001.tgz" &&
tar -zxf "PDO_CUBRID-9.2.0.0001.tgz" &&
sh -c "cd PDO_CUBRID-9.2.0.0001 && phpize && ./configure && make && sudo make install"
if (test "! (-f PDO_CUBRID-$CUBRID_PDO_VERSION.tgz)"); then
wget "http://pecl.php.net/get/PDO_CUBRID-$CUBRID_PDO_VERSION.tgz" -O PDO_CUBRID-$CUBRID_PDO_VERSION.tgz
fi
tar -zxf "PDO_CUBRID-$CUBRID_PDO_VERSION.tgz"
sh -c "cd PDO_CUBRID-$CUBRID_PDO_VERSION && phpize && ./configure --prefix=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION && make"
echo "extension=pdo_cubrid.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
echo "extension=$CWD/cubrid/PDO_CUBRID-$CUBRID_PDO_VERSION/modules/pdo_cubrid.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
return $?
}
install_pdo_cubrid > ~/pdo_cubrid.log || ( echo "=== PDO CUBRID BUILD FAILED ==="; cat ~/pdo_cubrid.log )
echo "Installed CUBRID `dpkg -s cubrid |grep Version`"
echo ""
echo "Installed CUBRID PDO $CUBRID_PDO_VERSION"
echo ""
cd ..
......@@ -2,10 +2,11 @@
#
# install mongodb
mongod --version
echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
sudo sh -c 'echo "setParameter = textSearchEnabled=true" >> /etc/mongodb.conf'
cat /etc/mongodb.conf
mongod --version
# enable text search
mongo --eval 'db.adminCommand( { setParameter: true, textSearchEnabled : true})'
sudo service mongodb restart
cat /etc/mongodb.conf
......@@ -2,19 +2,26 @@
SCRIPT=$(readlink -f "$0")
CWD=$(dirname "$SCRIPT")
# work around https://github.com/travis-ci/travis-ci/issues/2728
PATH=$PATH:/usr/local/sphinx-2.1.9/bin
mkdir -p sphinx
sed -i s\~SPHINX_BASE_DIR~$PWD/sphinx~g $CWD/../sphinx/sphinx.conf
# log files
sudo mkdir /var/log/sphinx
sudo touch /var/log/sphinx/searchd.log
sudo touch /var/log/sphinx/query.log
sudo chmod -R 777 /var/log/sphinx # ugly (for travis)
#sudo mkdir /var/log/sphinx
#sudo touch /var/log/sphinx/searchd.log
#sudo touch /var/log/sphinx/query.log
#sudo chmod -R 777 /var/log/sphinx # ugly (for travis)
# spl dir
sudo mkdir /var/lib/sphinx
sudo chmod 777 /var/lib/sphinx # ugly (for travis)
#sudo mkdir /var/lib/sphinx
#sudo chmod 777 /var/lib/sphinx # ugly (for travis)
# run dir pid
sudo mkdir /var/run/sphinx
sudo chmod 777 /var/run/sphinx # ugly (for travis)
#sudo mkdir /var/run/sphinx
#sudo chmod 777 /var/run/sphinx # ugly (for travis)
# Setup source database
mysql -D yiitest -u travis < $CWD/../sphinx/source.sql
......
......@@ -2,8 +2,12 @@
namespace yiiunit\framework\db\pgsql;
use yii\behaviors\TimestampBehavior;
use yii\db\pgsql\Schema;
use yiiunit\data\ar\ActiveRecord;
use yiiunit\framework\ar\ActiveRecordTestTrait;
use yiiunit\framework\db\ActiveRecordTest;
use yiiunit\TestCase;
/**
* @group db
......@@ -13,6 +17,72 @@ class PostgreSQLActiveRecordTest extends ActiveRecordTest
{
protected $driverName = 'pgsql';
public function testBooleanAttribute()
{
/* @var $customerClass \yii\db\ActiveRecordInterface */
$customerClass = $this->getCustomerClass();
/* @var $this TestCase|ActiveRecordTestTrait */
$customer = new $customerClass();
$customer->name = 'boolean customer';
$customer->email = 'mail@example.com';
$customer->bool_status = false;
$customer->save(false);
$customer->refresh();
$this->assertSame(false, $customer->bool_status);
$customer->bool_status = true;
$customer->save(false);
$customer->refresh();
$this->assertSame(true, $customer->bool_status);
$customers = $customerClass::find()->where(['bool_status' => true])->all();
$this->assertEquals(3, count($customers));
$customers = $customerClass::find()->where(['bool_status' => false])->all();
$this->assertEquals(1, count($customers));
}
public function testFindAsArray()
{
/* @var $customerClass \yii\db\ActiveRecordInterface */
$customerClass = $this->getCustomerClass();
// asArray
$customer = $customerClass::find()->where(['id' => 2])->asArray()->one();
$this->assertEquals([
'id' => 2,
'email' => 'user2@example.com',
'name' => 'user2',
'address' => 'address2',
'status' => 1,
'profile_id' => null,
'bool_status' => true,
], $customer);
// find all asArray
$customers = $customerClass::find()->asArray()->all();
$this->assertEquals(3, count($customers));
$this->assertArrayHasKey('id', $customers[0]);
$this->assertArrayHasKey('name', $customers[0]);
$this->assertArrayHasKey('email', $customers[0]);
$this->assertArrayHasKey('address', $customers[0]);
$this->assertArrayHasKey('status', $customers[0]);
$this->assertArrayHasKey('bool_status', $customers[0]);
$this->assertArrayHasKey('id', $customers[1]);
$this->assertArrayHasKey('name', $customers[1]);
$this->assertArrayHasKey('email', $customers[1]);
$this->assertArrayHasKey('address', $customers[1]);
$this->assertArrayHasKey('status', $customers[1]);
$this->assertArrayHasKey('bool_status', $customers[1]);
$this->assertArrayHasKey('id', $customers[2]);
$this->assertArrayHasKey('name', $customers[2]);
$this->assertArrayHasKey('email', $customers[2]);
$this->assertArrayHasKey('address', $customers[2]);
$this->assertArrayHasKey('status', $customers[2]);
$this->assertArrayHasKey('bool_status', $customers[2]);
}
public function testBooleanValues()
{
......@@ -40,6 +110,42 @@ class PostgreSQLActiveRecordTest extends ActiveRecordTest
$this->assertSame(false, BoolAR::find()->where(['bool_col' => false])->one($db)->bool_col);
}
/**
* https://github.com/yiisoft/yii2/issues/4672
*/
public function testBooleanValues2()
{
$db = $this->getConnection();
$db->charset = 'utf8';
$db->createCommand("DROP TABLE IF EXISTS bool_user;")->execute();
$db->createCommand()->createTable('bool_user', [
'id' => Schema::TYPE_PK,
'username' => Schema::TYPE_STRING . ' NOT NULL',
'auth_key' => Schema::TYPE_STRING . '(32) NOT NULL',
'password_hash' => Schema::TYPE_STRING . ' NOT NULL',
'password_reset_token' => Schema::TYPE_STRING,
'email' => Schema::TYPE_STRING . ' NOT NULL',
'role' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
'status' => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 10',
'created_at' => Schema::TYPE_INTEGER . ' NOT NULL',
'updated_at' => Schema::TYPE_INTEGER . ' NOT NULL',
])->execute();
$db->createCommand()->addColumn('bool_user', 'is_deleted', Schema::TYPE_BOOLEAN . ' NOT NULL DEFAULT FALSE')->execute();
$user = new UserAR();
$user->username = 'test';
$user->auth_key = 'test';
$user->password_hash = 'test';
$user->email = 'test@example.com';
$user->save(false);
$this->assertEquals(1, count(UserAR::find()->where(['is_deleted' => false])->all($db)));
$this->assertEquals(0, count(UserAR::find()->where(['is_deleted' => true])->all($db)));
$this->assertEquals(1, count(UserAR::find()->where(['is_deleted' => [true, false]])->all($db)));
}
public function testBooleanDefaultValues()
{
$model = new BoolAR();
......@@ -61,4 +167,24 @@ class BoolAR extends ActiveRecord
{
return 'bool_values';
}
}
\ No newline at end of file
}
class UserAR extends ActiveRecord
{
const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10;
const ROLE_USER = 10;
public static function tableName()
{
return '{{%bool_user}}';
}
public function behaviors()
{
return [
TimestampBehavior::className(),
];
}
}
......@@ -47,14 +47,19 @@ class PostgreSQLSchemaTest extends SchemaTest
$columns['blob_col']['type'] = 'binary';
$columns['numeric_col']['dbType'] = 'numeric';
$columns['numeric_col']['size'] = null;
$columns['bool_col']['dbType'] = 'int2';
$columns['bool_col']['type'] = 'boolean';
$columns['bool_col']['phpType'] = 'boolean';
$columns['bool_col']['dbType'] = 'bool';
$columns['bool_col']['size'] = null;
$columns['bool_col']['precision'] = 16;
$columns['bool_col']['scale'] = 0;
$columns['bool_col2']['dbType'] = 'int2';
$columns['bool_col']['precision'] = null;
$columns['bool_col']['scale'] = null;
$columns['bool_col2']['type'] = 'boolean';
$columns['bool_col2']['phpType'] = 'boolean';
$columns['bool_col2']['dbType'] = 'bool';
$columns['bool_col2']['size'] = null;
$columns['bool_col2']['precision'] = 16;
$columns['bool_col2']['scale'] = 0;
$columns['bool_col2']['precision'] = null;
$columns['bool_col2']['scale'] = null;
$columns['bool_col2']['defaultValue'] = true;
$columns['ts_default']['defaultValue'] = new Expression('now()');
$columns['bit_col']['dbType'] = 'bit';
$columns['bit_col']['size'] = 8;
......@@ -71,8 +76,8 @@ class PostgreSQLSchemaTest extends SchemaTest
[0, \PDO::PARAM_INT],
[1, \PDO::PARAM_INT],
[1337, \PDO::PARAM_INT],
[true, \PDO::PARAM_INT],
[false, \PDO::PARAM_INT],
[true, \PDO::PARAM_BOOL],
[false, \PDO::PARAM_BOOL],
[$fp = fopen(__FILE__, 'rb'), \PDO::PARAM_LOB],
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment