/**
  * tests the findTimesheetsByTimeaccountAndPeriod method of the timesheet controller
  */
 public function testFindTimesheetsByTimeaccountAndPeriod()
 {
     $i = 0;
     $now = Tinebase_DateTime::now();
     $data = array('account_id' => Tinebase_Core::getUser()->getId(), 'is_cleared' => true, 'timeaccount_id' => $this->_objects['timeaccount']->getId(), 'description' => 'test', 'duration' => 1, 'title' => 'test');
     while ($i < 10) {
         $data['start_date'] = $now->addHour(1);
         $this->_timesheetController->create(new Timetracker_Model_Timesheet($data));
         $i++;
     }
     $sdate = Tinebase_DateTime::now();
     $sdate->subDay(1);
     $edate = $now->addDay(1);
     $result = $this->_timesheetController->findTimesheetsByTimeaccountAndPeriod($this->_objects['timeaccount']->getId(), $sdate, $edate);
     $this->assertEquals(10, count($result));
 }
コード例 #2
0
 /**
  * creates and persists a timesheet
  * 
  * @param array $data
  * @return Tinebase_Record_Interface
  */
 protected function _createTimesheet($data)
 {
     $ts = new Timetracker_Model_Timesheet($data);
     return $this->_tsController->create($ts);
 }
 /**
  * 
  * @param array $recordData
  * @return Tinebase_Record_RecordSet
  */
 protected function _createTimesheets($recordData = NULL)
 {
     $this->_timesheetController = Timetracker_Controller_Timesheet::getInstance();
     if (!$this->_timesheetRecords) {
         $this->_timesheetRecords = new Tinebase_Record_RecordSet('Timetracker_Model_Timesheet');
     }
     if (!$recordData) {
         if (!$this->_timeaccountRecords) {
             $this->_createTimeaccounts();
         }
         $tsDate = clone $this->_referenceDate;
         $tsDate->addMonth(4)->addDay(5);
         // this is a ts on 20xx-05-06
         $timesheet = new Timetracker_Model_Timesheet(array('account_id' => Tinebase_Core::getUser()->getId(), 'timeaccount_id' => $this->_timeaccountRecords->filter('title', 'TA-for-Customer3')->getFirstRecord()->getId(), 'start_date' => $tsDate, 'duration' => 105, 'description' => 'ts from ' . (string) $tsDate));
         $this->_timesheetRecords->addRecord($this->_timesheetController->create($timesheet));
         // this is a ts on 20xx-05-07
         $timesheet->id = NULL;
         $timesheet->start_date = $tsDate->addDay(1);
         $timesheet->description = 'ts from ' . (string) $tsDate;
         $this->_timesheetRecords->addRecord($this->_timesheetController->create($timesheet));
         // this is a ts on 20xx-09-07
         $timesheet->id = NULL;
         $timesheet->start_date = $tsDate->addMonth(4);
         $timesheet->description = 'ts from ' . (string) $tsDate;
         $this->_timesheetRecords->addRecord($this->_timesheetController->create($timesheet));
         // this is a ts on 20xx-09-08
         $timesheet->id = NULL;
         $timesheet->start_date = $tsDate->addDay(1);
         $timesheet->description = 'ts from ' . (string) $tsDate;
         $this->_timesheetRecords->addRecord($this->_timesheetController->create($timesheet));
     } else {
         foreach ($recordData as $tsData) {
             $timesheet = new Timetracker_Model_Timesheet($tsData);
             $this->_timesheetRecords->addRecord($this->_timesheetController->create($timesheet));
         }
     }
     return $this->_timesheetRecords;
 }