Include composer dependencies in repo
This commit is contained in:
64
vendor/eluceo/ical/tests/Eluceo/iCal/Component/CalendarIntegrationTest.php
vendored
Normal file
64
vendor/eluceo/ical/tests/Eluceo/iCal/Component/CalendarIntegrationTest.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal\Component;
|
||||
|
||||
class CalendarIntegrationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @coversNothing
|
||||
*/
|
||||
public function testExample3()
|
||||
{
|
||||
$timeZone = new \DateTimeZone('Europe/Berlin');
|
||||
|
||||
// 1. Create new calendar
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
|
||||
// 2. Create an event
|
||||
$vEvent = new \Eluceo\iCal\Component\Event('123456');
|
||||
$vEvent->setDtStart(new \DateTime('2012-12-31', $timeZone));
|
||||
$vEvent->setDtEnd(new \DateTime('2012-12-31', $timeZone));
|
||||
$vEvent->setNoTime(true);
|
||||
$vEvent->setIsPrivate(true);
|
||||
$vEvent->setSummary('New Year’s Eve');
|
||||
|
||||
// Set recurrence rule
|
||||
$recurrenceRule = new \Eluceo\iCal\Property\Event\RecurrenceRule();
|
||||
$recurrenceRule->setFreq(\Eluceo\iCal\Property\Event\RecurrenceRule::FREQ_YEARLY);
|
||||
$recurrenceRule->setInterval(1);
|
||||
$vEvent->setRecurrenceRule($recurrenceRule);
|
||||
|
||||
// Adding Timezone (optional)
|
||||
$vEvent->setUseTimezone(true);
|
||||
|
||||
// 3. Add event to calendar
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
$lines = array(
|
||||
'/BEGIN:VCALENDAR/',
|
||||
'/VERSION:2\.0/',
|
||||
'/PRODID:www\.example\.com/',
|
||||
'/X-PUBLISHED-TTL:P1W/',
|
||||
'/BEGIN:VEVENT/',
|
||||
'/UID:123456/',
|
||||
'/DTSTART;TZID=Europe\/Berlin;VALUE=DATE:20121231/',
|
||||
'/SEQUENCE:0/',
|
||||
'/TRANSP:OPAQUE/',
|
||||
'/DTEND;TZID=Europe\/Berlin;VALUE=DATE:20121231/',
|
||||
'/SUMMARY:New Year’s Eve/',
|
||||
'/CLASS:PRIVATE/',
|
||||
'/RRULE:FREQ=YEARLY;INTERVAL=1/',
|
||||
'/X-MICROSOFT-CDO-ALLDAYEVENT:TRUE/',
|
||||
'/DTSTAMP:20\d{6}T\d{6}Z/',
|
||||
'/END:VEVENT/',
|
||||
'/END:VCALENDAR/',
|
||||
);
|
||||
|
||||
foreach (explode("\n", $vCalendar->render()) as $key => $line)
|
||||
{
|
||||
$this->assertTrue(isset($lines[$key]), 'Too many lines... ' . $line);
|
||||
|
||||
$this->assertRegExp($lines[$key], $line);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
vendor/eluceo/ical/tests/Eluceo/iCal/ComponentTest.php
vendored
Normal file
45
vendor/eluceo/ical/tests/Eluceo/iCal/ComponentTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class ComponentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFoldWithMultibyte()
|
||||
{
|
||||
$input = "x" . str_repeat("あいうえお", 5);
|
||||
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDescription($input);
|
||||
|
||||
$vAlarm = new \Eluceo\iCal\Component\Alarm;
|
||||
$vAlarm->setAction(\Eluceo\iCal\Component\Alarm::ACTION_DISPLAY);
|
||||
$vAlarm->setDescription($input);
|
||||
$vAlarm->setTrigger('PT0S', true);
|
||||
$vEvent->addComponent($vAlarm);
|
||||
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
$output = $vCalendar->render();
|
||||
$output = preg_replace('/\r\n /u', '', $output);
|
||||
$this->assertContains($input, $output);
|
||||
}
|
||||
|
||||
public function testDescriptionWithNewLines()
|
||||
{
|
||||
$input = "new string \n new line \n new line \n new string";
|
||||
|
||||
$vCalendar = new \Eluceo\iCal\Component\Calendar('www.example.com');
|
||||
$vEvent = new \Eluceo\iCal\Component\Event();
|
||||
$vEvent->setDtStart(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDtEnd(new \DateTime('2014-12-24'));
|
||||
$vEvent->setDescription($input);
|
||||
|
||||
$vCalendar->addComponent($vEvent);
|
||||
|
||||
$output = $vCalendar->render();
|
||||
$this->assertContains(str_replace("\n", "\\n", $input), $output);
|
||||
}
|
||||
}
|
||||
35
vendor/eluceo/ical/tests/Eluceo/iCal/ParameterBagTest.php
vendored
Normal file
35
vendor/eluceo/ical/tests/Eluceo/iCal/ParameterBagTest.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class ParameterBagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testEscapeParamValue()
|
||||
{
|
||||
$propertyObject = new ParameterBag;
|
||||
|
||||
$this->assertEquals(
|
||||
'test string',
|
||||
$propertyObject->escapeParamValue('test string'),
|
||||
'No escaping necessary'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'"Containing \\"double-quotes\\""',
|
||||
$propertyObject->escapeParamValue('Containing "double-quotes"'),
|
||||
'Text contains double quotes'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'"Containing forbidden chars like a ;"',
|
||||
$propertyObject->escapeParamValue('Containing forbidden chars like a ;'),
|
||||
'Text with semicolon'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'"Containing forbidden chars like a :"',
|
||||
$propertyObject->escapeParamValue('Containing forbidden chars like a :'),
|
||||
'Text with colon'
|
||||
);
|
||||
}
|
||||
}
|
||||
26
vendor/eluceo/ical/tests/Eluceo/iCal/Property/ArrayValueTest.php
vendored
Normal file
26
vendor/eluceo/ical/tests/Eluceo/iCal/Property/ArrayValueTest.php
vendored
Normal file
@@ -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\"'),
|
||||
);
|
||||
}
|
||||
}
|
||||
17
vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/DescriptionTest.php
vendored
Normal file
17
vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/DescriptionTest.php
vendored
Normal file
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
63
vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/OrganizerTest.php
vendored
Normal file
63
vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/OrganizerTest.php
vendored
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
21
vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/RecurrenceRuleTest.php
vendored
Normal file
21
vendor/eluceo/ical/tests/Eluceo/iCal/Property/Event/RecurrenceRuleTest.php
vendored
Normal file
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
63
vendor/eluceo/ical/tests/Eluceo/iCal/Property/StringValueTest.php
vendored
Normal file
63
vendor/eluceo/ical/tests/Eluceo/iCal/Property/StringValueTest.php
vendored
Normal file
@@ -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'
|
||||
);
|
||||
}
|
||||
}
|
||||
18
vendor/eluceo/ical/tests/Eluceo/iCal/PropertyBagTest.php
vendored
Normal file
18
vendor/eluceo/ical/tests/Eluceo/iCal/PropertyBagTest.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class PropertyBagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @todo Use Mocks instead of a real object!
|
||||
*/
|
||||
public function testPropertyAlreadyExistsOnAddingProperty()
|
||||
{
|
||||
$this->setExpectedException('\\Exception', "Property with name 'propName' already exists");
|
||||
|
||||
$propertyBag = new PropertyBag();
|
||||
$propertyBag->add(new Property('propName', ''));
|
||||
$propertyBag->add(new Property('propName', ''));
|
||||
}
|
||||
}
|
||||
42
vendor/eluceo/ical/tests/Eluceo/iCal/PropertyTest.php
vendored
Normal file
42
vendor/eluceo/ical/tests/Eluceo/iCal/PropertyTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Eluceo\iCal;
|
||||
|
||||
class PropertyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testPropertyWithSingleValue()
|
||||
{
|
||||
$property = new Property('DTSTAMP', '20131020T153112');
|
||||
$this->assertEquals(
|
||||
'DTSTAMP:20131020T153112',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyWithValueAndParams()
|
||||
{
|
||||
$property = new Property('DTSTAMP', '20131020T153112', array('TZID' => 'Europe/Berlin'));
|
||||
$this->assertEquals(
|
||||
'DTSTAMP;TZID=Europe/Berlin:20131020T153112',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyWithEscapedSingleValue()
|
||||
{
|
||||
$property = new Property('SOMEPROP', 'Escape me!"');
|
||||
$this->assertEquals(
|
||||
'SOMEPROP:Escape me!\\"',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
|
||||
public function testPropertyWithEscapedValues()
|
||||
{
|
||||
$property = new Property('SOMEPROP', 'Escape me!"', array('TEST' => 'Lorem "test" ipsum'));
|
||||
$this->assertEquals(
|
||||
'SOMEPROP;TEST="Lorem \\"test\\" ipsum":Escape me!\\"',
|
||||
$property->toLine()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user