diff options
Diffstat (limited to 'vendor/eluceo/ical/tests/Eluceo/iCal/Property')
5 files changed, 190 insertions, 0 deletions
diff --git a/vendor/eluceo/ical/tests/Eluceo/iCal/Property/ArrayValueTest.php b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/ArrayValueTest.php new file mode 100644 index 00000000..1d1b3331 --- /dev/null +++ b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/ArrayValueTest.php @@ -0,0 +1,26 @@ +<?php + +namespace Eluceo\iCal\Property; + +class ArrayValueTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider arrayValuesProvider + */ + public function testArrayValue($values, $expectedOutput) + { + $arrayValue = new ArrayValue($values); + + $this->assertEquals($expectedOutput, $arrayValue->getEscapedValue()); + } + + public function arrayValuesProvider() + { + return array( + array(array(), ''), + array(array('Lorem'), 'Lorem'), + array(array('Lorem', 'Ipsum'), 'Lorem,Ipsum'), + array(array('Lorem', '"doublequotes"'), 'Lorem,\"doublequotes\"'), + ); + } +} diff --git a/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/DescriptionTest.php b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/DescriptionTest.php new file mode 100644 index 00000000..0ad16bcc --- /dev/null +++ b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/DescriptionTest.php @@ -0,0 +1,17 @@ +<?php + +namespace Eluceo\iCal\Property\Event; + +class DescriptionTest extends \PHPUnit_Framework_TestCase +{ + public function testAllowsNewLines() + { + $testString = "New String \n New Line"; + $description = new Description($testString); + + $this->assertEquals( + str_replace("\n", "\\n", $testString), + $description->getEscapedValue() + ); + } +} diff --git a/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/OrganizerTest.php b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/OrganizerTest.php new file mode 100644 index 00000000..71acdce9 --- /dev/null +++ b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/OrganizerTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Eluceo\iCal\Property\Event\OrganizerTest + * + * @author Giulio Troccoli <giulio@troccoli.it> + */ + +namespace Eluceo\iCal\Property\Event; + +/** + * OrganizerTest + */ +class OrganizerTest extends \PHPUnit_Framework_TestCase +{ + public function testOrganizerValueOnly() + { + $value = "MAILTO:name.lastname@example.com"; + $expected = "ORGANIZER:$value"; + + $vCalendar = $this->createCalendarWithOrganizer( + new \Eluceo\iCal\Property\Event\Organizer($value) + ); + + foreach (explode("\n", $vCalendar->render()) as $line) + { + if (preg_match('/^ORGANIZER[:;](.*)$/', $line)) { + $this->assertEquals($expected, trim($line)); + } + } + } + + public function testOrganizerValueAndParameter() + { + $value = "MAILTO:name.lastname@example.com"; + $param = "Name LastName"; + $expected = "ORGANIZER;CN=$param:$value"; + + $vCalendar = $this->createCalendarWithOrganizer( + new \Eluceo\iCal\Property\Event\Organizer($value, array('CN' => $param)) + ); + + foreach (explode("\n", $vCalendar->render()) as $line) + { + if (preg_match('/^ORGANIZER[:;](.*)$/', $line)) { + $this->assertEquals($expected, trim($line)); + } + } + + } + + /** + * @param Organizer $vOrganizer + * @return \Eluceo\iCal\Component\Calendar + */ + private function createCalendarWithOrganizer(\Eluceo\iCal\Property\Event\Organizer $vOrganizer) + { + $vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com'); + $vEvent = new \Eluceo\iCal\Component\Event('123456'); + $vEvent->setOrganizer($vOrganizer); + $vCalendar->addComponent($vEvent); + return $vCalendar; + } +} diff --git a/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/RecurrenceRuleTest.php b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/RecurrenceRuleTest.php new file mode 100644 index 00000000..a44b2580 --- /dev/null +++ b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/RecurrenceRuleTest.php @@ -0,0 +1,21 @@ +<?php + +namespace Eluceo\iCal\Property\Event; + +class RecurrenceRuleTest extends \PHPUnit_Framework_TestCase +{ + /** + * Example taken from http://www.kanzaki.com/docs/ical/rrule.html + */ + public function testUntil() + { + $rule = new RecurrenceRule(); + $rule->setFreq(RecurrenceRule::FREQ_DAILY); + $rule->setInterval(null); + $rule->setUntil(new \DateTime('1997-12-24')); + $this->assertEquals( + 'FREQ=DAILY;UNTIL=19971224T000000Z', + $rule->getEscapedValue() + ); + } +} diff --git a/vendor/eluceo/ical/tests/Eluceo/iCal/Property/StringValueTest.php b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/StringValueTest.php new file mode 100644 index 00000000..afa70df1 --- /dev/null +++ b/vendor/eluceo/ical/tests/Eluceo/iCal/Property/StringValueTest.php @@ -0,0 +1,63 @@ +<?php + +namespace Eluceo\iCal\Property; + +use Eluceo\iCal\Property\StringValue; + +class StringValueTest extends \PHPUnit_Framework_TestCase +{ + public function testNoEscapeNeeded() + { + $stringValue = new StringValue('LOREM'); + + $this->assertEquals( + 'LOREM', + $stringValue->getEscapedValue(), + 'No escaping necessary' + ); + } + + public function testValueContainsBackslash() + { + $stringValue = new StringValue('text contains backslash: \\'); + + $this->assertEquals( + 'text contains backslash: \\\\', + $stringValue->getEscapedValue(), + 'Text contains backslash' + ); + } + + public function testEscapingDoubleQuotes() + { + $stringValue = new StringValue('text with "doublequotes" will be escaped'); + + $this->assertEquals( + 'text with \\"doublequotes\\" will be escaped', + $stringValue->getEscapedValue(), + 'Escaping double quotes' + ); + } + + public function testEscapingSemicolonAndComma() + { + $stringValue = new StringValue('text with , and ; will also be escaped'); + + $this->assertEquals( + 'text with \\, and \\; will also be escaped', + $stringValue->getEscapedValue(), + 'Escaping ; and ,' + ); + } + + public function testNewLineEscaping() + { + $stringValue = new StringValue("Text with new\n line"); + + $this->assertEquals( + 'Text with new\\n line', + $stringValue->getEscapedValue(), + 'Escape new line to text' + ); + } +} |