get() 공개 정적인 메소드

public static get ( $type, $export, array $options = [] )
$options array
예제 #1
0
	/**
	 * Tests that a nested key on a previously saved document gets updated properly.
	 */
	public function testExistingNestedKeyOverwrite() {
		$doc = new Document(array('model' => $this->_model));
		$doc->{'this.that'} = 'value1';
		$this->assertEqual(array('this' => array('that' => 'value1')), $doc->data());

		$result = Exporter::get('create', $doc->export());
		$this->assertEqual(array('create' => array('this' => array('that' => 'value1'))), $result);

		$doc->sync();
		$doc->{'this.that'} = 'value2';
		$this->assertEqual(array('this' => array('that' => 'value2')), $doc->data());

		$result = Exporter::get('update', $doc->export());
		$this->assertEqual(array('update' => array('this.that' => 'value2')), $result);
	}
 public function testIndexesOnExportingDocument()
 {
     $schema = new Schema(array('fields' => array('_id' => array('type' => 'id'), 'accounts' => array('type' => 'object', 'array' => true), 'accounts._id' => array('type' => 'id'), 'accounts.name' => array('type' => 'string'))));
     $data = array('_id' => '4c8f86167675abfabd970300', 'accounts' => array(array('_id' => "4fb6e2dd3e91581fe6e75736", 'name' => 'Foo1'), array('_id' => "4fb6e2df3e91581fe6e75737", 'name' => 'Bar1')));
     $model = $this->_model;
     $document = new Document(compact('model', 'schema', 'data'));
     $this->assertTrue($document->accounts instanceof DocumentSet);
     $this->assertTrue($document->accounts instanceof DocumentSet);
     $export = $document->export();
     $result = Exporter::get('create', $document->export());
     $this->assertTrue(isset($result['create']['accounts'][0]));
     $this->assertTrue(isset($result['create']['accounts'][1]));
     $export['data'] = array();
     $result = Exporter::get('update', $export);
     $this->assertTrue(isset($result['update']['accounts'][0]));
     $this->assertTrue(isset($result['update']['accounts'][1]));
 }
예제 #3
0
 public function testWithArraySchema()
 {
     $model = $this->_model;
     $model::schema(array('_id' => array('type' => 'id'), 'list' => array('array' => true), 'list.foo' => array('type' => 'string'), 'list.bar' => array('type' => 'string')));
     $doc = new Document(compact('model'));
     $doc->list[] = array('foo' => '!!', 'bar' => '??');
     $data = array('list' => array(array('foo' => '!!', 'bar' => '??')));
     $this->assertEqual($data, $doc->data());
     $result = Exporter::get('create', $doc->export());
     $this->assertEqual($data, $result['create']);
     $result = Exporter::get('update', $doc->export());
     $this->assertEqual($data, $result['update']);
     $doc = new Document(compact('model'));
     $doc->list = array();
     $doc->list[] = array('foo' => '!!', 'bar' => '??');
     $data = array('list' => array(array('foo' => '!!', 'bar' => '??')));
     $this->assertEqual($data, $doc->data());
     $result = Exporter::get('create', $doc->export());
     $this->assertEqual($result['create'], $data);
     $result = Exporter::get('update', $doc->export());
     $this->assertEqual($result['update'], $data);
 }