field = get_widget('varchar'); $this->field->id = 'Contactstest_c'; $this->field->name = 'test_c'; $this->field->type = 'varchar'; $this->field->len = 255; $this->field->importable = 'true'; $this->field->label = ''; $this->module = new Contact(); $this->dynamicField = new DynamicField('Contacts'); $this->dynamicField->setup($this->module); $this->dynamicField->addFieldObject($this->field); SugarTestHelper::setUp('dictionary'); $GLOBALS['reload_vardefs'] = true; $this->account = SugarTestAccountUtilities::createAccount(); $this->contact = SugarTestContactUtilities::createContact(); $this->contact->account_id = $this->account->id; $this->contact->test_c = 'test value'; $this->contact->load_relationship('accounts'); $this->contact->accounts->add($this->account->id); $this->contact->save(); $GLOBALS['db']->commit(); } /** * Removing field, account, contact */ public function tearDown() { SugarTestContactUtilities::removeAllCreatedContacts(); SugarTestAccountUtilities::removeAllCreatedAccounts(); $this->dynamicField->deleteField($this->field); SugarTestHelper::tearDown(); } /** * Test asserts that contact can be found by custom field * * @group 58138 */ public function testSoap() { $soap_url = $GLOBALS['sugar_config']['site_url'] . '/soap.php'; $this->soap = new nusoapclient($soap_url); $result = $this->soap->call('login', array( 'user_auth' => array( 'user_name' => $GLOBALS['current_user']->user_name, 'password' => $GLOBALS['current_user']->user_hash, 'version' => '.01' ), 'application_name' => 'SoapTest' ) ); $actual = $this->soap->call('get_relationships', array( 'session' => $result['id'], 'module_name' => 'Accounts', 'module_id' => $this->account->id, 'link_field_name' => 'Contacts', 'related_module_query' => "contacts_cstm.test_c = 'test value' ", 'deleted' => '1', )); $this->assertInternalType('array', $actual, 'Incorrect response'); if (empty($actual['ids'])) { $this->fail('Data is not present'); } $actual = reset($actual['ids']); $this->assertEquals($this->contact->id, $actual['id'], 'Contact is incorrect'); } public static function dataProvider() { return array( array('/service/v2/soap.php'), array('/service/v2_1/soap.php'), array('/service/v3/soap.php'), array('/service/v3_1/soap.php'), array('/service/v4/soap.php'), array('/service/v4_1/soap.php') ); } /** * Test asserts that contact can be found by custom field * * @group 58138 * @dataProvider dataProvider */ public function testSoapVersions($url) { $soap_url = $GLOBALS['sugar_config']['site_url'] . $url; $this->soap = new nusoapclient($soap_url); $result = $this->soap->call('login', array( 'user_auth' => array( 'user_name' => $GLOBALS['current_user']->user_name, 'password' => $GLOBALS['current_user']->user_hash, 'version' => '.01' ), 'application_name' => 'SoapTest' ) ); $actual = $this->soap->call('get_relationships', array( 'session' => $result['id'], 'module_name' => 'Accounts', 'module_id' => $this->account->id, 'link_field_name' => 'contacts', 'related_module_query' => "contacts_cstm.test_c = 'test value' ", 'link_module_fields' => array('id'), 'deleted' => '1', )); $this->assertInternalType('array', $actual, 'Incorrect response'); if (empty($actual['entry_list'])) { $this->fail('Data is not present'); } $actual = reset($actual['entry_list']); $this->assertEquals($this->contact->id, $actual['id'], 'Contact is incorrect'); } }