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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
0ba6b4bd
Commit
0ba6b4bd
authored
Jan 30, 2012
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
376dd0d4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
36 deletions
+52
-36
ActiveQuery.php
framework/db/ar/ActiveQuery.php
+36
-23
ActiveRecordTest.php
tests/unit/framework/db/ar/ActiveRecordTest.php
+16
-13
No files found.
framework/db/ar/ActiveQuery.php
View file @
0ba6b4bd
This diff is collapsed.
Click to expand it.
tests/unit/framework/db/ar/ActiveRecordTest.php
View file @
0ba6b4bd
...
...
@@ -32,13 +32,14 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
$this
->
assertTrue
(
$customers
[
1
]
instanceof
Customer
);
$this
->
assertTrue
(
$customers
[
2
]
instanceof
Customer
);
$this
->
assertEquals
(
3
,
$result
->
count
);
$this
->
assertEquals
(
3
,
count
(
$result
));
// check count first
$result
=
Customer
::
find
();
$this
->
assertEquals
(
3
,
$result
->
count
);
$customer
=
$result
->
one
();
$this
->
assertTrue
(
$customer
instanceof
Customer
);
$this
->
assertEquals
(
1
,
$result
->
count
);
$this
->
assertEquals
(
3
,
$result
->
count
);
// iterator
$result
=
Customer
::
find
();
...
...
@@ -66,11 +67,14 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
$this
->
assertEquals
(
2
,
$customer
->
id
);
// find by Query
$query
=
new
Active
Query
;
$query
=
new
Query
;
$query
->
where
(
'id=:id'
,
array
(
':id'
=>
2
));
$customer
=
Customer
::
find
(
$query
)
->
one
();
$this
->
assertTrue
(
$customer
instanceof
Customer
);
$this
->
assertEquals
(
'user2'
,
$customer
->
name
);
// find count
$this
->
assertEquals
(
3
,
Customer
::
find
()
->
count
(
true
));
}
public
function
testFindBySql
()
...
...
@@ -92,10 +96,9 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
// count
$finder
=
Customer
::
findBySql
(
'SELECT * FROM tbl_customer ORDER BY id DESC'
);
$finder
->
one
();
$this
->
assertEquals
(
1
,
$finder
->
count
);
$this
->
assertEquals
(
3
,
$finder
->
count
);
$finder
=
Customer
::
findBySql
(
'SELECT * FROM tbl_customer ORDER BY id DESC'
);
// todo
// $this->assertEquals(3, $finder->count);
$this
->
assertEquals
(
3
,
$finder
->
count
);
}
public
function
testQueryMethods
()
...
...
@@ -113,12 +116,12 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
$this
->
assertEquals
(
3
,
$customer
->
id
);
$this
->
assertEquals
(
null
,
$customer
->
name
);
}
/*
public function testGetSql()
{
// sql for all
$sql = Customer::find()->sql;
$this
->
assertEquals
(
'SELECT * FROM
tbl_customer
'
,
$sql
);
$this->assertEquals('SELECT * FROM
`tbl_customer`
', $sql);
// sql for one row
$sql = Customer::find()->oneSql;
...
...
@@ -137,12 +140,10 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
public function testMisc()
{
/*
* Customer::exists()
* Customer::updateAll()
* Customer::updateCounters()
* Customer::deleteAll()
*/
// Customer::exists()
// Customer::updateAll()
// Customer::updateCounters()
// Customer::deleteAll()
}
public function testInsert()
...
...
@@ -170,4 +171,5 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
{
}
*/
}
\ 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