public function testUpdateWithNewArray()
 {
     $new = Companies::create(array('name' => 'Acme, Inc.', 'active' => true));
     $expected = array('name' => 'Acme, Inc.', 'active' => true);
     $result = $new->data();
     $this->assertEqual($expected, $result);
     $new->foo = array('bar');
     $expected = array('name' => 'Acme, Inc.', 'active' => true, 'foo' => array('bar'));
     $result = $new->data();
     $this->assertEqual($expected, $result);
     $this->assertTrue($new->save());
     $updated = Companies::find((string) $new->_id);
     $expected = 'bar';
     $result = $updated->foo[0];
     $this->assertEqual($expected, $result);
     $updated->foo[1] = 'baz';
     $this->assertTrue($updated->save());
     $updated = Companies::find((string) $updated->_id);
     $expected = 'baz';
     $result = $updated->foo[1];
     $this->assertEqual($expected, $result);
 }
 /**
  * Tests that a record can be created, saved, and subsequently re-read using a key
  * auto-generated by the data source. Uses short-hand `find()` syntax which does not support
  * compound keys.
  *
  * @return void
  */
 public function testGetRecordByGeneratedId()
 {
     $key = Companies::meta('key');
     $companies = Companies::create(array('name' => 'Test Companies'));
     $this->assertTrue($companies->save());
     $id = (string) $companies->{$key};
     $companiesCopy = Companies::find($id)->data();
     $data = $companies->data();
     foreach ($data as $key => $value) {
         $this->assertTrue(isset($companiesCopy[$key]));
         $this->assertEqual($data[$key], $companiesCopy[$key]);
     }
 }