PHPWord/tests/PhpWord/Tests/Element/FootnoteTest.php

112 lines
2.6 KiB
PHP
Raw Normal View History

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
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
*/
namespace PhpOffice\PhpWord\Tests\Element;
2014-03-09 19:09:22 +01:00
use PhpOffice\PhpWord\Element\Footnote;
2014-03-09 19:09:22 +01:00
2014-03-27 23:55:06 +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
{
/**
* New instance without parameter
*/
2014-03-09 15:04:23 -04:00
public function testConstruct()
{
$oFootnote = new Footnote();
2014-03-09 19:09:22 +01: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
/**
* New instance with string parameter
*/
2014-03-09 15:04:23 -04:00
public function testConstructString()
{
$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
/**
* New instance with array parameter
*/
2014-03-09 15:04:23 -04:00
public function testConstructArray()
{
$oFootnote = new Footnote(array('spacing' => 100));
2014-03-09 19:09:22 +01: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
/**
* Add text element
*/
2014-03-09 15:04:23 -04:00
public function testAddText()
{
$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());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Text', $element);
2014-03-09 15:04:23 -04:00
}
2014-03-09 19:09:22 +01: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()
{
$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());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Link', $element);
2014-03-09 15:04:23 -04:00
}
2014-03-09 19:09:22 +01:00
/**
* Set/get reference Id
*/
2014-03-09 15:04:23 -04:00
public function testReferenceId()
{
$oFootnote = new Footnote();
2014-03-09 19:09:22 +01:00
2014-03-09 15:04:23 -04:00
$iVal = rand(1, 1000);
$oFootnote->setReferenceId($iVal);
$this->assertEquals($oFootnote->getReferenceId(), $iVal);
}
2014-03-09 19:09:22 +01:00
/**
* Get elements
*/
2014-03-09 15:04:23 -04:00
public function testGetElements()
{
$oFootnote = new Footnote();
2014-03-09 15:04:23 -04:00
$this->assertInternalType('array', $oFootnote->getElements());
}
}