Inheritance: extends lithium\data\Model
Esempio n. 1
0
 public function testKeyGeneration()
 {
     $this->assertEqual('comment_id', MockComment::key());
     $this->assertEqual(array('post_id', 'tag_id'), MockTagging::key());
     $result = MockComment::key(array('comment_id' => 5, 'body' => 'This is a comment'));
     $this->assertEqual(array('comment_id' => 5), $result);
     $result = MockTagging::key(array('post_id' => 2, 'tag_id' => 5, 'created' => '2009-06-16 10:00:00'));
     $this->assertEqual('id', MockPost::key());
     $this->assertEqual(array('id' => 5), MockPost::key(5));
     $this->assertEqual(array('post_id' => 2, 'tag_id' => 5), $result);
     $key = new stdClass();
     $key->foo = 'bar';
     $this->assertEqual(array('id' => $key), MockPost::key($key));
     $this->assertNull(MockPost::key(array()));
     $model = $this->_model;
     $this->assertNull($model::key(array('client_id' => 3)));
     $result = $model::key(array('invoice_id' => 5, 'payment' => '100'));
     $this->assertNull($result);
     $expected = array('client_id' => 3, 'invoice_id' => 5);
     $result = $model::key(array('client_id' => 3, 'invoice_id' => 5, 'payment' => '100'));
     $this->assertEqual($expected, $result);
 }
Esempio n. 2
0
 public function testKeyGeneration()
 {
     $this->assertEqual('comment_id', MockComment::key());
     $this->assertEqual(array('post_id', 'tag_id'), MockTagging::key());
     $result = MockComment::key(array('comment_id' => 5, 'body' => 'This is a comment'));
     $this->assertEqual(5, $result);
     $result = MockTagging::key(array('post_id' => 2, 'tag_id' => 5, 'created' => '2009-06-16 10:00:00'));
     $this->assertEqual(array('post_id' => 2, 'tag_id' => 5), $result);
 }