From 6a1a3bf182cf70b679e43e3721c45b8391684293 Mon Sep 17 00:00:00 2001 From: Garion Herman Date: Tue, 3 Nov 2015 23:56:30 +1300 Subject: [PATCH] Corrected TotalItems() method to use Count(). Added test coverage. (fixes #4646) --- model/ListDecorator.php | 2 +- tests/model/GroupedListTest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/model/ListDecorator.php b/model/ListDecorator.php index 83bf7ad35..6ba6edb90 100644 --- a/model/ListDecorator.php +++ b/model/ListDecorator.php @@ -81,7 +81,7 @@ abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sort } public function TotalItems() { - return $this->list->TotalItems(); + return $this->list->Count(); } public function Count() { diff --git a/tests/model/GroupedListTest.php b/tests/model/GroupedListTest.php index e5c426692..4d5c5cd41 100644 --- a/tests/model/GroupedListTest.php +++ b/tests/model/GroupedListTest.php @@ -123,4 +123,31 @@ class GroupedListTest extends SapphireTest { } } + public function testTotalItems() { + $list = GroupedList::create( + ArrayList::create( + array( + ArrayData::create(array( + 'Name' => 'AAA', + 'Number' => '111', + )), + ArrayData::create(array( + 'Name' => 'BBB', + 'Number' => '111', + )), + ArrayData::create(array( + 'Name' => 'AAA', + 'Number' => '222', + )), + ArrayData::create(array( + 'Name' => 'BBB', + 'Number' => '111', + )) + ) + ) + ); + + $this->assertEquals(4, $list->TotalItems()); + } + }