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
53a1f960
Commit
53a1f960
authored
Jul 09, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit test for ActiveDataProvider.
parent
3996c799
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
2 deletions
+67
-2
ActiveDataProvider.php
framework/yii/data/ActiveDataProvider.php
+17
-1
ActiveDataProviderTest.php
tests/unit/framework/data/ActiveDataProviderTest.php
+50
-0
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+0
-1
No files found.
framework/yii/data/ActiveDataProvider.php
View file @
53a1f960
...
...
@@ -18,7 +18,7 @@ use yii\db\Connection;
*
* ActiveDataProvider provides data by performing DB queries using [[query]].
*
* The following is an example of using ActiveDataProvider:
* The following is an example of using ActiveDataProvider
to provide ActiveRecord instances
:
*
* ~~~
* $provider = new ActiveDataProvider(array(
...
...
@@ -32,6 +32,22 @@ use yii\db\Connection;
* $posts = $provider->getItems();
* ~~~
*
* And the following example shows how to use ActiveDataProvider without ActiveRecord:
*
* ~~~
* $provider = new ActiveDataProvider(array(
* 'query' => new Query(array(
* 'from' => 'tbl_post',
* )),
* 'pagination' => array(
* 'pageSize' => 20,
* ),
* ));
*
* // get the posts in the current page
* $posts = $provider->getItems();
* ~~~
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
...
...
tests/unit/framework/data/ActiveDataProviderTest.php
0 → 100644
View file @
53a1f960
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yiiunit\framework\data
;
use
yii\data\ActiveDataProvider
;
use
yiiunit\data\ar\ActiveRecord
;
use
yiiunit\framework\db\DatabaseTestCase
;
use
yiiunit\data\ar\Order
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ActiveDataProviderTest
extends
DatabaseTestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
ActiveRecord
::
$db
=
$this
->
getConnection
();
}
public
function
testActiveQuery
()
{
$provider
=
new
ActiveDataProvider
(
array
(
'query'
=>
Order
::
find
(),
));
$orders
=
$provider
->
getItems
();
$this
->
assertEquals
(
3
,
count
(
$orders
));
$provider
=
new
ActiveDataProvider
(
array
(
'query'
=>
Order
::
find
(),
'pagination'
=>
array
(
'pageSize'
=>
2
,
)
));
$orders
=
$provider
->
getItems
();
$this
->
assertEquals
(
2
,
count
(
$orders
));
}
public
function
testQuery
()
{
}
}
tests/unit/framework/db/ActiveRecordTest.php
View file @
53a1f960
...
...
@@ -14,7 +14,6 @@ class ActiveRecordTest extends DatabaseTestCase
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
mockApplication
();
ActiveRecord
::
$db
=
$this
->
getConnection
();
}
...
...
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