Пример #1
0
 /**
  * @depends testCreateAndGetMeetingById
  */
 public function testUpdateMeetingFromForm()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $user = User::getByUsername('billy');
     $meetings = Meeting::getByName('MyMeeting');
     $meeting = $meetings[0];
     $this->assertEquals($meeting->name, 'MyMeeting');
     $timeStamp = time();
     $newStamp = DateTimeUtil::convertTimestampToDbFormatDateTime($timeStamp);
     $postData = array('owner' => array('id' => $user->id), 'name' => 'New Name', 'startDateTime' => DateTimeUtil::convertTimestampToDisplayFormat($timeStamp, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true));
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($meeting, $postData);
     $meeting->setAttributes($sanitizedPostData);
     $saved = $meeting->save();
     $this->assertTrue($saved);
     $id = $meeting->id;
     unset($meeting);
     $meeting = Meeting::getById($id);
     $this->assertEquals('New Name', $meeting->name);
     $this->assertEquals($sanitizedPostData['startDateTime'], $meeting->startDateTime);
     //create new meeting from scratch where the startDateTime and endDateTime attributes are not populated.
     //It should let you save.
     $meeting = new Meeting();
     $postData = array('owner' => array('id' => $user->id), 'name' => 'Lamazing', 'startDateTime' => DateTimeUtil::convertTimestampToDisplayFormat($timeStamp, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true));
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel($meeting, $postData);
     $meeting->setAttributes($sanitizedPostData);
     $saved = $meeting->save();
     $this->assertTrue($saved);
     $id = $meeting->id;
     unset($meeting);
     $meeting = Meeting::getById($id);
     $this->assertEquals('Lamazing', $meeting->name);
     $this->assertEquals($sanitizedPostData['startDateTime'], $meeting->startDateTime);
     $this->assertEquals(null, $meeting->endDateTime);
 }
 public function actionGetMeetingEndDateTimeBasedOnStartDateTime($startDateTime = null)
 {
     Yii::app()->getClientScript()->setToAjaxMode();
     if ($startDateTime == null) {
         return null;
     }
     $timestamp = CDateTimeParser::parse($startDateTime, DateTimeUtil::getLocaleDateTimeFormatForInput());
     if ($timestamp == null) {
         return null;
     }
     $endTimeStamp = $timestamp + 15 * 60;
     $endDateTime = DateTimeUtil::convertTimestampToDisplayFormat((int) $endTimeStamp, DateTimeUtil::DATETIME_FORMAT_DATE_WIDTH, DateTimeUtil::DATETIME_FORMAT_TIME_WIDTH, true);
     echo CJSON::encode(array('endDateTime' => $endDateTime));
     Yii::app()->end(0, false);
 }