Permalink
Browse files

Update testcase.

  • Loading branch information...
1 parent d29f0d9 commit 1e75b3e109b33a213dc7f99acc186fda33088ebb @k1LoW committed Dec 19, 2011
Showing with 200 additions and 42 deletions.
  1. +17 −2 libs/expander.php
  2. +0 −6 models/behaviors/calendar_validation_rule.php
  3. +0 −3 models/vevent.php
  4. +183 −31 tests/cases/models/vevent.test.php
View
@@ -40,6 +40,11 @@ public function expandEvents($start, $end, $event){
$this->until = empty($event['Vevent']['rrule_until']) ? null : $event['Vevent']['rrule_until'];
$this->byday = empty($event['Vevent']['rrule_byday']) ? null : explode(',', $event['Vevent']['rrule_byday']);
$this->bymonth = empty($event['Vevent']['rrule_bymonth']) ? null : explode(',', $event['Vevent']['rrule_bymonth']);
+ if (!empty($this->bymonth)) {
+ foreach ($this->bymonth as $key => $value) {
+ $this->bymonth[$key] = sprintf('%02d', $value);
+ }
+ }
$this->bymonthday = empty($event['Vevent']['rrule_bymonthday']) ? null : explode(',', $event['Vevent']['rrule_bymonthday']);
$this->interval = empty($event['Vevent']['rrule_interval']) ? 1 : $event['Vevent']['rrule_interval']; // INTERVAL
@@ -132,7 +137,14 @@ private function _expandEventsDaily(){
$e = $this->expandEndPoint;
while($this->_mta($s) < $this->_mta($e)) {
- $this->_pushEvent($s);
+ if ($this->bymonth) {
+ $month = date('m', $this->_mta($s));
+ if (in_array($month, $this->bymonth)) {
+ $this->_pushEvent($s);
+ }
+ } else {
+ $this->_pushEvent($s);
+ }
$s['day'] += 1 * $this->interval;
}
}
@@ -413,6 +425,9 @@ public static function expandEvent($start, $end, $event){
if (empty($event['Vevent'])) {
$event = array('Vevent' => $event);
}
+ if ($daydiff === 0) {
+ $evants = array($event);
+ }
for ($i = 0; $i <= $daydiff; $i++) {
$key = date('Y-m-d', mktime(0, 0, 0, $startDate['month'], ($startDate['day'] + $i), $startDate['year']));
if ($event) {
@@ -536,7 +551,7 @@ public static function _generateCalendarTemplate($start, $end){
/**
* mergeEvents
*
- * @param $arg
+ * @param $events1, $events2
* @return
*/
public static function mergeEvents($events1, $events2){
@@ -72,12 +72,6 @@ function checkByDay(&$model, $fields){
*/
function checkByMonth(&$model, $fields){
$bymonth = explode(',', array_shift($fields));
- if (!empty($bymonth)
- && (empty($model->data[$model->alias]['rrule_freq'])
- || $model->data[$model->alias]['rrule_freq'] === 'daily'
- || $model->data[$model->alias]['rrule_freq'] === 'monthly')) {
- return false;
- }
foreach ($bymonth as $value) {
if (!is_numeric($value)) {
return false;
View
@@ -211,7 +211,6 @@ function findByRange($start, $end){
array('Vevent.rrule_freq' => '')));
$query['order'] = array('Vevent.dtstart');
$result = $this->find('all', $query);
-
foreach ($result as $event) {
$event['Vevent']['event_start'] = $event['Vevent']['dtstart'];
$event['Vevent']['event_end'] = $event['Vevent']['dtend'];
@@ -248,11 +247,9 @@ function findByRange($start, $end){
if (strtotime($eventEnd) > strtotime($end)) {
$eventEnd = $end;
}
-
$events = Expander::mergeEvents($events, Expander::expandEvent($eventStart, $eventEnd, $ee));
}
}
-
return $events;
}
Oops, something went wrong. Retry.

0 comments on commit 1e75b3e

Please sign in to comment.