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
8e1079cd
Commit
8e1079cd
authored
May 23, 2013
by
resurtm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MSSQL more tests.
parent
caf9948c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
3 deletions
+54
-3
mssql.sql
tests/unit/data/mssql.sql
+1
-1
MssqlCommandTest.php
tests/unit/framework/db/mssql/MssqlCommandTest.php
+53
-2
No files found.
tests/unit/data/mssql.sql
View file @
8e1079cd
...
@@ -62,7 +62,7 @@ CREATE TABLE [dbo].[tbl_type] (
...
@@ -62,7 +62,7 @@ CREATE TABLE [dbo].[tbl_type] (
[
char_col3
]
[
text
],
[
char_col3
]
[
text
],
[
float_col
]
[
decimal
](
4
,
3
)
NOT
NULL
,
[
float_col
]
[
decimal
](
4
,
3
)
NOT
NULL
,
[
float_col2
]
[
float
]
DEFAULT
'1.23'
,
[
float_col2
]
[
float
]
DEFAULT
'1.23'
,
[
blob_col
]
[
binary
]
,
[
blob_col
]
[
varbinary
](
MAX
)
,
[
numeric_col
]
[
decimal
](
5
,
2
)
DEFAULT
'33.22'
,
[
numeric_col
]
[
decimal
](
5
,
2
)
DEFAULT
'33.22'
,
[
time
]
[
datetime
]
NOT
NULL
DEFAULT
'2002-01-01 00:00:00'
,
[
time
]
[
datetime
]
NOT
NULL
DEFAULT
'2002-01-01 00:00:00'
,
[
bool_col
]
[
tinyint
]
NOT
NULL
,
[
bool_col
]
[
tinyint
]
NOT
NULL
,
...
...
tests/unit/framework/db/mssql/MssqlCommandTest.php
View file @
8e1079cd
...
@@ -21,11 +21,62 @@ class MssqlCommandTest extends \yiiunit\framework\db\CommandTest
...
@@ -21,11 +21,62 @@ class MssqlCommandTest extends \yiiunit\framework\db\CommandTest
function
testPrepareCancel
()
function
testPrepareCancel
()
{
{
$this
->
markTest
Incomplete
(
);
$this
->
markTest
Skipped
(
'MSSQL driver does not support this feature.'
);
}
}
function
testBindParamValue
()
function
testBindParamValue
()
{
{
$this
->
markTestIncomplete
();
$db
=
$this
->
getConnection
();
// bindParam
$sql
=
'INSERT INTO tbl_customer(email, name, address) VALUES (:email, :name, :address)'
;
$command
=
$db
->
createCommand
(
$sql
);
$email
=
'user4@example.com'
;
$name
=
'user4'
;
$address
=
'address4'
;
$command
->
bindParam
(
':email'
,
$email
);
$command
->
bindParam
(
':name'
,
$name
);
$command
->
bindParam
(
':address'
,
$address
);
$command
->
execute
();
$sql
=
'SELECT name FROM tbl_customer WHERE email=:email'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindParam
(
':email'
,
$email
);
$this
->
assertEquals
(
$name
,
$command
->
queryScalar
());
$sql
=
'INSERT INTO tbl_type (int_col, char_col, float_col, blob_col, numeric_col, bool_col) VALUES (:int_col, :char_col, :float_col, CONVERT([varbinary], :blob_col), :numeric_col, :bool_col)'
;
$command
=
$db
->
createCommand
(
$sql
);
$intCol
=
123
;
$charCol
=
'abc'
;
$floatCol
=
1.23
;
$blobCol
=
"
\x10\x11\x12
"
;
$numericCol
=
'1.23'
;
$boolCol
=
false
;
$command
->
bindParam
(
':int_col'
,
$intCol
);
$command
->
bindParam
(
':char_col'
,
$charCol
);
$command
->
bindParam
(
':float_col'
,
$floatCol
);
$command
->
bindParam
(
':blob_col'
,
$blobCol
);
$command
->
bindParam
(
':numeric_col'
,
$numericCol
);
$command
->
bindParam
(
':bool_col'
,
$boolCol
);
$this
->
assertEquals
(
1
,
$command
->
execute
());
$sql
=
'SELECT int_col, char_col, float_col, CONVERT([nvarchar], blob_col) AS blob_col, numeric_col FROM tbl_type'
;
$row
=
$db
->
createCommand
(
$sql
)
->
queryRow
();
$this
->
assertEquals
(
$intCol
,
$row
[
'int_col'
]);
$this
->
assertEquals
(
$charCol
,
trim
(
$row
[
'char_col'
]));
$this
->
assertEquals
(
$floatCol
,
$row
[
'float_col'
]);
$this
->
assertEquals
(
$blobCol
,
$row
[
'blob_col'
]);
$this
->
assertEquals
(
$numericCol
,
$row
[
'numeric_col'
]);
// bindValue
$sql
=
'INSERT INTO tbl_customer(email, name, address) VALUES (:email, \'user5\', \'address5\')'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindValue
(
':email'
,
'user5@example.com'
);
$command
->
execute
();
$sql
=
'SELECT email FROM tbl_customer WHERE name=:name'
;
$command
=
$db
->
createCommand
(
$sql
);
$command
->
bindValue
(
':name'
,
'user5'
);
$this
->
assertEquals
(
'user5@example.com'
,
$command
->
queryScalar
());
}
}
}
}
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