Skip to content
Snippets Groups Projects
Commit cce1ab06 authored by Markus Poerschke's avatar Markus Poerschke
Browse files

Merge pull request #16 from ngyuki/pr-fix-fold

Fix fold and build method in Component
parents f26cae02 921005d3
No related merge requests found
......@@ -80,11 +80,15 @@ abstract class Component
$lines[] = sprintf('END:%s', $this->getType());
foreach ($lines as $key => $line) {
$lines[$key] = $this->fold($line);
$ret = array();
foreach ($lines as $line) {
foreach ($this->fold($line) as $l) {
$ret[] = $l;
}
}
return $lines;
return $ret;
}
/**
......@@ -96,7 +100,7 @@ abstract class Component
*
* @param $string
*
* @return string
* @return array
*/
public function fold($string)
{
......@@ -117,7 +121,7 @@ abstract class Component
$lines[$lineNo] = $line;
}
return implode("\r\n", $lines);
return $lines;
}
/**
......
<?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('2012-12-24'));
$vEvent->setDtEnd(new \DateTime('2012-12-24'));
$vEvent->setDescription($input);
$vCalendar->addEvent($vEvent);
$output = $vCalendar->render();
$output = preg_replace('/\r\n /u', '', $output);
$this->assertContains($input, $output);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment