public function testNestedObjectExistence()
{
$model = $this->_model;
$data = array('foo' => array('bar' => 'bar', 'baz' => 'dib'), 'deeply' => array('nested' => array('object' => array('should' => 'exist'))));
$doc = new Document(compact('model', 'data') + array('exists' => false));
$this->assertFalse($doc->exists());
$this->assertFalse($doc->foo->exists());
$doc = new Document(compact('model', 'data') + array('exists' => true));
$this->assertTrue($doc->exists());
$this->assertTrue($doc->foo->exists());
$this->assertTrue($doc->deeply->nested->object->exists());
$doc = new Document(compact('model', 'data') + array('exists' => true));
$subDoc = new Document(array('data' => array('bar' => 'stuff')));
$this->assertTrue($doc->foo->exists());
$this->assertFalse($subDoc->exists());
$doc->foo = $subDoc;
$this->assertTrue($doc->exists());
$this->assertFalse($doc->foo->exists());
$doc->sync();
$this->assertTrue($doc->foo->exists());
}