3 /*********************************************************************************
4 * By installing or using this file, you are confirming on behalf of the entity
5 * subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
6 * the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
7 * http://www.sugarcrm.com/master-subscription-agreement
9 * If Company is not bound by the MSA, then by installing or using this file
10 * you are agreeing unconditionally that Company will be bound by the MSA and
11 * certifying that you have authority to bind Company accordingly.
13 * Copyright (C) 2004-2013 SugarCRM Inc. All rights reserved.
14 ********************************************************************************/
16 require_once('tests/service/SOAPTestCase.php');
20 * set_relationships will not delete relationships via API
22 * @author mgusev@sugarcrm.com
25 class Bug38858Test extends SOAPTestCase
30 protected $account = null;
35 protected $contact = null;
37 public function setUp()
39 SugarTestHelper::setUp('beanFiles');
40 SugarTestHelper::setUp('beanList');
41 SugarTestHelper::setUp('current_user');
43 $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v4_1/soap.php';
44 parent::_setupTestUser();
47 $this->account = SugarTestAccountUtilities::createAccount();
48 $this->contact = SugarTestContactUtilities::createContact();
50 $this->account->load_relationship('contacts');
51 $this->account->contacts->add($this->contact->id);
54 public function tearDown()
56 SugarTestAccountUtilities::removeAllCreatedAccounts();
57 SugarTestContactUtilities::removeAllCreatedContacts();
60 parent::_tearDownTestUser();
62 SugarTestHelper::tearDown();
66 * Test checks that relationship between account & contact can be removed by soap
71 public function testDeletionBySetRelationships()
75 $result = $this->_soapClient->call('get_relationships', array(
76 'session' => $this->_sessionId,
77 'module_name' => 'Accounts',
78 'module_id' => $this->account->id,
79 'link_field_name' => 'contacts',
80 'related_module_query' => "",
81 'link_module_fields' => array('id'),
84 $this->assertEquals(1, count($result['entry_list']), 'Response is incorrect');
86 $contact = reset($result['entry_list']);
87 $this->assertEquals($this->contact->id, $contact['id'], 'Contact is incorrect');
89 $result = $this->_soapClient->call('set_relationship', array(
90 'session' => $this->_sessionId,
91 'module_name' => $this->account->module_dir,
92 'module_id' => $this->account->id,
93 'link_field_name' => 'contacts',
94 'related_ids' => array($this->contact->id),
95 'name_value_list' => array(),
98 $this->assertEquals(1, $result['deleted'], 'Contact is not deleted');
100 $result = $this->_soapClient->call('get_relationships', array(
101 'session' => $this->_sessionId,
102 'module_name' => 'Accounts',
103 'module_id' => $this->account->id,
104 'link_field_name' => 'contacts',
105 'related_module_query' => "",
106 'link_module_fields' => array('id'),
110 $this->assertEquals(0, count($result['entry_list']), 'Contact is present');