15 $sub = $comp->createComponent(
'VEVENT');
18 $sub = $comp->createComponent(
'VTODO');
22 foreach ($comp->children() as
$key => $subcomponent) {
25 $this->assertInstanceOf(
'Sabre\\VObject\\Component', $subcomponent);
28 $this->assertEquals(2, $count);
29 $this->assertEquals(1, $key);
37 $sub = $comp->createComponent(
'VEVENT');
40 $sub = $comp->createComponent(
'VTODO');
43 $event = $comp->vevent;
44 $this->assertInstanceOf(
'Sabre\\VObject\\Component', $event);
45 $this->assertEquals(
'VEVENT', $event->name);
47 $this->assertInternalType(
'null', $comp->vjournal);
55 $sub = $comp->createProperty(
'GROUP1.EMAIL',
'1@1.com');
58 $sub = $comp->createProperty(
'GROUP2.EMAIL',
'2@2.com');
61 $sub = $comp->createProperty(
'EMAIL',
'3@3.com');
64 $emails = $comp->email;
65 $this->assertEquals(3, count($emails));
67 $email1 = $comp->{
"group1.email"};
68 $this->assertEquals(
'EMAIL', $email1[0]->name);
69 $this->assertEquals(
'GROUP1', $email1[0]->group);
71 $email3 = $comp->{
".email"};
72 $this->assertEquals(
'EMAIL', $email3[0]->name);
73 $this->assertEquals(null, $email3[0]->group);
81 $sub = $comp->createComponent(
'VEVENT');
84 $sub = $comp->createComponent(
'VTODO');
87 $this->assertTrue(isset($comp->vevent));
88 $this->assertTrue(isset($comp->vtodo));
89 $this->assertFalse(isset($comp->vjournal));
96 $comp->myProp =
'myValue';
98 $this->assertInstanceOf(
'Sabre\\VObject\\Property', $comp->MYPROP);
99 $this->assertEquals(
'myValue', (
string)$comp->MYPROP);
107 $comp->myProp =
'myValue';
108 $comp->myProp =
'myValue';
110 $this->assertEquals(1, count($comp->children()));
111 $this->assertInstanceOf(
'Sabre\\VObject\\Property', $comp->MYPROP);
112 $this->assertEquals(
'myValue', (
string)$comp->MYPROP);
119 $comp->ORG = [
'Acme Inc',
'Section 9'];
121 $this->assertInstanceOf(
'Sabre\\VObject\\Property', $comp->ORG);
122 $this->assertEquals([
'Acme Inc',
'Section 9'], $comp->ORG->getParts());
131 $comp->myProp = $comp->createComponent(
'VEVENT');
133 $this->assertEquals(1, count($comp));
135 $this->assertEquals(
'VEVENT', $comp->VEVENT->name);
143 $comp->VEVENT = $comp->createComponent(
'VEVENT');
144 $comp->VEVENT = $comp->createComponent(
'VEVENT');
146 $this->assertEquals(1, count($comp->children()));
148 $this->assertEquals(
'VEVENT', $comp->VEVENT->name);
156 $event = $comp->createComponent(
'VEVENT');
157 $event->summary =
'Event 1';
161 $event2 = clone $event;
162 $event2->summary =
'Event 2';
166 $this->assertEquals(2, count($comp->children()));
167 $this->assertTrue($comp->vevent[1] instanceof
Component);
168 $this->assertEquals(
'Event 2', (
string)$comp->vevent[1]->summary);
176 $event = $comp->createComponent(
'VEVENT');
177 $event->summary =
'Event 1';
181 $event2 = clone $event;
182 $event2->summary =
'Event 2';
186 $this->assertTrue(isset($comp->vevent[0]));
187 $this->assertTrue(isset($comp->vevent[1]));
197 $comp[
'hey'] =
'hi there';
214 $comp->add(
'myprop',
'value');
216 $this->assertEquals(1, count($comp->children()));
218 $bla = $comp->children()[0];
220 $this->assertTrue($bla instanceof
Property);
221 $this->assertEquals(
'MYPROP', $bla->name);
222 $this->assertEquals(
'value', (
string)$bla);
230 $comp->add(
'myprop',
'value', [
'param1' =>
'value1']);
232 $this->assertEquals(1, count($comp->children()));
234 $bla = $comp->children()[0];
236 $this->assertInstanceOf(
'Sabre\\VObject\\Property', $bla);
237 $this->assertEquals(
'MYPROP', $bla->name);
238 $this->assertEquals(
'value', (
string)$bla);
240 $this->assertEquals(1, count($bla->parameters()));
242 $this->assertEquals(
'PARAM1', $bla->parameters[
'PARAM1']->name);
243 $this->assertEquals(
'value1', $bla->parameters[
'PARAM1']->getValue());
252 $comp->add($comp->createComponent(
'VEVENT'));
254 $this->assertEquals(1, count($comp->children()));
256 $this->assertEquals(
'VEVENT', $comp->VEVENT->name);
264 $comp->add($comp->createComponent(
'VEVENT'));
265 $comp->add($comp->createComponent(
'VEVENT'));
267 $this->assertEquals(2, count($comp->children()));
269 $this->assertEquals(
'VEVENT', $comp->VEVENT->name);
279 $comp->add($comp->createComponent(
'VEVENT'),
'hello');
296 $comp->add($comp->createComponent(
'VEVENT'));
298 unset($comp->vevent);
300 $this->assertEquals(0, count($comp->children()));
308 $this->assertEquals(1, $comp->count());
317 $comp->add($comp->createComponent(
'VEVENT'));
318 $comp->add($comp->createComponent(
'VTODO'));
320 $r = $comp->children();
321 $this->assertInternalType(
'array',
$r);
322 $this->assertEquals(2, count(
$r));
329 $comp->add($comp->createProperty(
'FOO',
'BAR'));
330 $comp->add($comp->createComponent(
'VTODO'));
332 $r = $comp->getComponents();
333 $this->assertInternalType(
'array',
$r);
334 $this->assertEquals(1, count(
$r));
335 $this->assertEquals(
'VTODO',
$r[0]->name);
341 $this->assertEquals(
"BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", $comp->serialize());
348 $event = $comp->add($comp->createComponent(
'VEVENT'));
349 unset($event->DTSTAMP, $event->UID);
350 $todo = $comp->add($comp->createComponent(
'VTODO'));
351 unset($todo->DTSTAMP, $todo->UID);
353 $str = $comp->serialize();
355 $this->assertEquals(
"BEGIN:VCALENDAR\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nBEGIN:VTODO\r\nEND:VTODO\r\nEND:VCALENDAR\r\n", $str);
362 $comp->add($event = $comp->createComponent(
'VEVENT'));
363 $comp->add(
'PROP1',
'BLABLA');
364 $comp->add(
'VERSION',
'2.0');
365 $comp->add($comp->createComponent(
'VTIMEZONE'));
367 unset($event->DTSTAMP, $event->UID);
368 $str = $comp->serialize();
370 $this->assertEquals(
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPROP1:BLABLA\r\nBEGIN:VTIMEZONE\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n", $str);
376 $prop4s = [
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'10'];
378 $comp =
new VCard([],
false);
380 $comp->__set(
'SOMEPROP',
'FOO');
381 $comp->__set(
'ANOTHERPROP',
'FOO');
382 $comp->__set(
'THIRDPROP',
'FOO');
383 foreach ($prop4s as $prop4) {
384 $comp->add(
'PROP4',
'FOO ' . $prop4);
386 $comp->__set(
'PROPNUMBERFIVE',
'FOO');
387 $comp->__set(
'PROPNUMBERSIX',
'FOO');
388 $comp->__set(
'PROPNUMBERSEVEN',
'FOO');
389 $comp->__set(
'PROPNUMBEREIGHT',
'FOO');
390 $comp->__set(
'PROPNUMBERNINE',
'FOO');
391 $comp->__set(
'PROPNUMBERTEN',
'FOO');
392 $comp->__set(
'VERSION',
'2.0');
393 $comp->__set(
'UID',
'FOO');
395 $str = $comp->serialize();
397 $this->assertEquals(
"BEGIN:VCARD\r\nVERSION:2.0\r\nSOMEPROP:FOO\r\nANOTHERPROP:FOO\r\nTHIRDPROP:FOO\r\nPROP4:FOO 1\r\nPROP4:FOO 2\r\nPROP4:FOO 3\r\nPROP4:FOO 4\r\nPROP4:FOO 5\r\nPROP4:FOO 6\r\nPROP4:FOO 7\r\nPROP4:FOO 8\r\nPROP4:FOO 9\r\nPROP4:FOO 10\r\nPROPNUMBERFIVE:FOO\r\nPROPNUMBERSIX:FOO\r\nPROPNUMBERSEVEN:FOO\r\nPROPNUMBEREIGHT:FOO\r\nPROPNUMBERNINE:FOO\r\nPROPNUMBERTEN:FOO\r\nUID:FOO\r\nEND:VCARD\r\n", $str);
404 'ORG' => [
'Acme Inc.',
'Section 9'],
405 'FN' =>
'Finn The Human',
408 $this->assertEquals([
'Acme Inc.',
'Section 9'], $comp->ORG->getParts());
409 $this->assertEquals(
'Finn The Human', $comp->FN->getValue());
416 $event = $comp->createComponent(
'VEVENT', [
417 $comp->createProperty(
'UID',
'12345'),
421 $this->assertEquals(
'12345', $comp->VEVENT->UID->getValue());
428 $comp->add(
'prop1',
'val1');
429 $comp->add(
'prop2',
'val2');
430 $comp->add(
'prop2',
'val2');
432 $comp->remove(
'prop2');
433 $this->assertFalse(isset($comp->prop2));
434 $this->assertTrue(isset($comp->prop1));
441 $comp->add(
'prop1',
'val1');
442 $prop = $comp->add(
'prop2',
'val2');
444 $comp->remove($prop);
445 $this->assertFalse(isset($comp->prop2));
446 $this->assertTrue(isset($comp->prop1));
456 $prop = $comp->createProperty(
'A',
'B');
457 $comp->remove($prop);
466 $vcard =
new Component\VCard();
468 $component =
new FakeComponent($vcard,
'Hi', [], $defaults =
false);
469 foreach ($componentList as $v) {
470 $component->add($v,
'Hello.');
473 $this->assertEquals($errorCount, count($component->validate()));
479 $vcard =
new Component\VCard();
481 $component =
new FakeComponent($vcard,
'Hi', [], $defaults =
false);
483 $this->assertEquals(
'yow', $component->BAR->getValue());
488 $vcard =
new Component\VCard();
490 $component =
new FakeComponent($vcard,
'WithDuplicateGIR', []);
491 $component->add(
'BAZ',
'BAZ');
492 $component->add(
'GIR',
'VALUE1');
493 $component->add(
'GIR',
'VALUE2');
497 $this->assertEquals(1, count(
$messages));
498 $this->assertEquals(3,
$messages[0][
'level']);
499 $this->assertEquals(2, count($component->GIR));
503 $vcard =
new Component\VCard();
505 $component =
new FakeComponent($vcard,
'WithDuplicateGIR', []);
506 $component->add(
'BAZ',
'BAZ');
507 $component->add(
'GIR',
'VALUE')->add(
'PARAM',
'1');
508 $component->add(
'GIR',
'VALUE')->add(
'PARAM',
'2');
512 $this->assertEquals(1, count(
$messages));
513 $this->assertEquals(3,
$messages[0][
'level']);
514 $this->assertEquals(2, count($component->GIR));
518 $vcard =
new Component\VCard();
520 $component =
new FakeComponent($vcard,
'WithDuplicateGIR', []);
521 $component->add(
'BAZ',
'BAZ');
522 $component->add(
'GIR',
'VALUE')->add(
'PARAM',
'P');
523 $component->add(
'GIR',
'VALUE')->add(
'PARAM',
'P');
527 $this->assertEquals(1, count(
$messages));
528 $this->assertEquals(1,
$messages[0][
'level']);
529 $this->assertEquals(1, count($component->GIR));
533 $vcard =
new Component\VCard();
535 $component =
new FakeComponent($vcard,
'WithDuplicateGIR', []);
536 $component->add(
'BAZ',
'BAZ');
537 $component->add(
'GIR',
'VALUE');
538 $component->add(
'GIR',
'VALUE');
542 $this->assertEquals(1, count(
$messages));
543 $this->assertEquals(1,
$messages[0][
'level']);
544 $this->assertEquals(1, count($component->GIR));
556 [[
'BAR',
'BAZ',
'ZIM',], 0],
557 [[
'BAR',
'BAZ',
'ZIM',
'GIR'], 0],
558 [[
'BAR',
'BAZ',
'ZIM',
'GIR',
'GIR'], 1],
testValidateRepairShouldNotDeduplicatePropertiesWhenValuesDiffer()
testRemoveNotFound()
InvalidArgumentException
testValidateRepairShouldNotDeduplicatePropertiesWhenParametersDiffer()
testAddArgFail()
InvalidArgumentException
testSerializeOrderCompAndProp()
testMagicSetScalarTwice()
testValidateRules($componentList, $errorCount)
ruleData
testArrayAccessSet()
LogicException
testArrayAccessUnset()
LogicException
const REPAIR
The following constants are used by the validate() method.
testAddArgFail2()
InvalidArgumentException
testValidateRepairShouldDeduplicatePropertiesWhenValuesAreEqual()
testAnotherSerializeOrderProp()
testValidateRepairShouldDeduplicatePropertiesWhenValuesAndParametersAreEqual()
testInstantiateWithChildren()
testInstantiateSubComponent()