zoopcommerce/shard — pull request #26 by crimsonronin (2013-12-06 02:49:31+00:00)
Title: Hotfix/Unserializer with passed document

When updating or patching a document using the unserializer, and also passing in the original document, collections would not persist correctly. eg.

```
{
"_id" : "6088b3b8158734499517cbca32f09743",
"groups" : [{
"name" : "groupA"
}, {
"name" : "groupB"
}]
}
```

Then calling:
```php
...
$updated = $this->unserializer->fromArray(
[
'id' => $id,
'groups' => []
],
'Zoop\Shard\Test\Serializer\TestAsset\Document\User',
$user
);
...
```

Would still appear like the following **in the DB**:
```
{
"_id" : "6088b3b8158734499517cbca32f09743",
"groups" : [{
"name" : "groupA"
}, {
"name" : "groupB"
}]
}
```

However, it would appear correctly in `$updated`, and therefore giving a false positive in the tests.

I have updated the `UnserializeModeTest` to ensure all tests have a document explicitly passed in to ensure this problem is avoided. **Should we also have tests that don't pass `$user` in**?

Also, I'm not sure if my treatment was ok for this: https://github.com/crimsonronin/shard/blob/Hotfix/UnserializerWithPassedDocument/lib/Zoop/Shard/Serializer/Unserializer.php#L288