Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
30e85fae
Commit
30e85fae
authored
Nov 01, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:yiisoft/yii2
parents
fedc38fd
ee1689da
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
28 deletions
+84
-28
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+47
-0
CubridActiveRecordTest.php
tests/unit/framework/db/cubrid/CubridActiveRecordTest.php
+0
-28
PostgreSQLActiveRecordTest.php
tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php
+5
-0
SqliteActiveRecordTest.php
tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php
+32
-0
No files found.
tests/unit/framework/db/ActiveRecordTest.php
View file @
30e85fae
...
...
@@ -426,4 +426,51 @@ class ActiveRecordTest extends DatabaseTestCase
$this
->
assertEquals
(
0
,
$record
->
var3
);
$this
->
assertEquals
(
''
,
$record
->
stringcol
);
}
public
function
testStoreEmpty
()
{
$record
=
new
NullValues
();
$record
->
id
=
1
;
// this is to simulate empty html form submission
$record
->
var1
=
''
;
$record
->
var2
=
''
;
$record
->
var3
=
''
;
$record
->
stringcol
=
''
;
$record
->
save
(
false
);
$this
->
assertTrue
(
$record
->
refresh
());
// https://github.com/yiisoft/yii2/commit/34945b0b69011bc7cab684c7f7095d837892a0d4#commitcomment-4458225
$this
->
assertTrue
(
$record
->
var1
===
$record
->
var2
);
$this
->
assertTrue
(
$record
->
var2
===
$record
->
var3
);
}
/**
* Some PDO implementations(e.g. cubrid) do not support boolean values.
* Make sure this does not affect AR layer.
*/
public
function
testBooleanAttribute
()
{
$customer
=
new
Customer
();
$customer
->
name
=
'boolean customer'
;
$customer
->
email
=
'mail@example.com'
;
$customer
->
status
=
true
;
$customer
->
save
(
false
);
$customer
->
refresh
();
$this
->
assertEquals
(
1
,
$customer
->
status
);
$customer
->
status
=
false
;
$customer
->
save
(
false
);
$customer
->
refresh
();
$this
->
assertEquals
(
0
,
$customer
->
status
);
$customers
=
Customer
::
find
()
->
where
([
'status'
=>
true
])
->
all
();
$this
->
assertEquals
(
2
,
count
(
$customers
));
$customers
=
Customer
::
find
()
->
where
([
'status'
=>
false
])
->
all
();
$this
->
assertEquals
(
1
,
count
(
$customers
));
}
}
tests/unit/framework/db/cubrid/CubridActiveRecordTest.php
View file @
30e85fae
...
...
@@ -11,32 +11,4 @@ use yiiunit\framework\db\ActiveRecordTest;
class
CubridActiveRecordTest
extends
ActiveRecordTest
{
public
$driverName
=
'cubrid'
;
/**
* cubrid PDO does not support boolean values.
* Make sure this does not affect AR layer.
*/
public
function
testBooleanAttribute
()
{
$customer
=
new
Customer
();
$customer
->
name
=
'boolean customer'
;
$customer
->
email
=
'mail@example.com'
;
$customer
->
status
=
true
;
$customer
->
save
(
false
);
$customer
->
refresh
();
$this
->
assertEquals
(
1
,
$customer
->
status
);
$customer
->
status
=
false
;
$customer
->
save
(
false
);
$customer
->
refresh
();
$this
->
assertEquals
(
0
,
$customer
->
status
);
$customers
=
Customer
::
find
()
->
where
([
'status'
=>
true
])
->
all
();
$this
->
assertEquals
(
2
,
count
(
$customers
));
$customers
=
Customer
::
find
()
->
where
([
'status'
=>
false
])
->
all
();
$this
->
assertEquals
(
1
,
count
(
$customers
));
}
}
tests/unit/framework/db/pgsql/PostgreSQLActiveRecordTest.php
View file @
30e85fae
...
...
@@ -11,4 +11,9 @@ use yiiunit\framework\db\ActiveRecordTest;
class
PostgreSQLActiveRecordTest
extends
ActiveRecordTest
{
protected
$driverName
=
'pgsql'
;
public
function
testBooleanAttribute
()
{
$this
->
markTestSkipped
(
'Storing boolean values does not work in PostgreSQL right now. See https://github.com/yiisoft/yii2/issues/1115 for details.'
);
}
}
tests/unit/framework/db/sqlite/SqliteActiveRecordTest.php
View file @
30e85fae
<?php
namespace
yiiunit\framework\db\sqlite
;
use
yiiunit\data\ar\Customer
;
use
yiiunit\framework\db\ActiveRecordTest
;
/**
...
...
@@ -10,4 +11,35 @@ use yiiunit\framework\db\ActiveRecordTest;
class
SqliteActiveRecordTest
extends
ActiveRecordTest
{
protected
$driverName
=
'sqlite'
;
/**
* Some PDO implementations(e.g. cubrid) do not support boolean values.
* Make sure this does not affect AR layer.
*/
public
function
testBooleanAttribute
()
{
$customer
=
new
Customer
();
$customer
->
name
=
'boolean customer'
;
$customer
->
email
=
'mail@example.com'
;
$customer
->
status
=
true
;
$customer
->
save
(
false
);
$customer
->
refresh
();
$this
->
assertEquals
(
1
,
$customer
->
status
);
$customer
->
status
=
false
;
$customer
->
save
(
false
);
$customer
->
refresh
();
// sqlite will return empty string here but it would still
// evaluate to false or null so we accept it
$this
->
assertTrue
(
0
==
$customer
->
status
);
// select with boolean values does not seem to work in sqlite
// $customers = Customer::find()->where(['status' => true])->all();
// $this->assertEquals(2, count($customers));
//
// $customers = Customer::find()->where(['status' => false])->all();
// $this->assertEquals(1, count($customers));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment