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
6e3dfb8f
Commit
6e3dfb8f
authored
Nov 11, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"Sphinx" unit tests for "update" and "delete" added.
parent
0f94ed39
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
Schema.php
extensions/sphinx/Schema.php
+17
-0
CommandTest.php
tests/unit/extensions/sphinx/CommandTest.php
+26
-2
No files found.
extensions/sphinx/Schema.php
View file @
6e3dfb8f
...
...
@@ -19,6 +19,23 @@ use yii\db\TableSchema;
class
Schema
extends
\yii\db\mysql\Schema
{
/**
* @var array mapping from physical column types (keys) to abstract column types (values)
*/
public
$typeMap
=
[
'field'
=>
self
::
TYPE_STRING
,
'string'
=>
self
::
TYPE_STRING
,
'ordinal'
=>
self
::
TYPE_STRING
,
'integer'
=>
self
::
TYPE_INTEGER
,
'int'
=>
self
::
TYPE_INTEGER
,
'uint'
=>
self
::
TYPE_INTEGER
,
'bigint'
=>
self
::
TYPE_BIGINT
,
'timestamp'
=>
self
::
TYPE_TIMESTAMP
,
'bool'
=>
self
::
TYPE_BOOLEAN
,
'float'
=>
self
::
TYPE_FLOAT
,
'mva'
=>
self
::
TYPE_STRING
,
];
/**
* Creates a query builder for the database.
* This method may be overridden by child classes to create a DBMS-specific query builder.
* @return QueryBuilder query builder instance
...
...
tests/unit/extensions/sphinx/CommandTest.php
View file @
6e3dfb8f
...
...
@@ -3,6 +3,7 @@
namespace
yiiunit\extensions\sphinx
;
use
yii\db\DataReader
;
use
yii\db\Expression
;
/**
* @group sphinx
...
...
@@ -128,12 +129,34 @@ class CommandTest extends SphinxTestCase
$command
=
$db
->
createCommand
()
->
update
(
'yii2_test_rt_index'
,
[
'title'
=>
'Test title'
,
'content'
=>
'Test content'
,
'type_id'
=>
$newTypeId
,
],
'id = 1'
);
$this
->
assertEquals
(
1
,
$command
->
execute
(),
'Unable to execute update!'
);
list
(
$row
)
=
$db
->
createCommand
(
'SELECT * FROM yii2_test_rt_index'
)
->
queryAll
();
$this
->
assertEquals
(
$newTypeId
,
$row
[
'type_id'
],
'Unable to update attribute value!'
);
}
/**
* @depends testInsert
*/
public
function
testDelete
()
{
$db
=
$this
->
getConnection
();
$db
->
createCommand
()
->
insert
(
'yii2_test_rt_index'
,
[
'title'
=>
'Test title'
,
'content'
=>
'Test content'
,
'type_id'
=>
2
,
'id'
=>
1
,
])
->
execute
();
$command
=
$db
->
createCommand
()
->
delete
(
'yii2_test_rt_index'
,
'id = 1'
);
$this
->
assertEquals
(
1
,
$command
->
execute
(),
'Unable to execute delete!'
);
$rows
=
$db
->
createCommand
(
'SELECT * FROM yii2_test_rt_index'
)
->
queryAll
();
$this
->
assertEquals
(
0
,
count
(
$rows
),
'Unable to delete record!'
);
}
}
\ No newline at end of file
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