public function testAccessorMethods() { $model = $this->_model; $model::config(array('connection' => false)); $collection = new DocumentSet(compact('model')); $this->assertEqual($model, $collection->model()); $this->assertEqual(compact('model'), $collection->meta()); }
public function testAccessorMethods() { Connections::config(array('mock-source' => array('type' => 'lithium\\tests\\mocks\\data\\MockSource'))); $model = $this->_model; $model::config(array('connection' => false, 'key' => 'id')); $collection = new DocumentSet(compact('model')); $this->assertEqual($model, $collection->model()); $this->assertEqual(compact('model'), $collection->meta()); }
public function testMappingToNewDocumentSet() { $result = new MockResult(); $model = $this->_model; $doc = new DocumentSet(compact('model', 'result')); $mapped = $doc->map(function ($data) { return $data; }); $this->assertEqual($doc->data(), $mapped->data()); $this->assertEqual($model, $doc->model()); $this->assertEqual($model, $mapped->model()); }
public function testMappingToNewDocumentSet() { $result = new MockResult(array('data' => array(array('_id' => '4c8f86167675abfabdbf0300', 'title' => 'bar'), array('_id' => '5c8f86167675abfabdbf0301', 'title' => 'foo'), array('_id' => '6c8f86167675abfabdbf0302', 'title' => 'dib')))); $model = $this->_model; $doc = new DocumentSet(compact('model', 'result')); $mapped = $doc->map(function ($data) { return $data; }); $this->assertEqual($doc->data(), $mapped->data()); $this->assertEqual($model, $doc->model()); $this->assertEqual($model, $mapped->model()); }
/** * Tests `Collection::assignTo`. */ public function testAssignTo() { $parent = new stdClass(); $config = array('valid' => false, 'model' => $this->_model); $collection = new DocumentSet(); $collection->assignTo($parent, $config); $this->assertEqual($this->_model, $collection->model()); $this->assertEqual($parent, $collection->parent()); }
public function testAccessorMethods() { $collection = new DocumentSet(array('model' => 'Foo')); $this->assertEqual('Foo', $collection->model()); $this->assertEqual(array('model' => 'Foo'), $collection->meta()); }