示例#1
0
 public function testClassInitialization()
 {
     $expected = MockPost::instances();
     MockPost::config();
     $this->assertEqual($expected, MockPost::instances());
     Model::config();
     $this->assertEqual($expected, MockPost::instances());
     $this->assertEqual('mock_posts', MockPost::meta('source'));
     MockPost::config(array('meta' => array('source' => 'post')));
     $this->assertEqual('post', MockPost::meta('source'));
     MockPost::config(array('meta' => array('source' => false)));
     $this->assertFalse(MockPost::meta('source'));
     MockPost::config(array('meta' => array('source' => null)));
     $this->assertIdentical('mock_posts', MockPost::meta('source'));
     MockPost::config();
     $this->assertEqual('mock_posts', MockPost::meta('source'));
     $this->assertEqual('mocksource', MockPost::meta('connection'));
     MockPost::config(array('meta' => array('source' => 'toreset')));
     MockPost::reset();
     MockPost::config(array('meta' => array('connection' => 'mocksource')));
     $this->assertEqual('mock_posts', MockPost::meta('source'));
     $this->assertEqual('mocksource', MockPost::meta('connection'));
     MockPost::config(array('query' => array('with' => array('MockComment'), 'limit' => 10)));
     $expected = array('with' => array('MockComment'), 'limit' => 10, 'conditions' => null, 'fields' => null, 'order' => null, 'page' => null);
     $this->assertEqual($expected, MockPost::query());
     $finder = array('fields' => array('title', 'body'));
     MockPost::finder('myFinder', $finder);
     $result = MockPost::find('myFinder');
     $expected = $finder + array('order' => null, 'limit' => 10, 'conditions' => null, 'page' => null, 'with' => array('MockComment'), 'type' => 'read', 'model' => 'lithium\\tests\\mocks\\data\\MockPost');
     $this->assertEqual($expected, $result['options']);
     $finder = array('fields' => array('id', 'title'));
     MockPost::reset();
     MockPost::config(array('meta' => array('connection' => 'mocksource')));
     $result = MockPost::finder('myFinder');
     $this->assertNull($result);
 }