Inheritance: extends lithium\data\Model
コード例 #1
0
ファイル: MongoDbTest.php プロジェクト: fedeisas/lithium
 public function tearDown()
 {
     Connections::remove('mockconn');
     MockPost::reset();
     MockComment::reset();
     MockMongoPost::reset();
 }
コード例 #2
0
ファイル: ModelTest.php プロジェクト: rapzo/lithium
 public function testRelationFromFieldName()
 {
     MockPost::bind('hasMany', 'MockTag');
     $this->assertEqual('MockComment', MockPost::relations('mock_comments')->name());
     $this->assertEqual('MockTag', MockPost::relations('mock_tags')->name());
     $this->assertEqual('MockPost', MockComment::relations('mock_post')->name());
     $this->assertNull(MockPost::relations('undefined'));
 }
コード例 #3
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);
 }
コード例 #4
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);
 }
コード例 #5
0
 public function tearDown()
 {
     unset($this->query);
     MockPost::reset();
     MockComment::reset();
 }