[limb-svn] r5517 - in 3.x/limb/tree: src/tree tests/cases/tree
svn at limb-project.com
svn at limb-project.com
Tue Apr 3 14:20:45 MSD 2007
Author: serega
Date: 2007-04-03 14:20:44 +0400 (Tue, 03 Apr 2007)
New Revision: 5517
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5517
Modified:
3.x/limb/tree/src/tree/lmbTreeRsProcessor.class.php
3.x/limb/tree/tests/cases/tree/lmbTreeRsProcessorTest.class.php
Log:
-- lmbTreeRsProcessor keep processed iterator record intact and returns lmbPagedArrayDataset instead of lmbArrayDataset
Modified: 3.x/limb/tree/src/tree/lmbTreeRsProcessor.class.php
===================================================================
--- 3.x/limb/tree/src/tree/lmbTreeRsProcessor.class.php 2007-04-03 08:42:09 UTC (rev 5516)
+++ 3.x/limb/tree/src/tree/lmbTreeRsProcessor.class.php 2007-04-03 10:20:44 UTC (rev 5517)
@@ -1,14 +1,16 @@
<?php
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright Copyright © 2004-2007 BIT
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- * @version $Id$
- * @package tree
+/**
+ * Limb Web Application Framework
+ *
+ * @link http://limb-project.com
+ *
+ * @copyright Copyright © 2004-2007 BIT
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ * @version $Id$
+ * @package tree
*/
+lmb_require('limb/datasource/src/lmbPagedArrayDataset.class.php');
+
class lmbTreeRsProcessor
{
function sort($rs, $sort_params, $id_hash = 'id', $parent_hash = 'parent_id')
@@ -22,17 +24,14 @@
self :: _doSort($tree_array, $sorted_tree_array, $sort_params, $parent_id, $id_hash, $parent_hash);
- return new lmbArrayDataset($sorted_tree_array);
+ return new lmbPagedArrayDataset($sorted_tree_array);
}
function _convertRs2Array($rs)
{
$tree_array = array();
- for($rs->rewind();$rs->valid();$rs->next())
- {
- $record = $rs->current();
- $tree_array[] = $record->export();
- }
+ foreach($rs as $record)
+ $tree_array[] = $record;
return $tree_array;
}
Modified: 3.x/limb/tree/tests/cases/tree/lmbTreeRsProcessorTest.class.php
===================================================================
--- 3.x/limb/tree/tests/cases/tree/lmbTreeRsProcessorTest.class.php 2007-04-03 08:42:09 UTC (rev 5516)
+++ 3.x/limb/tree/tests/cases/tree/lmbTreeRsProcessorTest.class.php 2007-04-03 10:20:44 UTC (rev 5517)
@@ -1,15 +1,16 @@
<?php
-/**
- * Limb Web Application Framework
- *
- * @link http://limb-project.com
- *
- * @copyright Copyright © 2004-2007 BIT
- * @license LGPL http://www.gnu.org/copyleft/lesser.html
- * @version $Id$
- * @package tree
+/**
+ * Limb Web Application Framework
+ *
+ * @link http://limb-project.com
+ *
+ * @copyright Copyright © 2004-2007 BIT
+ * @license LGPL http://www.gnu.org/copyleft/lesser.html
+ * @version $Id$
+ * @package tree
*/
lmb_require('limb/tree/src/tree/lmbTreeRsProcessor.class.php');
+lmb_require('limb/datasource/src/lmbPagedArrayDataset.class.php');
class lmbTreeRsProcessorTest extends UnitTestCase
{
@@ -37,13 +38,14 @@
array('id' => 7, 'parent_id' => 6, 'sort1' => 'tom', 'sort2' => 0),
);
- $sorted = lmbTreeRsProcessor :: sort(new lmbArrayDataset($raw_tree_array),
+ $sorted = lmbTreeRsProcessor :: sort(new lmbPagedArrayDataset($raw_tree_array),
array('sort1' => 'DESC', 'sort2' => 'ASC'));
- $this->assertEqual(
- $sorted,
- new lmbArrayDataset($expected_tree_array)
- );
+ $to_check = array();
+ foreach($sorted as $record)
+ $to_check[] = $record->export();
+
+ $this->assertEqual($to_check, $expected_tree_array);
}
}
More information about the limb-svn
mailing list