summaryrefslogtreecommitdiff
path: root/tests/unit/Collections/TPagedListTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Collections/TPagedListTest.php')
-rw-r--r--tests/unit/Collections/TPagedListTest.php53
1 files changed, 26 insertions, 27 deletions
diff --git a/tests/unit/Collections/TPagedListTest.php b/tests/unit/Collections/TPagedListTest.php
index 2d884736..a225db61 100644
--- a/tests/unit/Collections/TPagedListTest.php
+++ b/tests/unit/Collections/TPagedListTest.php
@@ -3,26 +3,26 @@
Prado::using('System.Collections.TPagedList');
class MyPagedList extends TPagedList {
-
+
private $_isPageIndexChanged = false;
private $_hasFetchedData = false;
-
+
public function pageIndexChanged($sender, $param) {
$this->_isPageIndexChanged = true;
}
-
+
public function fetchData($sender, $param) {
$this->_hasFetchedData = true;
}
-
+
public function isPageIndexChanged() {
return $this->_isPageIndexChanged;
}
-
+
public function hasFetchedData() {
return $this->_hasFetchedData;
}
-
+
}
/**
@@ -58,7 +58,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->PageSize = 5;
self::assertEquals(5, $list->PageSize);
}
-
+
public function testCanNotSetInvalidPageSize() {
$list = new TPagedList();
try {
@@ -68,14 +68,14 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
}
self::fail('An expected TInvalidDataValueException was not raised');
}
-
+
public function testCurrentPageIndex() {
$list = new TPagedList(array(1, 2, 3));
$list->PageSize = 1;
$list->CurrentPageIndex = 2;
self::assertEquals(2, $list->CurrentPageIndex);
}
-
+
public function testOnPageIndexChanged() {
$list = new TPagedList(array(1, 2, 3, 4, 5));
$list->PageSize = 1;
@@ -87,7 +87,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage));
self::assertEquals(true, $myList->isPageIndexChanged());
}
-
+
public function testOnFetchData() {
$list = new TPagedList(array(1, 2, 3, 4));
$list->CustomPaging = true;
@@ -95,18 +95,18 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->gotoPage(0);
$myList = new MyPagedList();
$list->attachEventHandler('OnFetchData', array($myList, 'fetchData'));
- self::assertEquals(false, $myList->hasFetchedData());
+ self::assertEquals(false, $myList->hasFetchedData());
$list->onFetchData(new TPagedListFetchDataEventParameter($list->CurrentPageIndex, $list->PageSize*$list->CurrentPageIndex, $list->PageSize));
self::assertEquals(true, $myList->hasFetchedData());
}
-
+
public function testGotoPage() {
$list = new TPagedList(array(1, 2, 3));
$list->PageSize = 1;
self::assertEquals(2, $list->gotoPage(2));
self::assertEquals(false, $list->gotoPage(4));
}
-
+
public function testNextPage() {
$list = new TPagedList(array(1, 2));
$list->PageSize = 1;
@@ -114,7 +114,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
self::assertEquals(1, $list->nextPage());
self::assertEquals(false, $list->nextPage());
}
-
+
public function testPreviousPage() {
$list = new TPagedList(array(1, 2));
$list->PageSize = 1;
@@ -122,7 +122,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
self::assertEquals(0, $list->previousPage());
self::assertEquals(false, $list->previousPage());
}
-
+
public function testVirtualCount() {
$list = new TPagedList(array(1, 2));
$list->VirtualCount = -10;
@@ -130,7 +130,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->VirtualCount = 5;
self::assertEquals(5, $list->VirtualCount);
}
-
+
public function testPageCount() {
$list = new TPagedList(array(1, 2, 3));
$list->PageSize = 1;
@@ -141,7 +141,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->CustomPaging = false;
self::assertEquals(3, $list->PageCount);
}
-
+
public function testIsFirstPage() {
$list = new TPagedList(array(1, 2, 3));
$list->PageSize = 1;
@@ -150,7 +150,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->gotoPage(1);
self::assertEquals(false, $list->IsFirstPage);
}
-
+
public function testIsLastPage() {
$list = new TPagedList(array(1, 2, 3));
$list->PageSize = 1;
@@ -159,7 +159,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->gotoPage(2);
self::assertEquals(true, $list->IsLastPage);
}
-
+
public function testGetCount() {
$list = new TPagedList(array(1, 2, 3));
$list->PageSize = 1;
@@ -167,7 +167,7 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->CustomPaging = true;
self::assertEquals(3, $list->Count);
}
-
+
public function testGetIterator() {
$list = new TPagedList(array(1, 2));
$list->CustomPaging = true;
@@ -181,12 +181,12 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$found++;
}
if($index === 1 && $item === 2) {
- $found++;
+ $found++;
}
}
self::assertTrue($n == 2 && $found == 2);
}
-
+
public function testItemAt() {
$list = new TPagedList(array(1, 2, 3));
$list->CustomPaging = true;
@@ -196,27 +196,27 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
$list->CurrentPageIndex = 0;
self::assertEquals(1, $list[0]);
}
-
+
public function testIndexOf() {
$list = new TPagedList(array(1, 2, 3));
$list->CustomPaging = true;
self::assertEquals(0, $list->indexOf(1));
self::assertEquals(-1, $list->indexOf(0));
}
-
+
public function testOffsetExists() {
$list = new TPagedList(array(1, 2, 3));
$list->CustomPaging = true;
self::assertEquals(true, isset($list[0]));
self::assertEquals(false, isset($list[4]));
}
-
+
public function testOffsetGet() {
$list = new TPagedList(array(1, 2, 3));
$list->CustomPaging = true;
self::assertEquals(2, $list[1]);
}
-
+
public function testToArray() {
$list = new TPagedList(array(1, 2, 3));
$list->CustomPaging = true;
@@ -225,4 +225,3 @@ class TPagedListTest extends PHPUnit_Framework_TestCase {
}
-?>