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
c4dc9470
Commit
c4dc9470
authored
Aug 13, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created a test case to verify #4682
parent
7ad76857
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
54 additions
and
0 deletions
+54
-0
Type.php
tests/unit/data/ar/Type.php
+1
-0
cubrid.sql
tests/unit/data/cubrid.sql
+1
-0
mssql.sql
tests/unit/data/mssql.sql
+1
-0
mysql.sql
tests/unit/data/mysql.sql
+1
-0
postgres.sql
tests/unit/data/postgres.sql
+1
-0
sqlite.sql
tests/unit/data/sqlite.sql
+1
-0
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+29
-0
SchemaTest.php
tests/unit/framework/db/SchemaTest.php
+12
-0
CubridSchemaTest.php
tests/unit/framework/db/cubrid/CubridSchemaTest.php
+3
-0
PostgreSQLSchemaTest.php
tests/unit/framework/db/pgsql/PostgreSQLSchemaTest.php
+4
-0
No files found.
tests/unit/data/ar/Type.php
View file @
c4dc9470
...
...
@@ -7,6 +7,7 @@ namespace yiiunit\data\ar;
*
* @property int $int_col
* @property int $int_col2 DEFAULT 1
* @property int $smallint_col DEFAULT 1
* @property string $char_col
* @property string $char_col2 DEFAULT 'something'
* @property string $char_col3
...
...
tests/unit/data/cubrid.sql
View file @
c4dc9470
...
...
@@ -100,6 +100,7 @@ CREATE TABLE null_values (
CREATE
TABLE
"type"
(
"int_col"
int
(
11
)
NOT
NULL
,
"int_col2"
int
(
11
)
DEFAULT
'1'
,
"smallint_col"
smallint
(
1
)
DEFAULT
'1'
,
"char_col"
char
(
100
)
NOT
NULL
,
"char_col2"
varchar
(
100
)
DEFAULT
'something'
,
"char_col3"
string
,
...
...
tests/unit/data/mssql.sql
View file @
c4dc9470
...
...
@@ -92,6 +92,7 @@ CREATE TABLE [dbo].[null_values] (
CREATE
TABLE
[
dbo
].[
type
]
(
[
int_col
]
[
int
]
NOT
NULL
,
[
int_col2
]
[
int
]
DEFAULT
'1'
,
[
smallint_col
]
[
smallint
]
DEFAULT
'1'
,
[
char_col
]
[
char
](
100
)
NOT
NULL
,
[
char_col2
]
[
varchar
](
100
)
DEFAULT
'something'
,
[
char_col3
]
[
text
],
...
...
tests/unit/data/mysql.sql
View file @
c4dc9470
...
...
@@ -110,6 +110,7 @@ CREATE TABLE null_values (
CREATE
TABLE
`type`
(
`int_col`
integer
NOT
NULL
,
`int_col2`
integer
DEFAULT
'1'
,
`smallint_col`
smallint
(
1
)
DEFAULT
'1'
,
`char_col`
char
(
100
)
NOT
NULL
,
`char_col2`
varchar
(
100
)
DEFAULT
'something'
,
`char_col3`
text
,
...
...
tests/unit/data/postgres.sql
View file @
c4dc9470
...
...
@@ -100,6 +100,7 @@ CREATE TABLE "null_values" (
CREATE
TABLE
"type"
(
int_col
integer
NOT
NULL
,
int_col2
integer
DEFAULT
'1'
,
smallint_col
smallint
DEFAULT
'1'
,
char_col
char
(
100
)
NOT
NULL
,
char_col2
varchar
(
100
)
DEFAULT
'something'
,
char_col3
text
,
...
...
tests/unit/data/sqlite.sql
View file @
c4dc9470
...
...
@@ -94,6 +94,7 @@ CREATE TABLE "null_values" (
CREATE
TABLE
"type"
(
int_col
INTEGER
NOT
NULL
,
int_col2
INTEGER
DEFAULT
'1'
,
smallint_col
SMALLINT
(
1
)
DEFAULT
'1'
,
char_col
char
(
100
)
NOT
NULL
,
char_col2
varchar
(
100
)
DEFAULT
'something'
,
char_col3
text
,
...
...
tests/unit/framework/db/ActiveRecordTest.php
View file @
c4dc9470
...
...
@@ -573,4 +573,33 @@ class ActiveRecordTest extends DatabaseTestCase
$this
->
assertEquals
(
$orderItemCount
,
$orderItemsWithNullFKClass
::
find
()
->
count
());
$this
->
assertEquals
(
5
,
$itemClass
::
find
()
->
count
());
}
public
function
testCastValues
()
{
$model
=
new
Type
();
$model
->
int_col
=
123
;
$model
->
int_col2
=
456
;
$model
->
smallint_col
=
42
;
$model
->
char_col
=
'1337'
;
$model
->
char_col2
=
'test'
;
$model
->
char_col3
=
'test123'
;
$model
->
float_col
=
1337.42
;
$model
->
float_col2
=
42.1337
;
$model
->
bool_col
=
true
;
$model
->
bool_col2
=
false
;
$model
->
save
(
false
);
/* @var $model Type */
$model
=
Type
::
find
()
->
one
();
$this
->
assertSame
(
123
,
$model
->
int_col
);
$this
->
assertSame
(
456
,
$model
->
int_col2
);
$this
->
assertSame
(
42
,
$model
->
smallint_col
);
$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(42.1337, $model->float_col2);
// $this->assertSame(true, $model->bool_col);
// $this->assertSame(false, $model->bool_col2);
}
}
tests/unit/framework/db/SchemaTest.php
View file @
c4dc9470
...
...
@@ -119,6 +119,18 @@ class SchemaTest extends DatabaseTestCase
'scale'
=>
null
,
'defaultValue'
=>
1
,
],
'smallint_col'
=>
[
'type'
=>
'smallint'
,
'dbType'
=>
'smallint(1)'
,
'phpType'
=>
'integer'
,
'allowNull'
=>
true
,
'autoIncrement'
=>
false
,
'enumValues'
=>
null
,
'size'
=>
1
,
'precision'
=>
1
,
'scale'
=>
null
,
'defaultValue'
=>
1
,
],
'char_col'
=>
[
'type'
=>
'string'
,
'dbType'
=>
'char(100)'
,
...
...
tests/unit/framework/db/cubrid/CubridSchemaTest.php
View file @
c4dc9470
...
...
@@ -45,6 +45,9 @@ class CubridSchemaTest extends SchemaTest
$columns
[
'int_col2'
][
'dbType'
]
=
'integer'
;
$columns
[
'int_col2'
][
'size'
]
=
null
;
$columns
[
'int_col2'
][
'precision'
]
=
null
;
$columns
[
'smallint_col'
][
'dbType'
]
=
'integer'
;
$columns
[
'smallint_col'
][
'size'
]
=
null
;
$columns
[
'smallint_col'
][
'precision'
]
=
null
;
$columns
[
'char_col3'
][
'type'
]
=
'string'
;
$columns
[
'char_col3'
][
'dbType'
]
=
'varchar(1073741823)'
;
$columns
[
'char_col3'
][
'size'
]
=
1073741823
;
...
...
tests/unit/framework/db/pgsql/PostgreSQLSchemaTest.php
View file @
c4dc9470
...
...
@@ -26,6 +26,10 @@ class PostgreSQLSchemaTest extends SchemaTest
$columns
[
'int_col2'
][
'size'
]
=
null
;
$columns
[
'int_col2'
][
'precision'
]
=
32
;
$columns
[
'int_col2'
][
'scale'
]
=
0
;
$columns
[
'smallint_col'
][
'dbType'
]
=
'int2'
;
$columns
[
'smallint_col'
][
'size'
]
=
null
;
$columns
[
'smallint_col'
][
'precision'
]
=
16
;
$columns
[
'smallint_col'
][
'scale'
]
=
0
;
$columns
[
'char_col'
][
'dbType'
]
=
'bpchar'
;
$columns
[
'char_col'
][
'precision'
]
=
null
;
$columns
[
'char_col2'
][
'dbType'
]
=
'varchar'
;
...
...
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