id = '1'; $bean->test_id = '3'; $bean->field_defs = array( 'test' => array( 'type' => 'link', 'relationship' => 'test', 'link_file' => 'data/SugarBean.php', 'link_class' => 'Link44930' ) ); $bean->relationship_fields = array( 'test_id' => 'test' ); $bean->save_relationship_changes(true); $this->assertEquals($bean->test_id, $bean->test->lastCall, 'Last relation should point to test_id instead of relate_id'); } } /** * Emulation of link2 class */ class Link44930 { public $lastCall = ''; function __call($function, $arguments) { if ($function == 'add') { $this->lastCall = reset($arguments); } } }