function setUp() { global $db, $timedate, $current_user; $this->original_current_user = $current_user; $user = new User(); $user->retrieve('1'); $current_user = $user; if ($db->dbType != 'mysql') { $this->markTestSkipped('Skipping for non-mysql dbs'); } $this->meeting = SugarTestMeetingUtilities::createMeeting(); $date_start = $timedate->nowDb(); $this->meeting->date_start = $date_start; $this->meeting->duration_hours = 2; $this->meeting->duration_minutes = 30; $this->meeting->save(); $sql = "UPDATE meetings SET date_end = '{$date_start}' WHERE id = '{$this->meeting->id}'"; $db->query($sql); $this->call = SugarTestCallUtilities::createCall(); $date_start = $timedate->nowDb(); $this->call->date_start = $date_start; $this->call->duration_hours = 2; $this->call->duration_minutes = 30; $this->call->save(); $sql = "UPDATE calls SET date_end = '{$date_start}' WHERE id = '{$this->call->id}'"; $db->query($sql); }
public function setUp() { global $current_user; $current_user = SugarTestUserUtilities::createAnonymousUser(); $this->call = SugarTestCallUtilities::createCall(); $this->useOutputBuffering = false; }
public function setUp() { global $timedate, $current_user; $timedate = TimeDate::getInstance(); require 'include/modules.php'; $GLOBALS['beanList'] = $beanList; $GLOBALS['beanFiles'] = $beanFiles; $current_user = SugarTestUserUtilities::createAnonymousUser(); $this->nowTime = $timedate->asDb($timedate->getNow()->get("-10 minutes")); $this->tenMinutesLaterTime = $timedate->asDb($timedate->getNow()->get("+10 minutes")); $current_user->is_admin = 1; $current_user->save(); $this->meeting = SugarTestMeetingUtilities::createMeeting(); $this->meeting->team_id = $current_user->team_id; $this->meeting->team_set_id = $current_user->team_set_id; $this->meeting->team_id = $current_user->team_id; $this->meeting->team_set_id = $current_user->team_set_id; $this->meeting->assigned_user_id = $current_user->id; $this->meeting->save(); $this->meeting->load_relationship('users'); $this->meeting->users->add($current_user); $this->call = SugarTestCallUtilities::createCall(); $this->call->team_id = $current_user->team_id; $this->call->team_set_id = $current_user->team_set_id; $this->call->assigned_user_id = $current_user->id; $this->call->save(); $this->call->load_relationships('users'); $this->call->users->add($current_user); $this->contact = SugarTestContactUtilities::createContact(); $this->contact->email1 = '*****@*****.**'; $this->contact->contacts_users_id = $current_user->id; $this->contact->load_relationship('user_sync'); $this->contact->user_sync->add($current_user); $this->contact->sync_contact = 1; $this->contact->save(); $this->task = SugarTestTaskUtilities::createTask(); $this->task->assigned_user_id = $current_user->id; $this->task->team_id = $current_user->id; $this->task->team_set_id = $current_user->id; $this->task->save(); //$this->useOutputBuffering = false; /** * This provider returns an Array of Array data. Each Array contains the following data * 0 => String - Left side module name * 1 => String - Right side module name * 2 => String - Relationship Query * 3 => boolean to return deleted records or not (this is actually ignored by the function) * 4 => integer offset to start with * 5 => integer value for the maximum number of results * 6 => array of fields to select and return * 7 => load_relationships - Relationship name to use * 8 => array of expected results * 9 => integer of expected total count * 10 => array of expected soap error * @return array The provider array */ $this->testData = array(array('Users', 'Meetings', "( (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND m1.deleted = 0) OR (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND m1.deleted = 1) AND m1.id IN ('{$this->meeting->id}')) OR (m1.id NOT IN ('{$this->meeting->id}') AND m1.deleted = 0) AND m2.id = '{$current_user->id}'", 0, 0, 3000, $this->callsAndMeetingsSelectFields, 'meetings_users', array('id' => $this->meeting->id), 1, $this->noSoapErrorArray), array('Users', 'Calls', "( m1.deleted = 0) AND m2.id = '{$current_user->id}'", 0, 0, 3000, $this->callsAndMeetingsSelectFields, 'calls_users', array('id' => $this->call->id), 1, $this->noSoapErrorArray), array('Users', 'Contacts', "( (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 0) OR ({0}.date_modified > '{$this->nowTime}' AND {0}.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 1) AND m1.id IN ('31a219bd-b9c1-2c3e-aa5d-4f2778ab0347','c794bc39-e4fb-f515-f1d5-4f285ca88965','d51a0555-8f84-9e62-0fbc-4f2787b5d839','a1219ae6-5a6b-0d1b-c49f-4f2854bc2912')) OR (m1.id NOT IN ('31a219bd-b9c1-2c3e-aa5d-4f2778ab0347','c794bc39-e4fb-f515-f1d5-4f285ca88965','d51a0555-8f84-9e62-0fbc-4f2787b5d839','a1219ae6-5a6b-0d1b-c49f-4f2854bc2912') AND {0}.deleted = 0) AND m2.id = '1'", 0, 0, 3000, $this->contactsSelectFields, 'contacts_users', array('id' => $this->contact->id, 'email1' => '*****@*****.**'), 1, $this->noSoapErrorArray), array('Users', 'Tasks', " ( (m1.date_modified > '{$this->nowTime}' AND m1.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 0) OR ({0}.date_modified > '{$this->nowTime}' AND {0}.date_modified <= '{$this->tenMinutesLaterTime}' AND {0}.deleted = 1) AND m1.id IN ('{$this->task->id}')) OR (m1.id NOT IN ('{$this->task->id}') AND {0}.deleted = 0) AND m2.id = '1'", 0, 0, 3000, $this->tasksSelectFields, 'tasks_assigned_user', array('id' => $this->task->id), 1, $this->noSoapErrorArray)); }
/** * @group 58702 * Test if Meetings/Calls/Tasks are shown properly when * show completed flag is set * * @dataProvider dataProvider */ public function testShowCompleted($showCompleted) { // Create Held Meeting $meeting = SugarTestMeetingUtilities::createMeeting(); $meeting->date_start = $GLOBALS['timedate']->nowDb(); $meeting->date_end = $GLOBALS['timedate']->nowDb(); $meeting->status = 'Held'; $meeting->save(); $meeting->set_accept_status($GLOBALS['current_user'], 'accept'); // Create Held Call $call = SugarTestCallUtilities::createCall(); $call->date_start = $GLOBALS['timedate']->nowDb(); $call->date_end = $GLOBALS['timedate']->nowDb(); $call->status = 'Held'; $call->save(); $call->set_accept_status($GLOBALS['current_user'], 'accept'); // Create Completed Task $task = SugarTestTaskUtilities::createTask(); $task->date_due = $GLOBALS['timedate']->nowDb(); $task->status = 'Completed'; $task->assigned_user_id = $GLOBALS['current_user']->id; $task->save(); // Set query dates $start_date_time = $GLOBALS['timedate']->fromString(date("Y-m-d")); $end_date_time = $start_date_time->get("+7 days"); $start_date_time = $start_date_time->get("-7 days"); // Get all activities for the user $result = CalendarActivity::get_activities($GLOBALS['current_user']->id, true, $start_date_time, $end_date_time, 'month', true, $showCompleted); // Depending on show completed, get_activities should return 3 entries, the ones we created above if ($showCompleted) { $this->assertEquals(3, sizeof($result), 'get_activities did not return the Metting, Call and Task as it should have'); $this->assertEquals($result[0]->sugar_bean->id, $meeting->id, 'Meeting not returned properly'); $this->assertEquals($result[1]->sugar_bean->id, $call->id, 'Call not returned properly'); $this->assertEquals($result[2]->sugar_bean->id, $task->id, 'Task not returned properly'); } else { $this->assertEquals(0, sizeof($result), 'get_activities should be empty'); } }
public function setUp() { global $beanList, $beanFiles, $current_user; global $beanList, $beanFiles; $beanList = array(); $beanFiles = array(); require 'include/modules.php'; $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v4_1/soap.php'; parent::setUp(); $current_user = SugarTestUserUtilities::createAnonymousUser(); $this->another_user = SugarTestUserUtilities::createAnonymousUser(); $this->_login(); global $current_user; $current_user = SugarTestUserUtilities::createAnonymousUser(); $this->another_user = SugarTestUserUtilities::createAnonymousUser(); $this->contact1 = SugarTestContactUtilities::createContact(); $this->contact1->contacts_users_id = $current_user->id; $this->contact1->first_name = 'First1'; $this->contact1->last_name = 'Last1'; $this->contact1->save(); $this->contact1->user_sync->add($current_user); $this->contact1->sync_contact = 1; $this->contact1->save(); $this->contact2 = SugarTestContactUtilities::createContact(); $this->contact2->contacts_users_id = $this->another_user->id; $this->contact2->first_name = 'First2'; $this->contact2->last_name = 'Last2'; $this->contact2->save(); $this->contact2->user_sync->add($this->another_user); $this->contact2->sync_contact = 1; $this->contact2->save(); $this->call1 = SugarTestCallUtilities::createCall(); $this->call1->name = 'RESTAPI4_1Test1'; $this->call1->load_relationship('users'); $this->call1->users->add($current_user); $this->call1->save(); $this->call2 = SugarTestCallUtilities::createCall(); $this->call2->name = 'RESTAPI4_1Test2'; $this->call2->load_relationship('users'); $this->call2->users->add($current_user); $this->call2->save(); $this->meeting1 = SugarTestMeetingUtilities::createMeeting(); $this->meeting1->name = 'RESTAPI4_1Test1'; $this->meeting1->load_relationship('users'); $this->meeting1->users->add($current_user); $this->meeting1->save(); $this->meeting2 = SugarTestMeetingUtilities::createMeeting(); $this->meeting2->name = 'RESTAPI4_1Test2'; $this->meeting2->load_relationship('users'); $this->meeting2->users->add($this->another_user); $this->meeting2->save(); $this->meeting3 = SugarTestMeetingUtilities::createMeeting(); $this->meeting3->name = 'RESTAPI4_1Test3'; $this->meeting3->load_relationship('users'); $this->meeting3->users->add($current_user); $this->meeting3->save(); $this->meeting4 = SugarTestMeetingUtilities::createMeeting(); $this->meeting4->name = 'SOAPAPI4_1Test4'; $this->meeting4->load_relationship('users'); $this->meeting4->users->add($current_user); $this->meeting4->mark_deleted($this->meeting4->id); $this->meeting4->deleted = 1; $this->meeting4->save(); $GLOBALS['db']->commit(); }