Include composer dependencies in repo

This commit is contained in:
Frederic Guillot
2017-10-25 16:22:10 -07:00
parent c507c54162
commit 9e2b2a32fd
1787 changed files with 123616 additions and 45 deletions

View 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\"'),
);
}
}

View 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()
);
}
}

View 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;
}
}

View 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()
);
}
}

View 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'
);
}
}