Пример #1
0
 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());
 }
Пример #2
0
 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());
 }
Пример #3
0
 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());
 }
Пример #4
0
 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());
 }
Пример #5
0
 /**
  * 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());
 }
Пример #6
0
 public function testAccessorMethods()
 {
     $collection = new DocumentSet(array('model' => 'Foo'));
     $this->assertEqual('Foo', $collection->model());
     $this->assertEqual(array('model' => 'Foo'), $collection->meta());
 }