public function testInviteComponent() { $name = $this->faker->word; $value = $this->faker->word; $address = $this->faker->word; $url = $this->faker->word; $displayName = $this->faker->word; $sentBy = $this->faker->word; $dir = $this->faker->word; $lang = $this->faker->word; $cutype = $this->faker->word; $role = $this->faker->word; $member = $this->faker->word; $delTo = $this->faker->word; $delFrom = $this->faker->word; $date = $this->faker->iso8601; $uri = $this->faker->word; $ct = $this->faker->word; $tz = $this->faker->word; $utc = mt_rand(0, 24); $rangeType = mt_rand(1, 10); $weeks = mt_rand(1, 7); $days = mt_rand(1, 30); $hours = mt_rand(0, 23); $minutes = mt_rand(0, 59); $seconds = mt_rand(0, 59); $related = $this->faker->randomElement(['START', 'END']); $ordwk = mt_rand(1, 54); $num = mt_rand(1, 1000); $quantity = mt_rand(5, 10); $numbers = self::randomRange(0, 59, $quantity); $seclist = $minlist = implode(',', $numbers); $numbers = self::randomRange(0, 23, $quantity); $hrlist = implode(',', $numbers); $numbers = self::randomRange(1, 31, $quantity); $modaylist = implode(',', $numbers); $numbers = self::randomRange(1, 366, $quantity); $yrdaylist = implode(',', $numbers); $numbers = self::randomRange(1, 53, $quantity); $wklist = implode(',', $numbers); $numbers = self::randomRange(1, 12, $quantity); $molist = implode(',', $numbers); $numbers = self::randomRange(1, 366, $quantity); $poslist = implode(',', $numbers); $lat = $this->faker->randomFloat; $lon = $this->faker->randomFloat; $desc = $this->faker->word; $summary = $this->faker->word; $method = $this->faker->word; $loc = $this->faker->word; $x_uid = $this->faker->uuid; $uid = $this->faker->uuid; $compNum = mt_rand(1, 10); $priority = mt_rand(1, 10); $percent = mt_rand(1, 100); $seq = mt_rand(1, 10); $d = mt_rand(1, 10); $calItemId = $this->faker->word; $apptId = $this->faker->word; $ciFolder = $this->faker->word; $ridZ = $this->faker->iso8601; $category = $this->faker->word; $comment = $this->faker->word; $contact = $this->faker->word; $fr = $this->faker->word; $descHtml = $this->faker->word; $xparam = new \Zimbra\Mail\Struct\XParam($name, $value); $at = new \Zimbra\Mail\Struct\CalendarAttendee($address, $url, $displayName, $sentBy, $dir, $lang, $cutype, $role, ParticipationStatus::NEEDS_ACTION(), true, $member, $delTo, $delFrom, [$xparam]); $abs = new \Zimbra\Mail\Struct\DateAttr($date); $rel = new \Zimbra\Mail\Struct\DurationInfo(true, $weeks, $days, $hours, $minutes, $seconds, $related, $num); $trigger = new \Zimbra\Mail\Struct\AlarmTriggerInfo($abs, $rel); $repeat = new \Zimbra\Mail\Struct\DurationInfo(false, $weeks, $days, $hours, $minutes, $seconds, $related, $num); $attach = new \Zimbra\Mail\Struct\CalendarAttach($uri, $ct, $value); $except = new \Zimbra\Mail\Struct\ExceptionRuleInfo($rangeType, $date, null, null, $tz, $ridZ); $cancel = new \Zimbra\Mail\Struct\CancelRuleInfo($rangeType, $date, $tz, $ridZ); $s = new \Zimbra\Mail\Struct\DtTimeInfo($date, $tz, $utc); $e = new \Zimbra\Mail\Struct\DtTimeInfo($date, $tz, $utc); $dur = new \Zimbra\Mail\Struct\DurationInfo(true, $weeks, $days, $hours, $minutes, $seconds, $related, $num); $dtval = new \Zimbra\Mail\Struct\DtVal($s, $e, $dur); $dates = new \Zimbra\Mail\Struct\SingleDates($tz, [$dtval]); $wkday = new \Zimbra\Mail\Struct\WkDay(WeekDay::SU(), $ordwk); $until = new \Zimbra\Mail\Struct\DateTimeStringAttr($date); $count = new \Zimbra\Mail\Struct\NumAttr($num); $interval = new \Zimbra\Mail\Struct\IntervalRule($num); $bysecond = new \Zimbra\Mail\Struct\BySecondRule($seclist); $byminute = new \Zimbra\Mail\Struct\ByMinuteRule($seclist); $byhour = new \Zimbra\Mail\Struct\ByHourRule($hrlist); $byday = new \Zimbra\Mail\Struct\ByDayRule([$wkday]); $bymonthday = new \Zimbra\Mail\Struct\ByMonthDayRule($modaylist); $byyearday = new \Zimbra\Mail\Struct\ByYearDayRule($yrdaylist); $byweekno = new \Zimbra\Mail\Struct\ByWeekNoRule($wklist); $bymonth = new \Zimbra\Mail\Struct\ByMonthRule($molist); $bysetpos = new \Zimbra\Mail\Struct\BySetPosRule($poslist); $wkst = new \Zimbra\Mail\Struct\WkstRule(WeekDay::SU()); $xname = new \Zimbra\Mail\Struct\XNameRule($name, $value); $rule = new \Zimbra\Mail\Struct\SimpleRepeatingRule(Frequency::SECOND(), $until, $count, $interval, $bysecond, $byminute, $byhour, $byday, $bymonthday, $byyearday, $byweekno, $bymonth, $bysetpos, $wkst, [$xname]); $add = new \Zimbra\Mail\Struct\AddRecurrenceInfo([$except, $cancel, $dates, $rule]); $exclude = new \Zimbra\Mail\Struct\ExcludeRecurrenceInfo([$except, $cancel, $dates, $rule]); $geo = new \Zimbra\Mail\Struct\GeoInfo($lat, $lon); $xprop = new \Zimbra\Mail\Struct\XProp($name, $value, [$xparam]); $alarm = new \Zimbra\Mail\Struct\AlarmInfo(AlarmAction::DISPLAY(), $trigger, $repeat, $desc, $attach, $summary, [$at], [$xprop]); $org = new \Zimbra\Mail\Struct\CalOrganizer($address, $url, $displayName, $sentBy, $dir, $lang, [$xparam]); $recur = new \Zimbra\Mail\Struct\RecurrenceInfo([$add, $exclude, $except, $cancel, $dates, $rule]); $exceptId = new \Zimbra\Mail\Struct\ExceptionRecurIdInfo($date, $tz, RangeType::NONE()); $comp = new \Zimbra\Mail\Struct\InviteComponent($method, $compNum, true, $priority, $name, $loc, $percent, $date, true, FreeBusyStatus::FREE(), FreeBusyStatus::FREE(), Transparency::OPAQUE(), true, $x_uid, $uid, $seq, $d, $calItemId, $apptId, $ciFolder, InviteStatus::COMPLETED(), InviteClass::PUB(), $url, true, $ridZ, true, true, true, [InviteChange::SUBJECT(), InviteChange::LOCATION(), InviteChange::TIME()], [$category], [$comment], [$contact], $geo, [$at], [$alarm], [$xprop], $fr, $desc, $descHtml, $org, $recur, $exceptId, $s, $e, $dur); $this->assertSame([$category], $comp->getCategories()->all()); $this->assertSame([$comment], $comp->getComments()->all()); $this->assertSame([$contact], $comp->getContacts()->all()); $this->assertSame($geo, $comp->getGeo()); $this->assertSame([$at], $comp->getAttendees()->all()); $this->assertSame([$alarm], $comp->getAlarms()->all()); $this->assertSame([$xprop], $comp->getXProps()->all()); $this->assertSame($fr, $comp->getFragment()); $this->assertSame($desc, $comp->getDescription()); $this->assertSame($descHtml, $comp->getHtmlDescription()); $this->assertSame($org, $comp->getOrganizer()); $this->assertSame($recur, $comp->getRecurrence()); $this->assertSame($exceptId, $comp->getExceptionId()); $this->assertSame($s, $comp->getDtStart()); $this->assertSame($e, $comp->getDtEnd()); $this->assertSame($dur, $comp->getDuration()); $comp->addCategory($category)->addComment($comment)->addContact($contact)->setGeo($geo)->addAttendee($at)->addAlarm($alarm)->addXProp($xprop)->setFragment($fr)->setDescription($desc)->setHtmlDescription($descHtml)->setOrganizer($org)->setRecurrence($recur)->setExceptionId($exceptId)->setDtStart($s)->setDtEnd($e)->setDuration($dur); $this->assertSame([$category, $category], $comp->getCategories()->all()); $this->assertSame([$comment, $comment], $comp->getComments()->all()); $this->assertSame([$contact, $contact], $comp->getContacts()->all()); $this->assertSame($geo, $comp->getGeo()); $this->assertSame([$at, $at], $comp->getAttendees()->all()); $this->assertSame([$alarm, $alarm], $comp->getAlarms()->all()); $this->assertSame([$xprop, $xprop], $comp->getXProps()->all()); $this->assertSame($fr, $comp->getFragment()); $this->assertSame($desc, $comp->getDescription()); $this->assertSame($descHtml, $comp->getHtmlDescription()); $this->assertSame($org, $comp->getOrganizer()); $this->assertSame($recur, $comp->getRecurrence()); $this->assertSame($exceptId, $comp->getExceptionId()); $this->assertSame($s, $comp->getDtStart()); $this->assertSame($e, $comp->getDtEnd()); $this->assertSame($dur, $comp->getDuration()); $comp = new \Zimbra\Mail\Struct\InviteComponent($method, $compNum, true, $priority, $name, $loc, $percent, $date, true, FreeBusyStatus::FREE(), FreeBusyStatus::FREE(), Transparency::OPAQUE(), true, $x_uid, $uid, $seq, $d, $calItemId, $apptId, $ciFolder, InviteStatus::COMPLETED(), InviteClass::PUB(), $url, true, $ridZ, true, true, true, [InviteChange::SUBJECT(), InviteChange::LOCATION(), InviteChange::TIME()], [$category], [$comment], [$contact], $geo, [$at], [$alarm], [$xprop], $fr, $desc, $descHtml, $org, $recur, $exceptId, $s, $e, $dur); $xml = '<?xml version="1.0"?>' . "\n" . '<comp' . ' method="' . $method . '"' . ' compNum="' . $compNum . '"' . ' rsvp="true"' . ' priority="' . $priority . '"' . ' name="' . $name . '"' . ' loc="' . $loc . '"' . ' percentComplete="' . $percent . '"' . ' completed="' . $date . '"' . ' noBlob="true"' . ' fba="' . FreeBusyStatus::FREE() . '"' . ' fb="' . FreeBusyStatus::FREE() . '"' . ' transp="' . Transparency::OPAQUE() . '"' . ' isOrg="true"' . ' x_uid="' . $x_uid . '"' . ' uid="' . $uid . '"' . ' seq="' . $seq . '"' . ' d="' . $d . '"' . ' calItemId="' . $calItemId . '"' . ' apptId="' . $apptId . '"' . ' ciFolder="' . $ciFolder . '"' . ' status="' . InviteStatus::COMPLETED() . '"' . ' class="' . InviteClass::PUB() . '"' . ' url="' . $url . '"' . ' ex="true"' . ' ridZ="' . $ridZ . '"' . ' allDay="true"' . ' draft="true"' . ' neverSent="true"' . ' changes="' . InviteChange::SUBJECT() . ',' . InviteChange::LOCATION() . ',' . InviteChange::TIME() . '">' . '<geo lat="' . $lat . '" lon="' . $lon . '" />' . '<fr>' . $fr . '</fr>' . '<desc>' . $desc . '</desc>' . '<descHtml>' . $descHtml . '</descHtml>' . '<or a="' . $address . '" url="' . $url . '" d="' . $displayName . '" sentBy="' . $sentBy . '" dir="' . $dir . '" lang="' . $lang . '">' . '<xparam name="' . $name . '" value="' . $value . '" />' . '</or>' . '<recur>' . '<add>' . '<except rangeType="' . $rangeType . '" recurId="' . $date . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<cancel rangeType="' . $rangeType . '" recurId="' . $date . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<dates tz="' . $tz . '">' . '<dtval>' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</dtval>' . '</dates>' . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $num . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>' . '</add>' . '<exclude>' . '<except rangeType="' . $rangeType . '" recurId="' . $date . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<cancel rangeType="' . $rangeType . '" recurId="' . $date . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<dates tz="' . $tz . '">' . '<dtval>' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</dtval>' . '</dates>' . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $num . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>' . '</exclude>' . '<except rangeType="' . $rangeType . '" recurId="' . $date . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<cancel rangeType="' . $rangeType . '" recurId="' . $date . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<dates tz="' . $tz . '">' . '<dtval>' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</dtval>' . '</dates>' . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $num . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>' . '</recur>' . '<exceptId d="' . $date . '" tz="' . $tz . '" rangeType="' . RangeType::NONE() . '" />' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '<category>' . $category . '</category>' . '<comment>' . $comment . '</comment>' . '<contact>' . $contact . '</contact>' . '<at a="' . $address . '" url="' . $url . '" d="' . $displayName . '" sentBy="' . $sentBy . '" dir="' . $dir . '" lang="' . $lang . '" cutype="' . $cutype . '" role="' . $role . '" ptst="' . ParticipationStatus::NEEDS_ACTION() . '" rsvp="true" member="' . $member . '" delTo="' . $delTo . '" delFrom="' . $delFrom . '">' . '<xparam name="' . $name . '" value="' . $value . '" />' . '</at>' . '<alarm action="' . AlarmAction::DISPLAY() . '">' . '<trigger>' . '<abs d="' . $date . '" />' . '<rel neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</trigger>' . '<repeat neg="false" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '<desc>' . $desc . '</desc>' . '<attach uri="' . $uri . '" ct="' . $ct . '">' . $value . '</attach>' . '<summary>' . $summary . '</summary>' . '<at a="' . $address . '" url="' . $url . '" d="' . $displayName . '" sentBy="' . $sentBy . '" dir="' . $dir . '" lang="' . $lang . '" cutype="' . $cutype . '" role="' . $role . '" ptst="' . ParticipationStatus::NEEDS_ACTION() . '" rsvp="true" member="' . $member . '" delTo="' . $delTo . '" delFrom="' . $delFrom . '">' . '<xparam name="' . $name . '" value="' . $value . '" />' . '</at>' . '<xprop name="' . $name . '" value="' . $value . '">' . '<xparam name="' . $name . '" value="' . $value . '" />' . '</xprop>' . '</alarm>' . '<xprop name="' . $name . '" value="' . $value . '">' . '<xparam name="' . $name . '" value="' . $value . '" />' . '</xprop>' . '</comp>'; $this->assertXmlStringEqualsXmlString($xml, (string) $comp); $array = array('comp' => array('method' => $method, 'compNum' => $compNum, 'rsvp' => true, 'priority' => $priority, 'name' => $name, 'loc' => $loc, 'percentComplete' => $percent, 'completed' => $date, 'noBlob' => true, 'fba' => FreeBusyStatus::FREE()->value(), 'fb' => FreeBusyStatus::FREE()->value(), 'transp' => Transparency::OPAQUE()->value(), 'isOrg' => true, 'x_uid' => $x_uid, 'uid' => $uid, 'seq' => $seq, 'd' => $d, 'calItemId' => $calItemId, 'apptId' => $apptId, 'ciFolder' => $ciFolder, 'status' => InviteStatus::COMPLETED()->value(), 'class' => InviteClass::PUB()->value(), 'url' => $url, 'ex' => true, 'ridZ' => $ridZ, 'allDay' => true, 'draft' => true, 'neverSent' => true, 'changes' => InviteChange::SUBJECT()->value() . ',' . InviteChange::LOCATION()->value() . ',' . InviteChange::TIME()->value(), 'category' => array($category), 'comment' => array($comment), 'contact' => array($contact), 'geo' => array('lat' => $lat, 'lon' => $lon), 'at' => array(array('a' => $address, 'url' => $url, 'd' => $displayName, 'sentBy' => $sentBy, 'dir' => $dir, 'lang' => $lang, 'cutype' => $cutype, 'role' => $role, 'ptst' => ParticipationStatus::NEEDS_ACTION()->value(), 'rsvp' => true, 'member' => $member, 'delTo' => $delTo, 'delFrom' => $delFrom, 'xparam' => array(array('name' => $name, 'value' => $value)))), 'alarm' => array(array('action' => AlarmAction::DISPLAY()->value(), 'trigger' => array('abs' => array('d' => $date), 'rel' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)), 'repeat' => array('neg' => false, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num), 'desc' => $desc, 'attach' => array('uri' => $uri, 'ct' => $ct, '_content' => $value), 'summary' => $summary, 'at' => array(array('a' => $address, 'url' => $url, 'd' => $displayName, 'sentBy' => $sentBy, 'dir' => $dir, 'lang' => $lang, 'cutype' => $cutype, 'role' => $role, 'ptst' => ParticipationStatus::NEEDS_ACTION()->value(), 'rsvp' => true, 'member' => $member, 'delTo' => $delTo, 'delFrom' => $delFrom, 'xparam' => array(array('name' => $name, 'value' => $value)))), 'xprop' => array(array('name' => $name, 'value' => $value, 'xparam' => array(array('name' => $name, 'value' => $value)))))), 'xprop' => array(array('name' => $name, 'value' => $value, 'xparam' => array(array('name' => $name, 'value' => $value)))), 'fr' => $fr, 'desc' => $desc, 'descHtml' => $descHtml, 'or' => array('a' => $address, 'url' => $url, 'd' => $displayName, 'sentBy' => $sentBy, 'dir' => $dir, 'lang' => $lang, 'xparam' => array(array('name' => $name, 'value' => $value))), 'recur' => array('add' => array('except' => array('rangeType' => $rangeType, 'recurId' => $date, 'tz' => $tz, 'ridZ' => $ridZ), 'cancel' => array('rangeType' => $rangeType, 'recurId' => $date, 'tz' => $tz, 'ridZ' => $ridZ), 'dates' => array('tz' => $tz, 'dtval' => array(array('s' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)))), 'rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $num), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value)))), 'exclude' => array('except' => array('rangeType' => $rangeType, 'recurId' => $date, 'tz' => $tz, 'ridZ' => $ridZ), 'cancel' => array('rangeType' => $rangeType, 'recurId' => $date, 'tz' => $tz, 'ridZ' => $ridZ), 'dates' => array('tz' => $tz, 'dtval' => array(array('s' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)))), 'rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $num), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value)))), 'except' => array('rangeType' => $rangeType, 'recurId' => $date, 'tz' => $tz, 'ridZ' => $ridZ), 'cancel' => array('rangeType' => $rangeType, 'recurId' => $date, 'tz' => $tz, 'ridZ' => $ridZ), 'dates' => array('tz' => $tz, 'dtval' => array(array('s' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)))), 'rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $num), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value)))), 'exceptId' => array('d' => $date, 'tz' => $tz, 'rangeType' => RangeType::NONE()->value()), 's' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num))); $this->assertEquals($array, $comp->toArray()); }
public function testFrequency() { $values = array('SEC', 'MIN', 'HOU', 'DAI', 'WEE', 'MON', 'YEA'); foreach ($values as $value) { $this->assertTrue(\Zimbra\Enum\Frequency::has($value)); } }
public function testSimpleRepeatingRule() { $name = $this->faker->word; $value = $this->faker->word; $date = $this->faker->iso8601; $num = mt_rand(1, 100); $ival = mt_rand(1, 100); $ordwk = mt_rand(1, 53); $quantity = mt_rand(5, 10); $numbers = self::randomRange(0, 59, $quantity); $seclist = $minlist = implode(',', $numbers); $numbers = self::randomRange(0, 23, $quantity); $hrlist = implode(',', $numbers); $numbers = self::randomRange(1, 31, $quantity); $modaylist = implode(',', $numbers); $numbers = self::randomRange(1, 366, $quantity); $yrdaylist = implode(',', $numbers); $numbers = self::randomRange(1, 53, $quantity); $wklist = implode(',', $numbers); $numbers = self::randomRange(1, 12, $quantity); $molist = implode(',', $numbers); $numbers = self::randomRange(1, 366, $quantity); $poslist = implode(',', $numbers); $wkday = new \Zimbra\Mail\Struct\WkDay(WeekDay::SU(), $ordwk); $until = new \Zimbra\Mail\Struct\DateTimeStringAttr($date); $count = new \Zimbra\Mail\Struct\NumAttr($num); $interval = new \Zimbra\Mail\Struct\IntervalRule($ival); $bysecond = new \Zimbra\Mail\Struct\BySecondRule($seclist); $byminute = new \Zimbra\Mail\Struct\ByMinuteRule($minlist); $byhour = new \Zimbra\Mail\Struct\ByHourRule($hrlist); $byday = new \Zimbra\Mail\Struct\ByDayRule([$wkday]); $bymonthday = new \Zimbra\Mail\Struct\ByMonthDayRule($modaylist); $byyearday = new \Zimbra\Mail\Struct\ByYearDayRule($yrdaylist); $byweekno = new \Zimbra\Mail\Struct\ByWeekNoRule($wklist); $bymonth = new \Zimbra\Mail\Struct\ByMonthRule($molist); $bysetpos = new \Zimbra\Mail\Struct\BySetPosRule($poslist); $wkst = new \Zimbra\Mail\Struct\WkstRule(WeekDay::SU()); $xname = new \Zimbra\Mail\Struct\XNameRule($name, $value); $rule = new SimpleRepeatingRule(Frequency::SECOND(), $until, $count, $interval, $bysecond, $byminute, $byhour, $byday, $bymonthday, $byyearday, $byweekno, $bymonth, $bysetpos, $wkst, [$xname]); $this->assertSame('SEC', (string) $rule->getFrequency()); $this->assertSame($until, $rule->getUntil()); $this->assertSame($count, $rule->getCount()); $this->assertSame($interval, $rule->getInterval()); $this->assertSame($bysecond, $rule->getBySecond()); $this->assertSame($byminute, $rule->getByMinute()); $this->assertSame($byhour, $rule->getByHour()); $this->assertSame($byday, $rule->getByDay()); $this->assertSame($bymonthday, $rule->getByMonthDay()); $this->assertSame($byyearday, $rule->getByYearDay()); $this->assertSame($byweekno, $rule->getByWeekNo()); $this->assertSame($bymonth, $rule->getByMonth()); $this->assertSame($bysetpos, $rule->getBySetPos()); $this->assertSame($wkst, $rule->getWeekStart()); $this->assertSame([$xname], $rule->getRuleXNames()->all()); $rule = new SimpleRepeatingRule(Frequency::MINUTE()); $rule->setFrequency(Frequency::SECOND())->setUntil($until)->setCount($count)->setInterval($interval)->setBySecond($bysecond)->setByMinute($byminute)->setByHour($byhour)->setByDay($byday)->setByMonthDay($bymonthday)->setByYearDay($byyearday)->setByWeekNo($byweekno)->setByMonth($bymonth)->setBySetPos($bysetpos)->setWeekStart($wkst)->addXNameRule($xname); $this->assertSame('SEC', (string) $rule->getFrequency()); $this->assertSame($until, $rule->getUntil()); $this->assertSame($count, $rule->getCount()); $this->assertSame($interval, $rule->getInterval()); $this->assertSame($bysecond, $rule->getBySecond()); $this->assertSame($byminute, $rule->getByMinute()); $this->assertSame($byhour, $rule->getByHour()); $this->assertSame($byday, $rule->getByDay()); $this->assertSame($bymonthday, $rule->getByMonthDay()); $this->assertSame($byyearday, $rule->getByYearDay()); $this->assertSame($byweekno, $rule->getByWeekNo()); $this->assertSame($bymonth, $rule->getByMonth()); $this->assertSame($bysetpos, $rule->getBySetPos()); $this->assertSame($wkst, $rule->getWeekStart()); $this->assertSame([$xname], $rule->getRuleXNames()->all()); $xml = '<?xml version="1.0"?>' . "\n" . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $ival . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>'; $this->assertXmlStringEqualsXmlString($xml, (string) $rule); $array = array('rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $ival), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value)))); $this->assertEquals($array, $rule->toArray()); }
public function testRecurrenceInfo() { $name = $this->faker->word; $value = $this->faker->word; $rangeType = mt_rand(1, 10); $recurId = $this->faker->iso8601; $tz = $this->faker->word; $ridZ = $this->faker->iso8601; $date = $this->faker->iso8601; $utc = mt_rand(0, 24); $weeks = mt_rand(1, 7); $days = mt_rand(1, 30); $hours = mt_rand(0, 23); $minutes = mt_rand(0, 59); $seconds = mt_rand(0, 59); $related = $this->faker->randomElement(['START', 'END']); $ordwk = mt_rand(1, 53); $num = mt_rand(1, 100); $ival = mt_rand(1, 100); $quantity = mt_rand(5, 10); $numbers = self::randomRange(0, 59, $quantity); $seclist = $minlist = implode(',', $numbers); $numbers = self::randomRange(0, 23, $quantity); $hrlist = implode(',', $numbers); $numbers = self::randomRange(1, 31, $quantity); $modaylist = implode(',', $numbers); $numbers = self::randomRange(1, 366, $quantity); $yrdaylist = implode(',', $numbers); $numbers = self::randomRange(1, 53, $quantity); $wklist = implode(',', $numbers); $numbers = self::randomRange(1, 12, $quantity); $molist = implode(',', $numbers); $numbers = self::randomRange(1, 366, $quantity); $poslist = implode(',', $numbers); $except = new \Zimbra\Mail\Struct\ExceptionRuleInfo($rangeType, $recurId, null, null, $tz, $ridZ); $cancel = new \Zimbra\Mail\Struct\CancelRuleInfo($rangeType, $recurId, $tz, $ridZ); $s = new \Zimbra\Mail\Struct\DtTimeInfo($date, $tz, $utc); $e = new \Zimbra\Mail\Struct\DtTimeInfo($date, $tz, $utc); $dur = new \Zimbra\Mail\Struct\DurationInfo(true, $weeks, $days, $hours, $minutes, $seconds, $related, $num); $dtval = new \Zimbra\Mail\Struct\DtVal($s, $e, $dur); $dates = new \Zimbra\Mail\Struct\SingleDates($tz, [$dtval]); $wkday = new \Zimbra\Mail\Struct\WkDay(WeekDay::SU(), $ordwk); $until = new \Zimbra\Mail\Struct\DateTimeStringAttr($date); $count = new \Zimbra\Mail\Struct\NumAttr($num); $interval = new \Zimbra\Mail\Struct\IntervalRule($ival); $bysecond = new \Zimbra\Mail\Struct\BySecondRule($seclist); $byminute = new \Zimbra\Mail\Struct\ByMinuteRule($minlist); $byhour = new \Zimbra\Mail\Struct\ByHourRule($hrlist); $byday = new \Zimbra\Mail\Struct\ByDayRule([$wkday]); $bymonthday = new \Zimbra\Mail\Struct\ByMonthDayRule($modaylist); $byyearday = new \Zimbra\Mail\Struct\ByYearDayRule($yrdaylist); $byweekno = new \Zimbra\Mail\Struct\ByWeekNoRule($wklist); $bymonth = new \Zimbra\Mail\Struct\ByMonthRule($molist); $bysetpos = new \Zimbra\Mail\Struct\BySetPosRule($poslist); $wkst = new \Zimbra\Mail\Struct\WkstRule(WeekDay::SU()); $xname = new \Zimbra\Mail\Struct\XNameRule($name, $value); $rule = new \Zimbra\Mail\Struct\SimpleRepeatingRule(Frequency::SECOND(), $until, $count, $interval, $bysecond, $byminute, $byhour, $byday, $bymonthday, $byyearday, $byweekno, $bymonth, $bysetpos, $wkst, [$xname]); $add = new \Zimbra\Mail\Struct\AddRecurrenceInfo([$except, $cancel, $dates, $rule]); $exclude = new \Zimbra\Mail\Struct\ExcludeRecurrenceInfo([$except, $cancel, $dates, $rule]); $recur = new RecurrenceInfo([$add, $exclude, $except, $cancel, $dates]); $this->assertSame([$add, $exclude, $except, $cancel, $dates], $recur->getRules()->all()); $recur->addRule($rule); $this->assertSame([$add, $exclude, $except, $cancel, $dates, $rule], $recur->getRules()->all()); $xml = '<?xml version="1.0"?>' . "\n" . '<recur>' . '<add>' . '<except rangeType="' . $rangeType . '" recurId="' . $recurId . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<cancel rangeType="' . $rangeType . '" recurId="' . $recurId . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<dates tz="' . $tz . '">' . '<dtval>' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</dtval>' . '</dates>' . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $ival . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>' . '</add>' . '<exclude>' . '<except rangeType="' . $rangeType . '" recurId="' . $recurId . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<cancel rangeType="' . $rangeType . '" recurId="' . $recurId . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<dates tz="' . $tz . '">' . '<dtval>' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</dtval>' . '</dates>' . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $ival . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>' . '</exclude>' . '<except rangeType="' . $rangeType . '" recurId="' . $recurId . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<cancel rangeType="' . $rangeType . '" recurId="' . $recurId . '" tz="' . $tz . '" ridZ="' . $ridZ . '" />' . '<dates tz="' . $tz . '">' . '<dtval>' . '<s d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<e d="' . $date . '" tz="' . $tz . '" u="' . $utc . '" />' . '<dur neg="true" w="' . $weeks . '" d="' . $days . '" h="' . $hours . '" m="' . $minutes . '" s="' . $seconds . '" related="' . $related . '" count="' . $num . '" />' . '</dtval>' . '</dates>' . '<rule freq="' . Frequency::SECOND() . '">' . '<until d="' . $date . '" />' . '<count num="' . $num . '" />' . '<interval ival="' . $ival . '" />' . '<bysecond seclist="' . $seclist . '" />' . '<byminute minlist="' . $minlist . '" />' . '<byhour hrlist="' . $hrlist . '" />' . '<byday>' . '<wkday day="' . WeekDay::SU() . '" ordwk="' . $ordwk . '" />' . '</byday>' . '<bymonthday modaylist="' . $modaylist . '" />' . '<byyearday yrdaylist="' . $yrdaylist . '" />' . '<byweekno wklist="' . $wklist . '" />' . '<bymonth molist="' . $molist . '" />' . '<bysetpos poslist="' . $poslist . '" />' . '<wkst day="' . WeekDay::SU() . '" />' . '<rule-x-name name="' . $name . '" value="' . $value . '" />' . '</rule>' . '</recur>'; $this->assertXmlStringEqualsXmlString($xml, (string) $recur); $array = array('recur' => array('add' => array('except' => array('rangeType' => $rangeType, 'recurId' => $recurId, 'tz' => $tz, 'ridZ' => $ridZ), 'cancel' => array('rangeType' => $rangeType, 'recurId' => $recurId, 'tz' => $tz, 'ridZ' => $ridZ), 'dates' => array('tz' => $tz, 'dtval' => array(array('s' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)))), 'rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $ival), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value)))), 'exclude' => array('except' => array('rangeType' => $rangeType, 'recurId' => $recurId, 'tz' => $tz, 'ridZ' => $ridZ), 'cancel' => array('rangeType' => $rangeType, 'recurId' => $recurId, 'tz' => $tz, 'ridZ' => $ridZ), 'dates' => array('tz' => $tz, 'dtval' => array(array('s' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)))), 'rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $ival), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value)))), 'except' => array('rangeType' => $rangeType, 'recurId' => $recurId, 'tz' => $tz, 'ridZ' => $ridZ), 'cancel' => array('rangeType' => $rangeType, 'recurId' => $recurId, 'tz' => $tz, 'ridZ' => $ridZ), 'dates' => array('tz' => $tz, 'dtval' => array(array('s' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'e' => array('d' => $date, 'tz' => $tz, 'u' => $utc), 'dur' => array('neg' => true, 'w' => $weeks, 'd' => $days, 'h' => $hours, 'm' => $minutes, 's' => $seconds, 'related' => $related, 'count' => $num)))), 'rule' => array('freq' => Frequency::SECOND()->value(), 'until' => array('d' => $date), 'count' => array('num' => $num), 'interval' => array('ival' => $ival), 'bysecond' => array('seclist' => $seclist), 'byminute' => array('minlist' => $minlist), 'byhour' => array('hrlist' => $hrlist), 'byday' => array('wkday' => array(array('day' => WeekDay::SU()->value(), 'ordwk' => $ordwk))), 'bymonthday' => array('modaylist' => $modaylist), 'byyearday' => array('yrdaylist' => $yrdaylist), 'byweekno' => array('wklist' => $wklist), 'bymonth' => array('molist' => $molist), 'bysetpos' => array('poslist' => $poslist), 'wkst' => array('day' => WeekDay::SU()->value()), 'rule-x-name' => array(array('name' => $name, 'value' => $value))))); $this->assertEquals($array, $recur->toArray()); }
public function testSimpleRepeatingRule() { $wkday = new \Zimbra\Mail\Struct\WkDay(WeekDay::SU(), 10); $until = new \Zimbra\Mail\Struct\DateTimeStringAttr('20120315T18302305Z'); $count = new \Zimbra\Mail\Struct\NumAttr(20120315); $interval = new \Zimbra\Mail\Struct\IntervalRule(20120315); $bysecond = new \Zimbra\Mail\Struct\BySecondRule('10,a,20,b,30'); $byminute = new \Zimbra\Mail\Struct\ByMinuteRule('10,a,20,b,30'); $byhour = new \Zimbra\Mail\Struct\ByHourRule('5,a,10,b,15'); $byday = new \Zimbra\Mail\Struct\ByDayRule(array($wkday)); $bymonthday = new \Zimbra\Mail\Struct\ByMonthDayRule('5,a,10,b,15,32'); $byyearday = new \Zimbra\Mail\Struct\ByYearDayRule('5,a,10,b,15,367'); $byweekno = new \Zimbra\Mail\Struct\ByWeekNoRule('5,a,10,b,15,54'); $bymonth = new \Zimbra\Mail\Struct\ByMonthRule('5,a,10,b,15'); $bysetpos = new \Zimbra\Mail\Struct\BySetPosRule('5,a,10,b,15,367'); $wkst = new \Zimbra\Mail\Struct\WkstRule(WeekDay::SU()); $xname = new \Zimbra\Mail\Struct\XNameRule('name', 'value'); $rule = new \Zimbra\Mail\Struct\SimpleRepeatingRule(Frequency::SEC(), $until, $count, $interval, $bysecond, $byminute, $byhour, $byday, $bymonthday, $byyearday, $byweekno, $bymonth, $bysetpos, $wkst, array($xname)); $this->assertSame('SEC', (string) $rule->freq()); $this->assertSame($until, $rule->until()); $this->assertSame($count, $rule->count()); $this->assertSame($interval, $rule->interval()); $this->assertSame($bysecond, $rule->bysecond()); $this->assertSame($byminute, $rule->byminute()); $this->assertSame($byhour, $rule->byhour()); $this->assertSame($byday, $rule->byday()); $this->assertSame($bymonthday, $rule->bymonthday()); $this->assertSame($byyearday, $rule->byyearday()); $this->assertSame($byweekno, $rule->byweekno()); $this->assertSame($bymonth, $rule->bymonth()); $this->assertSame($bysetpos, $rule->bysetpos()); $this->assertSame($wkst, $rule->wkst()); $this->assertSame(array($xname), $rule->ruleXName()->all()); $rule->freq(Frequency::SEC())->until($until)->count($count)->interval($interval)->bysecond($bysecond)->byminute($byminute)->byhour($byhour)->byday($byday)->bymonthday($bymonthday)->byyearday($byyearday)->byweekno($byweekno)->bymonth($bymonth)->bysetpos($bysetpos)->wkst($wkst)->addXNameRule($xname); $this->assertSame('SEC', (string) $rule->freq()); $this->assertSame($until, $rule->until()); $this->assertSame($count, $rule->count()); $this->assertSame($interval, $rule->interval()); $this->assertSame($bysecond, $rule->bysecond()); $this->assertSame($byminute, $rule->byminute()); $this->assertSame($byhour, $rule->byhour()); $this->assertSame($byday, $rule->byday()); $this->assertSame($bymonthday, $rule->bymonthday()); $this->assertSame($byyearday, $rule->byyearday()); $this->assertSame($byweekno, $rule->byweekno()); $this->assertSame($bymonth, $rule->bymonth()); $this->assertSame($bysetpos, $rule->bysetpos()); $this->assertSame($wkst, $rule->wkst()); $this->assertSame(array($xname, $xname), $rule->ruleXName()->all()); $xml = '<?xml version="1.0"?>' . "\n" . '<rule freq="SEC">' . '<until d="20120315T18302305Z" />' . '<count num="20120315" />' . '<interval ival="20120315" />' . '<bysecond seclist="10,20,30" />' . '<byminute minlist="10,20,30" />' . '<byhour hrlist="5,10,15" />' . '<byday>' . '<wkday day="SU" ordwk="10" />' . '</byday>' . '<bymonthday modaylist="5,10,15" />' . '<byyearday yrdaylist="5,10,15" />' . '<byweekno wklist="5,10,15" />' . '<bymonth molist="5,10" />' . '<bysetpos poslist="5,10,15" />' . '<wkst day="SU" />' . '<rule-x-name name="name" value="value" />' . '<rule-x-name name="name" value="value" />' . '</rule>'; $this->assertXmlStringEqualsXmlString($xml, (string) $rule); $array = array('rule' => array('freq' => 'SEC', 'until' => array('d' => '20120315T18302305Z'), 'count' => array('num' => 20120315), 'interval' => array('ival' => 20120315), 'bysecond' => array('seclist' => '10,20,30'), 'byminute' => array('minlist' => '10,20,30'), 'byhour' => array('hrlist' => '5,10,15'), 'byday' => array('wkday' => array(array('day' => 'SU', 'ordwk' => 10))), 'bymonthday' => array('modaylist' => '5,10,15'), 'byyearday' => array('yrdaylist' => '5,10,15'), 'byweekno' => array('wklist' => '5,10,15'), 'bymonth' => array('molist' => '5,10'), 'bysetpos' => array('poslist' => '5,10,15'), 'wkst' => array('day' => 'SU'), 'rule-x-name' => array(array('name' => 'name', 'value' => 'value'), array('name' => 'name', 'value' => 'value')))); $this->assertEquals($array, $rule->toArray()); }