Author: FabianLange
Date: 2010-02-06 00:43:21 +0100 (Sat, 06 Feb 2010)
New Revision: 27613

Added:
   branches/1.3/test/unit/addon/
   branches/1.3/test/unit/addon/sfPagerTest.php
   branches/1.4/test/unit/addon/
   branches/1.4/test/unit/addon/sfPagerTest.php
Log:
[1.3, 1.4] added basic test for sfPager->rewind() and fixed bug not leading to 
->reset() not working correctly. (fixes #8021)

Added: branches/1.3/test/unit/addon/sfPagerTest.php
===================================================================
--- branches/1.3/test/unit/addon/sfPagerTest.php                                
(rev 0)
+++ branches/1.3/test/unit/addon/sfPagerTest.php        2010-02-05 23:43:21 UTC 
(rev 27613)
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
+
+$t = new lime_test(2);
+class myPager extends sfPager
+{
+  function init() {}
+  function retrieveObject($offset) {}
+  function getResults() 
+  {
+    $this->setNbResults(2);
+    return array("foo", "bar");
+  }
+}
+
+$pager = new myPager("fooClass");
+
+// #8021
+// ->rewind()
+$t->diag('->rewind()');
+$countRuns = 0;
+foreach ($pager as $item)
+{
+  $countRuns++;
+}
+$t->is($countRuns, $pager->count(), 'iterating first time will invoke on all 
items');
+
+$countRuns = 0;
+$pager->rewind();
+foreach ($pager as $item)
+{
+  $countRuns++;
+}
+$t->is($countRuns, $pager->count(), '->rewind will allow reiterating');
\ No newline at end of file

Added: branches/1.4/test/unit/addon/sfPagerTest.php
===================================================================
--- branches/1.4/test/unit/addon/sfPagerTest.php                                
(rev 0)
+++ branches/1.4/test/unit/addon/sfPagerTest.php        2010-02-05 23:43:21 UTC 
(rev 27613)
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ * This file is part of the symfony package.
+ * (c) 2004-2006 Fabien Potencier <[email protected]>
+ * 
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
+
+$t = new lime_test(2);
+class myPager extends sfPager
+{
+  function init() {}
+  function retrieveObject($offset) {}
+  function getResults() 
+  {
+    $this->setNbResults(2);
+    return array("foo", "bar");
+  }
+}
+
+$pager = new myPager("fooClass");
+
+// #8021
+// ->rewind()
+$t->diag('->rewind()');
+$countRuns = 0;
+foreach ($pager as $item)
+{
+  $countRuns++;
+}
+$t->is($countRuns, $pager->count(), 'iterating first time will invoke on all 
items');
+
+$countRuns = 0;
+$pager->rewind();
+foreach ($pager as $item)
+{
+  $countRuns++;
+}
+$t->is($countRuns, $pager->count(), '->rewind will allow reiterating');
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to