diff --git a/model/ArrayList.php b/model/ArrayList.php index 19d8a909a..c8c76d821 100644 --- a/model/ArrayList.php +++ b/model/ArrayList.php @@ -52,7 +52,7 @@ class ArrayList extends ViewableData implements SS_List { } public function getRange($offset, $length) { - return array_slice($this->array, $offset, $length); + return new ArrayList(array_slice($this->array, $offset, $length)); } public function add($item) { diff --git a/tests/model/ArrayListTest.php b/tests/model/ArrayListTest.php index bb13dc0ed..a733a2b0b 100644 --- a/tests/model/ArrayListTest.php +++ b/tests/model/ArrayListTest.php @@ -37,7 +37,7 @@ class ArrayListTest extends SapphireTest { $list = new ArrayList(array( array('Key' => 1), array('Key' => 2), array('Key' => 3) )); - $this->assertEquals($list->getRange(1, 2), array( + $this->assertEquals($list->getRange(1, 2)->toArray(), array( array('Key' => 2), array('Key' => 3) )); }