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);
 }
示例#2
0
 public function testAcceptanceAfterDateUpdate()
 {
     global $current_user;
     global $db;
     $meeting = SugarTestMeetingUtilities::createMeeting();
     $user = SugarTestUserUtilities::createAnonymousUser();
     SugarTestMeetingUtilities::addMeetingUserRelation($meeting->id, $current_user->id);
     SugarTestMeetingUtilities::addMeetingUserRelation($meeting->id, $user->id);
     // set this to 'accept' before handleSave and make sure it gets set to 'none' after handleSave
     $meeting->set_accept_status($user, 'accept');
     $meeting->save();
     $_POST['record'] = $_REQUEST['record'] = $meeting->id;
     $_POST['user_invitees'] = $current_user->id . ',' . $user->id;
     $_POST['module'] = 'Meetings';
     $_POST['action'] = 'Save';
     $_POST['assigned_user_id'] = $current_user->id;
     $_POST['send_invites'] = $_REQUEST['send_invites'] = 1;
     $_POST['date_start'] = $GLOBALS['timedate']->getNow()->asDb();
     $_POST['date_end'] = $GLOBALS['timedate']->getNow()->modify("+900 seconds")->asDb();
     $formBase = new MeetingFormBase();
     $formBase->handleSave('', false, false);
     $sql = "SELECT accept_status FROM meetings_users WHERE meeting_id='{$meeting->id}' AND user_id='{$user->id}'";
     $result = $db->query($sql);
     if ($row = $db->fetchByAssoc($result)) {
         $this->assertEquals('none', $row['accept_status'], 'Should be none after date changed and invite sent.');
     }
 }
 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));
 }
示例#4
0
 /**
  * Ensure that saving relationship changes do not fail with fatal error and works fine
  * when saving relation field with type id
  *
  * @group 53516
  */
 public function testSaveRelationOnRelateFieldWithIdType()
 {
     $meeting = SugarTestMeetingUtilities::createMeeting();
     $meeting->in_workflow = true;
     $meeting->not_use_rel_in_req = true;
     $meeting->contact_id = $meeting->new_rel_id = $this->contact->id;
     $meeting->new_rel_relname = 'contact_id';
     $meeting->save_relationship_changes(false);
 }
 /**
  * Create test user
  *
  */
 public function setUp()
 {
     $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/soap.php';
     parent::setUp();
     $this->_login();
     // Logging in just before the SOAP call as this will also commit any pending DB changes
     $this->_setupTestContact();
     $this->_meeting = SugarTestMeetingUtilities::createMeeting();
 }
示例#6
0
 public function setUp()
 {
     $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/service/v4_1/soap.php';
     parent::setUp();
     $this->_login();
     // Logging in just before the SOAP call as this will also commit any pending DB changes
     for ($x = 0; $x < 4; $x++) {
         $mid = SugarTestMeetingUtilities::createMeeting();
         SugarTestMeetingUtilities::addMeetingUserRelation($mid->id, self::$_user->id);
     }
     $GLOBALS['db']->commit();
 }
示例#7
0
 /**
  * Create test user
  *
  */
 public function setUp()
 {
     $this->_soapURL = $GLOBALS['sugar_config']['site_url'] . '/soap.php';
     parent::setUp();
     $this->_login();
     // Logging in just before the SOAP call as this will also commit any pending DB changes
     $this->_contact = SugarTestContactUtilities::createContact();
     $this->_contact->contacts_users_id = $GLOBALS['current_user']->id;
     $this->_contact->save();
     $this->_meeting = SugarTestMeetingUtilities::createMeeting();
     $GLOBALS['db']->commit();
     // Making sure these changes are committed to the database
 }
示例#8
0
 /**
  * @group 63403
  */
 public function testBug63403()
 {
     $meeting = SugarTestMeetingUtilities::createMeeting();
     SugarTestMeetingUtilities::addMeetingUserRelation($meeting->id, $GLOBALS['current_user']->id);
     $meeting->date_start = $GLOBALS['timedate']->getNow()->asDb();
     $meeting->date_end = $GLOBALS['timedate']->getNow()->modify("+25 days")->asDb();
     $meeting->duration_hours = 720;
     $meeting->save();
     $calendar = new CalendarActivity($meeting);
     $start_date_time = $GLOBALS['timedate']->fromString($GLOBALS['timedate']->nowDb());
     $result = $calendar->get_activities($GLOBALS['current_user']->id, false, $start_date_time->get("+7 days"), $start_date_time->get("+14 days"), false);
     $this->assertNotEmpty($result);
     $this->assertEquals($meeting->id, $result[0]->sugar_bean->id, 'We should get current test Meeting');
 }
