Skip to content

Commit

Permalink
Merge pull request parse-community#207 from zeliard91/fix-setArray
Browse files Browse the repository at this point in the history
Fix serialization of unindexed arrays
  • Loading branch information
gfosco committed Jan 10, 2016
2 parents 7b83c5d + d4fd8d2 commit f5a3d5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Parse/ParseObject.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function setArray($key, $value)
'Must use set() for non-array values.'
);
}
$this->_performOperation($key, new SetOperation($value));
$this->_performOperation($key, new SetOperation(array_values($value)));
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/Parse/ParseObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,16 @@ public function testAddWithAnObject()
);
}

public function testSetArray()
{
$arr = [0 => 'foo', 2 => 'bar'];
$obj = ParseObject::create('TestObject');
$obj->setArray('arr', $arr);
$obj->save();

$this->assertEquals($obj->get('arr'), array_values($arr));
}

public function testAddUnique()
{
$obj = ParseObject::create('TestObject');
Expand Down

0 comments on commit f5a3d5a

Please sign in to comment.