Esempio n. 1
0
 public function testSimpleFind()
 {
     $result = MockPost::find('all');
     $this->assertTrue($result instanceof \lithium\data\model\RecordSet);
 }
Esempio n. 2
0
 /**
  * Tests that objects can be passed as keys to `Model::find()` and be properly translated to
  * query conditions.
  */
 public function testFindByObjectKey()
 {
     $key = (object) array('foo' => 'bar');
     $result = MockPost::find($key);
     $this->assertEqual(array('id' => $key), $result['query']->conditions());
 }
Esempio n. 3
0
 /**
  * Tests that varying `count` syntaxes all produce the same query operation (i.e.
  * `Model::count(...)`, `Model::find('count', ...)` etc).
  *
  * @return void
  */
 public function testCountSyntax()
 {
     $base = MockPost::count(array('email' => '*****@*****.**'));
     $query = $base['query'];
     $this->assertEqual('read', $query->type());
     $this->assertEqual('count', $query->calculate());
     $this->assertEqual(array('email' => '*****@*****.**'), $query->conditions());
     $result = MockPost::find('count', array('conditions' => array('email' => '*****@*****.**')));
     $this->assertEqual($query, $result['query']);
     $result = MockPost::count(array('conditions' => array('email' => '*****@*****.**')));
     $this->assertEqual($query, $result['query']);
 }