示例#9
0
 public function setUp()
 {
     $this->timedate = new TimeDate();
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $meeting = SugarTestMeetingUtilities::createMeeting();
     $meeting->name = "VeryImportantMeeting";
     $meeting->date_start = $this->timedate->to_display_date_time(gmdate("Y-m-d H:i:s", mktime(12, 30, 00, date("m"), date("d") + 1, date("Y"))));
     $meeting->save();
     $GLOBALS['db']->query(sprintf("INSERT INTO meetings_users (id, meeting_id, user_id, required, accept_status, date_modified, deleted) VALUES ('%s', '%s', '%s', '1', 'none', NULL, '0')", create_guid(), $meeting->id, $GLOBALS['current_user']->id));
     $task = SugarTestTaskUtilities::createTask();
     $task->assigned_user_id = $GLOBALS['current_user']->id;
     $task->name = "VeryImportantTask";
     $task->save();
     $this->project = SugarTestProjectUtilities::createProject();
     $projectId = $this->project->id;
     $projectTaskData = array('project_id' => $projectId, 'parent_task_id' => '', 'project_task_id' => 1, 'percent_complete' => 50, 'name' => 'VeryImportantProjectTask');
     $projectTask = SugarTestProjectTaskUtilities::createProjectTask($projectTaskData);
     $projectTask->assigned_user_id = $GLOBALS['current_user']->id;
     $projectTask->save();
 }
示例#10
0
 /**
  * Test if set_entries returns proper IDs for Calls/Meetings
  * with set outlook_id or with equal fields
  *
  * @param $module - Module name
  * @param $outlookID - Outlook ID (must always be set, for the OPI Sync check to be initiated)
  * @param $nameValueLists - name-value lists for set_entries call
  *
  * @dataProvider dataProvider
  * @group 63559
  */
 public function testSetEntriesOPISync($module, $outlookID, $nameValueLists)
 {
     $meeting = SugarTestMeetingUtilities::createMeeting();
     // Set the fields using $nameValueLists, and resave the meeting
     foreach ($nameValueLists[0] as $nameValue) {
         $meeting->{$nameValue}['name'] = $nameValue['value'];
     }
     $meeting->outlook_id = $outlookID;
     $meeting->save();
     // Mock $server and $server->wsdl
     $server = $this->getMock('soap_server', array('register'));
     $server->wsdl = $this->getMock('wsdl', array('addComplexType'));
     // Need name space to be set
     $NAMESPACE = '';
     require_once 'soap/SoapSugarUsers.php';
     require_once 'soap/SoapError.php';
     // Unset $NAMESPACE, it was only needed in SoapSugarUsers.php
     unset($NAMESPACE);
     $actual = handle_set_entries($module, $nameValueLists);
     $this->assertEquals($meeting->id, $actual['ids'][0], 'Meeting not synced properly.');
 }
示例#11
0
 /**
  * @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');
     }
 }
示例#12
0
 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();
 }
示例#13
0
 public function testMeetingsUsersRelationships()
 {
     global $current_user;
     $bean = SugarTestMeetingUtilities::createMeeting();
     $convert_lead = SugarTestViewConvertLeadUtilities::createViewConvertLead();
     if ($bean->object_name == "Meeting") {
         $convert_lead->setMeetingsUsersRelationship($bean);
     }
     $this->assertTrue(is_object($bean->users), "Relationship wasn't set.");
     SugarTestMeetingUtilities::removeMeetingUsers();
     SugarTestMeetingUtilities::removeAllCreatedMeetings();
 }
示例#14
0
 public function setUp()
 {
     $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
     $this->meeting = SugarTestMeetingUtilities::createMeeting();
     //$this->listLayoutMetaDataParser = new ListLayoutMetaDataParser(MB_LISTVIEW, 'Meetings');
 }