mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9800 from creative-commoners/pulls/4.7/arraylist-value-set
FIX Bug when specifying 0 in ArrayList::offsetSet
This commit is contained in:
commit
a8d121d23f
@ -844,7 +844,7 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
|
|||||||
*/
|
*/
|
||||||
public function offsetSet($offset, $value)
|
public function offsetSet($offset, $value)
|
||||||
{
|
{
|
||||||
if ($offset == null) {
|
if ($offset === null) {
|
||||||
$this->items[] = $value;
|
$this->items[] = $value;
|
||||||
} else {
|
} else {
|
||||||
$this->items[$offset] = $value;
|
$this->items[$offset] = $value;
|
||||||
|
@ -1251,4 +1251,14 @@ class ArrayListTest extends SapphireTest
|
|||||||
|
|
||||||
$this->assertNotEquals(range(1, $upperLimit), $list->toArray());
|
$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