Пример #1
0
 public function testGetRelatedListFunctionWithLink2Class()
 {
     $focusModule = 'Accounts';
     $linkedModules = array('Bugs', 'Contacts');
     $focus = BeanFactory::newBean($focusModule);
     $focus->name = "bug49505";
     $focus->save();
     $this->_createdBeans[] = $focus;
     foreach ($linkedModules as $v) {
         $linkedBean = BeanFactory::newBean($v);
         $linkedBean->name = "bug49505";
         $linkedBean->save();
         $this->_createdBeans[] = $linkedBean;
         $link = new Link2(strtolower($v), $focus);
         $link->add(array($linkedBean));
         // get relation from 'Link2' class
         $link2List = $focus->get_related_list($linkedBean, strtolower($v));
         // get relation for 'get_related_list' function from Link class
         $focus->field_defs[strtolower($v)]['link_class'] = 'Link';
         $focus->field_defs[strtolower($v)]['link_file'] = 'data/Link.php';
         $linkList = $focus->get_related_list($linkedBean, strtolower($v));
         unset($focus->field_defs[strtolower($v)]['link_class']);
         unset($focus->field_defs[strtolower($v)]['link_file']);
         $this->assertEquals($linkedBean->id, $linkList['list'][0]->id);
         $this->assertEquals($linkedBean->id, $link2List['list'][0]->id);
     }
 }