array(true), 1 => array(false) ); } /** * @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'); } // Or it shouldn't return anything since all the activities are completed else { $this->assertEquals(0, sizeof($result), 'get_activities should be empty'); } } }