/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_json = new Crm_Frontend_Json(); $contact = $this->_getContact(); $task = $this->_getTask(); $lead = $this->_getLead(); $leadData = $lead->toArray(); $leadData['relations'] = array(array('type' => 'TASK', 'related_record' => $task->toArray()), array('type' => 'PARTNER', 'related_record' => $contact->toArray())); $this->_objects['lead'] = $this->_json->saveLead(Zend_Json::encode($leadData)); }
/** * testSortByLeadState * * @see 0010792: Sort leads by status and source */ public function testSortByLeadState() { $this->_saveLead(); $lead2 = $this->_getLead()->toArray(); // open $lead2['leadstate_id'] = 2; // contacted $this->_instance->saveLead($lead2); $sort = array('sort' => 'leadstate_id', 'dir' => 'ASC'); $searchLeads = $this->_instance->searchLeads($this->_getLeadFilter(), $sort); $this->assertEquals(2, $searchLeads['results'][0]['leadstate_id'], 'leadstate "contacted" should come first'); }
/** * 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); }