Skip to content

Instantly share code, notes, and snippets.

@mackstar
Created October 17, 2011 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mackstar/1291870 to your computer and use it in GitHub Desktop.
Save mackstar/1291870 to your computer and use it in GitHub Desktop.
public function testUpdateWithSubObjects() {
$model = $this->_model;
$exists = true;
$model::config(array('key' => '_id'));
$model::schema(array(
'array' => array('type' => 'string', 'array' => true),
'dictionary' => array('type' => 'string', 'array' => true),
'forceArray' => array('type' => 'string', 'array' => true)
));
$doc = new Document(compact('model', 'exists') + array('data' => array(
'dictionary' => array(),
)));
$doc->dictionary[] = 'A word';
$doc->forceArray = 'Word';
$doc->array = array('one');
$result = Exporter::get('update', $doc->export());
var_dump($result);
$expected = array(
'array' => array('one'),
'dictionary.0' => 'A word',
'forceArray' => array('Word'),
);
$this->assertEqual($expected, $result['update']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment