PHPWord/tests/PhpWord/Writer/Word2007/Part/FootnotesTest.php

59 lines
2.1 KiB
PHP
Raw Normal View History

2014-03-14 04:26:50 +07:00
<?php
2014-03-27 23:55:06 +07:00
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
2014-03-27 23:55:06 +07:00
*
* @link https://github.com/PHPOffice/PHPWord
2015-12-05 21:25:59 +04:00
* @copyright 2010-2015 PHPWord contributors
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
*/
2015-11-15 13:33:05 +04:00
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
2014-03-14 04:26:50 +07:00
use PhpOffice\PhpWord\PhpWord;
2015-10-10 19:22:19 +04:00
use PhpOffice\PhpWord\SimpleType\Jc;
2015-11-15 13:33:05 +04:00
use PhpOffice\PhpWord\TestHelperDOCX;
2014-03-14 04:26:50 +07:00
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Notes
2014-03-27 23:55:06 +07:00
*
2014-03-14 04:26:50 +07:00
* @runTestsInSeparateProcesses
*/
class FootnotesTest extends \PHPUnit_Framework_TestCase
2014-03-14 04:26:50 +07:00
{
/**
* Executed before each method of the class
*/
public function tearDown()
{
TestHelperDOCX::clear();
}
2014-03-30 14:15:23 +07:00
/**
* Write footnotes
*/
2014-03-14 04:26:50 +07:00
public function testWriteFootnotes()
{
$phpWord = new PhpWord();
2015-10-10 19:22:19 +04:00
$phpWord->addParagraphStyle('pStyle', array('alignment' => Jc::START));
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Text', ENT_COMPAT, 'UTF-8'));
$footnote1 = $section->addFootnote('pStyle');
$footnote1->addText(htmlspecialchars('Footnote', ENT_COMPAT, 'UTF-8'));
2014-03-30 11:09:14 +07:00
$footnote1->addTextBreak();
$footnote1->addLink('https://github.com/PHPOffice/PHPWord');
2015-10-10 19:22:19 +04:00
$footnote2 = $section->addEndnote(array('alignment' => Jc::START));
$footnote2->addText(htmlspecialchars('Endnote', ENT_COMPAT, 'UTF-8'));
$doc = TestHelperDOCX::getDocument($phpWord);
2014-03-14 04:26:50 +07:00
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:footnoteReference'));
$this->assertTrue($doc->elementExists('/w:document/w:body/w:p/w:r/w:endnoteReference'));
2014-03-14 04:26:50 +07:00
}
}