mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Bug when specifying 0 in ArrayList::offsetSet
This commit is contained in:
parent
43dbcfd001
commit
5be045f9a2
@ -844,7 +844,7 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if ($offset == null) {
|
||||
if ($offset === null) {
|
||||
$this->items[] = $value;
|
||||
} else {
|
||||
$this->items[$offset] = $value;
|
||||
|
@ -1251,4 +1251,14 @@ class ArrayListTest extends SapphireTest
|
||||
|
||||
$this->assertNotEquals(range(1, $upperLimit), $list->toArray());
|
||||
}
|
||||
|
||||
public function testOffsetSet()
|
||||
{
|
||||
$list = new ArrayList(['first value', 'second value']);
|
||||
$this->assertSame(2, $list->count());
|
||||
$list->offsetSet(0, 'new value');
|
||||
$this->assertSame(2, $list->count());
|
||||
$this->assertSame('new value', $list->offsetGet(0));
|
||||
$this->assertSame('second value', $list->offsetGet(1));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user