/**
  * testAdvancedSearch in related products
  * 
  * @see 0010814: quicksearch should search in related records
  */
 public function testAdvancedSearchInProduct()
 {
     Tinebase_Core::getPreference()->setValue(Tinebase_Preference::ADVANCED_SEARCH, true);
     $this->_saveLead();
     $filter = array(array('field' => 'query', 'operator' => 'contains', 'value' => 'PHPUnit test product'));
     $searchLeads = $this->_instance->searchLeads($filter, '');
     $this->assertEquals(1, $searchLeads['totalcount']);
 }
Exemplo n.º 2
0
 /**
  * add relation, remove relation and add relation again
  * 
  * see bug #4840 (http://forge.tine20.org/mantisbt/view.php?id=4840)
  */
 public function testAddRelationAgain()
 {
     $contact = $this->_getContact();
     $savedContact = Addressbook_Controller_Contact::getInstance()->create($contact, FALSE);
     $lead = $this->_getLead();
     $leadData = $lead->toArray();
     $leadData['relations'] = array(array('type' => 'PARTNER', 'related_record' => $savedContact->toArray()));
     $savedLead = $this->_instance->saveLead($leadData);
     $savedLead['relations'] = array();
     $savedLead = $this->_instance->saveLead($savedLead);
     $this->assertEquals(0, count($savedLead['relations']));
     $savedLead['relations'] = array(array('type' => 'PARTNER', 'related_record' => $savedContact->toArray()));
     $savedLead = $this->_instance->saveLead($savedLead);
     $this->assertEquals(1, count($savedLead['relations']), 'Relation has not been added');
     $this->assertEquals($contact->n_fn, $savedLead['relations'][0]['related_record']['n_fn'], 'Contact name does not match');
 }
 /**
  * testOtherRecordConstraintsConfig
  */
 public function testOtherRecordConstraintsConfig()
 {
     $leadData1 = $this->_getUit()->saveLead($this->_getLead(FALSE, FALSE)->toArray());
     $task = $this->_getTask();
     $taskJson = new Tasks_Frontend_Json();
     $leadJson = new Crm_Frontend_Json();
     $taskData = $task->toArray();
     $taskData['relations'] = array(array('type' => 'TASK', 'own_model' => 'Tasks_Model_Task', 'own_backend' => 'Sql', 'related_degree' => 'sibling', 'related_model' => 'Crm_Model_Lead', 'related_backend' => 'Sql', 'related_id' => $leadData1['id'], 'related_record' => $leadData1));
     $taskData = $taskJson->saveTask($taskData);
     $leadData2 = $this->_getUit()->saveLead($this->_getLead(FALSE, FALSE)->toArray());
     $leadData2['relations'] = array(array('type' => 'TASK', 'own_model' => 'Crm_Model_Lead', 'own_backend' => 'Sql', 'related_degree' => 'sibling', 'related_model' => 'Tasks_Model_Task', 'related_backend' => 'Sql', 'related_id' => $taskData['id'], 'related_record' => $taskData));
     $this->setExpectedException('Tinebase_Exception_InvalidRelationConstraints');
     $leadJson->saveLead($leadData2);
 }
Exemplo n.º 4
0
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     $this->_json->deleteLeads($this->_objects['lead']['id']);
     Addressbook_Controller_Contact::getInstance()->delete($this->_objects['lead']['relations'][0]['related_id']);
 }