setWriter($writer);
$this->_container = $this->getMockForAbstractClass('PHPRtfLite_Container',
array(),
'',
false);
$this->_container->__construct($rtf);
}
/**
* tests writeRtfCode
*/
public function testWriteRftCode()
{
$this->_container->writeRtfCode('test text');
$this->_container->render();
$this->assertEquals('{test text}', trim($this->_container->getRtf()->getWriter()->getContent()));
}
/**
* tests addEmptyParagraph
*/
public function testAddEmptyParagraph()
{
$this->_container->addEmptyParagraph();
$this->_container->render();
$this->assertEquals('\pard \ql {\par}', trim($this->_container->getRtf()->getWriter()->getContent()));
}
/**
* tests addEmptyParagraph
*/
public function testAddEmptyParagraphWithFontAndParFormat()
{
$font = new PHPRtfLite_Font();
$parFormat = new PHPRtfLite_ParFormat();
$this->_container->addEmptyParagraph($font, $parFormat);
$this->_container->render();
$this->assertEquals('\pard \ql {\fs20 \par}', trim($this->_container->getRtf()->getWriter()->getContent()));
}
/**
* tests writeText
*
* @return PHPRtfLite_Container
*/
public function testWriteTextForEmptyParagraph()
{
$this->_container->writeText('Hello world!');
$this->_container->render();
$this->assertEquals('{Hello world!}', trim($this->_container->getRtf()->getWriter()->getContent()));
return $this->_container;
}
/**
* tests addEmptyParagraph
* @depends testWriteTextForEmptyParagraph
*
* @param PHPRtfLite_Container $container
*/
public function testWriteTextAddEmptyParagraphWithFontAndParFormat(PHPRtfLite_Container $container)
{
$font = new PHPRtfLite_Font();
$parFormat = new PHPRtfLite_ParFormat();
$container->addEmptyParagraph($font, $parFormat);
$container->render();
$this->assertEquals('{Hello world!}' . "\r\n" . '\par \pard \ql {\fs20 \par}',
trim($container->getRtf()->getWriter()->getContent()));
}
/**
* @dataProvider provideWriteText
* tests writeText
*/
public function testWriteText($input, $expected)
{
#$this->_container->getRtf()->getWriter()->content = '';
$this->_container->writeText($input);
$this->_container->render();
$this->assertEquals($expected, trim($this->_container->getRtf()->getWriter()->getContent()));
}
/**
*
* @return array
*/
public function provideWriteText()
{
return array(
array('Hello world!', '{Hello world!}'),
array('Hello world!', '{\b Hello world!\b0 }'),
array('Hello world!', '{\b Hello world!\b0 }'),
array('Hello world!', '{\b Hello world!\b0 }'),
array('Hello world!', '{\b Hello world!\b0 }'),
array('Hello world!', '{\i Hello world!\i0 }'),
array('Hello world!', '{\i Hello world!\i0 }'),
array('Hello world!', '{\i Hello world!\i0 }'),
array('Hello world!', '{\i Hello world!\i0 }'),
array('Hello world!', '{\ul Hello world!\ul0 }'),
array('Hello world!', '{\ul Hello world!\ul0 }'),
array('Hello
world!', '{Hello\line \line world!}'),
array('Hello
world!', '{Hello\line \line world!}'),
array(
'Hello