PHPWord/test/PhpWord/Section/FootnoteTest.php

67 lines
1.8 KiB
PHP
Raw Normal View History

2014-03-09 19:09:22 +01:00
<?php
namespace PhpWord\Tests\Section;
2014-03-09 19:09:22 +01:00
use PhpOffice\PhpWord\Section\Footnote;
2014-03-09 19:09:22 +01:00
2014-03-09 15:04:23 -04:00
class FootnoteTest extends \PHPUnit_Framework_TestCase
{
public function testConstruct()
{
$oFootnote = new Footnote();
2014-03-09 19:09:22 +01:00
$this->assertInstanceOf('PhpOffice\\PhpWord\\Section\\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-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
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
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\\Section\\Text', $element);
2014-03-09 15:04:23 -04:00
}
2014-03-09 19:09:22 +01:00
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\\Section\\Link', $element);
2014-03-09 15:04:23 -04:00
}
2014-03-09 19:09:22 +01:00
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
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());
}
}