Beispiel #1
0
 public function setUp()
 {
     $this->_configs = Connections::config();
     Connections::config(array('mock-source' => array('type' => 'lithium\\tests\\mocks\\data\\MockSource')));
     MockPost::config(array('connection' => 'mock-source'));
     MockTag::config();
     MockComment::config();
 }
Beispiel #2
0
 /**
  * Tests introspecting the relationship settings for the model as a whole, various relationship
  * types, and individual relationships.
  *
  * @todo Some tests will need to change when full relationship support is built out.
  * @return void
  */
 public function testRelationshipIntrospection()
 {
     $result = array_keys(MockPost::relations());
     $expected = array('MockComment');
     $this->assertEqual($expected, $result);
     $result = MockPost::relations('hasMany');
     $this->assertEqual($expected, $result);
     $result = array_keys(MockComment::relations());
     $expected = array('MockPost');
     $this->assertEqual($expected, $result);
     $result = MockComment::relations('belongsTo');
     $this->assertEqual($expected, $result);
     $this->assertEmpty(MockComment::relations('hasMany'));
     $this->assertEmpty(MockPost::relations('belongsTo'));
     $expected = array('name' => 'MockPost', 'type' => 'belongsTo', 'key' => array('mock_post_id' => 'id'), 'from' => 'lithium\\tests\\mocks\\data\\MockComment', 'to' => 'lithium\\tests\\mocks\\data\\MockPost', 'link' => 'key', 'fields' => true, 'fieldName' => 'mock_post', 'constraints' => array(), 'strategy' => null, 'init' => true);
     $this->assertEqual($expected, MockComment::relations('MockPost')->data());
     $expected = array('name' => 'MockComment', 'type' => 'hasMany', 'from' => 'lithium\\tests\\mocks\\data\\MockPost', 'to' => 'lithium\\tests\\mocks\\data\\MockComment', 'fields' => true, 'key' => array('id' => 'mock_post_id'), 'link' => 'key', 'fieldName' => 'mock_comments', 'constraints' => array(), 'strategy' => null, 'init' => true);
     $this->assertEqual($expected, MockPost::relations('MockComment')->data());
     MockPost::config(array('meta' => array('connection' => false)));
     MockComment::config(array('meta' => array('connection' => false)));
     MockTag::config(array('meta' => array('connection' => false)));
 }