2014-03-09 19:09:22 +01:00
|
|
|
<?php
|
2014-03-27 23:55:06 +07:00
|
|
|
/**
|
|
|
|
|
* PHPWord
|
|
|
|
|
*
|
|
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
|
|
|
|
* @copyright 2014 PHPWord
|
2014-05-04 21:03:28 +04:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
2014-03-27 23:55:06 +07:00
|
|
|
*/
|
|
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
namespace PhpOffice\PhpWord\Tests\Element;
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
use PhpOffice\PhpWord\Element\Footnote;
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-27 23:55:06 +07:00
|
|
|
/**
|
2014-03-31 01:13:02 +07:00
|
|
|
* Test class for PhpOffice\PhpWord\Element\Footnote
|
2014-03-27 23:55:06 +07:00
|
|
|
*
|
|
|
|
|
* @runTestsInSeparateProcesses
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
class FootnoteTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* New instance without parameter
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testConstruct()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote();
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-31 01:13:02 +07:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Footnote', $oFootnote);
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertCount(0, $oFootnote->getElements());
|
|
|
|
|
$this->assertEquals($oFootnote->getParagraphStyle(), null);
|
|
|
|
|
}
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* New instance with string parameter
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testConstructString()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote('pStyle');
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertEquals($oFootnote->getParagraphStyle(), 'pStyle');
|
|
|
|
|
}
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* New instance with array parameter
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testConstructArray()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote(array('spacing' => 100));
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-18 17:26:03 +04:00
|
|
|
$this->assertInstanceOf(
|
|
|
|
|
'PhpOffice\\PhpWord\\Style\\Paragraph',
|
|
|
|
|
$oFootnote->getParagraphStyle()
|
|
|
|
|
);
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* Add text element
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testAddText()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote();
|
2014-03-09 15:04:23 -04:00
|
|
|
$element = $oFootnote->addText('text');
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertCount(1, $oFootnote->getElements());
|
2014-03-31 01:13:02 +07:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element);
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* Add text break element
|
|
|
|
|
*/
|
|
|
|
|
public function testAddTextBreak()
|
|
|
|
|
{
|
|
|
|
|
$oFootnote = new Footnote();
|
|
|
|
|
$oFootnote->addTextBreak(2);
|
|
|
|
|
|
|
|
|
|
$this->assertCount(2, $oFootnote->getElements());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add link element
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testAddLink()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote();
|
2014-03-09 15:04:23 -04:00
|
|
|
$element = $oFootnote->addLink('http://www.google.fr');
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertCount(1, $oFootnote->getElements());
|
2014-03-31 01:13:02 +07:00
|
|
|
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element);
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* Set/get reference Id
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testReferenceId()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote();
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-09 15:04:23 -04:00
|
|
|
$iVal = rand(1, 1000);
|
2014-04-03 08:44:41 +07:00
|
|
|
$oFootnote->setRelationId($iVal);
|
|
|
|
|
$this->assertEquals($oFootnote->getRelationId(), $iVal);
|
2014-03-09 15:04:23 -04:00
|
|
|
}
|
2014-03-09 19:09:22 +01:00
|
|
|
|
2014-03-29 00:57:23 +07:00
|
|
|
/**
|
|
|
|
|
* Get elements
|
|
|
|
|
*/
|
2014-03-09 15:04:23 -04:00
|
|
|
public function testGetElements()
|
|
|
|
|
{
|
2014-03-18 17:26:03 +04:00
|
|
|
$oFootnote = new Footnote();
|
2014-03-09 15:04:23 -04:00
|
|
|
$this->assertInternalType('array', $oFootnote->getElements());
|
|
|
|
|
}
|
2014-03-11 21:44:54 +07:00
|
|
|
}
|